<repo_name>golfchanut/sratong<file_sep>/modules/print/index.js
var opPage = 'print';
$(document).ready(function() {
	get_coures_id_list();
	//$(".course_detal_box").hide();
}); 


function set_room(){
	$(".room_value").val($("#room_search").val());	
}
function get_downloadPDF_all(){

	$( "#form_pdf_all_page" ).submit();
}
function get_downloadPDF_cover(){
	$( "#form_pdf_cover_page" ).submit();
}
function get_class_level(){
	var coures_id_list_val =$("#coures_id_list").val();
	$(".pdf_value").val(coures_id_list_val);
	
	var formData = new Array();
	formData.push({ "name": "acc_action", "value": "get_class_level" });
	formData.push({ "name": "coures_id_list_val", "value": coures_id_list_val });
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {
		$("#place_class_level").html(data.class_level);
		$("#place_class_level_val").val(data.class_level);
		if (data.status==2) {
			if (data.status_form==25 ||data.status_form==26 || data.status_form==27) {
				$(".class_set").css('display','inline-block');
			}else{
				$(".class_set").css('display','none');
			}
			
		}else{
			$(".class_set").css('display','inline-block');
		}
		$("#room_search").html(data.room);	
		$(".status").val(data.status);
		$(".status_form").val(data.status_form);		
		$(".room_value").val($("#room_search").val());	
	})
}
function get_coures_id_list(){
	var formData = new Array();
	formData.push({ "name": "acc_action", "value": "get_coures_id_list" });
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {
		$("#coures_id_list").html(data.coures_id_list);
		get_class_level();
	})
}<file_sep>/modules/attend_class/index.php
<?php session_start(); ?>
<div class="container set-content-pad-20" >
  <div class="bg-whte" style="position: relative;padding-bottom: 60px">
    <div class="circle-bg-violet">
      <img class="head-img-circle" src="assets/images/9.png">
    </div>
    <div class="text-head-title">
      <p>บันทึกเข้าเรียน</p>
    </div>
    <div class="text-head-desc">
      <p>ใช้สำหรับการบันทึกคะแนนของนักเรียนในแต่ละรายวิชา</p>
    </div>
    <div class="row pd-40 pt-80 stage-set" >   
    <?php if($_SESSION['ss_status']==2){ ?>
      <div class="col-sm-12 col-xs-12 mt-30">                        
        <div class="set-line">
          <form id="frm_data_room_admin">        
               <p class="text-bold text-inline fs-16">เลือกภาคเรียน</p>
              <select id="term_data" name="term_data" class="form-control search-drop-sub-class mr-20">
                 <option value="1">1</option>
                            <option value="2">2</option>
                            <option selected="selected" value="1,2">1,2</option>
                </select>  
               <p class="text-inline fs-14">ปีการศึกษา</p>
              <select id="year_data" name="year_data" class="form-control search-drop-sub-years mr-20">

              </select>   
              <div id="btn_search_course_detail_admin" class="btn-search-save-score">
                <div class="btn-search">
                  <span class="glyphicon glyphicon-arrow-right" aria-hidden="true"></span>
                </div>  
              </div>
            </form>
          </div>
        </div>     
      <?php } ?>                       
      <div class="col-sm-12 col-xs-12 mt-5">                        
        <div class="set-line">
          <form id="frm_data_room">
            <p class="text-bold text-inline fs-16">เลือกรายวิชา</p>
            <select onchange="get_class_level()" id="coures_id_list" name="coures_id_list" class="form-control search-drop-sub-id mr-30">

            </select>
            <p class="text-inline fs-14">ชั้น</p>
            <p id="place_class_level" class="text-inline mr-20"></p>

            <span id="slash-class" class="slash-class" style="display: none;">/</span>
            <form id="frm_data_room">
              <select id="room_search" style="display: none;" name="room_search" class="form-control search-drop-sub-class mr-20">

              </select>    
              <div id="btn_search_course_detail" class="btn-search-save-score">
                <div class="btn-search">
                  <span class="glyphicon glyphicon-arrow-right" aria-hidden="true"></span>
                </div>  
              </div>
            </form>
          </div>
        </div>                     
      </div>
      <div class="row">
        <div class="hr-co-text-depart mt-nega-30"></div> 
      </div>
      <div class="ml-50 mr-50 mt-nega-10 course_detal_box" style="display: none;" >
        <div class="row">
          <div class="box-search-depart">
            <div class="set-line">
              <div id="rate_score_box" class="col-sm-12 col-xs-12" style="display: block;">  
                <div class="row">
                  <table>
                    <tbody style="border: none;">
                      <tr >
                        <td class="text-before-box3 text-bold" style="float: right;">
                          รหัสวิชา
                        </td>
                        <td width="100px">
                          <p id="place_detail_courseID" class=" text-before-box2 " ></p> 
                        </td>

                        <td class="text-before-box3 text-bold">
                          รายวิชา
                        </td>
                        <td width="350px">
                          <p id="place_detail_name" class=" text-before-box2 "></p> 
                        </td>

                        <td class="text-before-box3 text-bold">
                          น.น./นก.
                        </td>
                        <td width="40px">
                          <p id="place_detail_unit" class=" text-before-box2 "></p> 
                        </td>

                        <td class="text-before-box3 text-bold">
                          เวลาเรียน/สัปดาห์
                        </td>
                        <td >
                          <p id="place_detail_hr_learn" class=" text-before-box2 "></p> 
                        </td>
                      </tr>
                      <tr >
                        <td class="text-before-box3 text-bold" style="float: right;">
                          ชั้น
                        </td>
                        <td>
                          <p id="place_detail_class_level" class=" text-before-box2 ">

                          </p> 
                        </td>

                      </tr>

                    </tbody>                                         
                  </table>
                </div>                               
              </div>  
            </div>                              
          </div>
        </div>
      </div>
      
      <input type="text" hidden="hidden" id="registed_course_id" name="registed_course_id">
      
      <div  class="ml-50 mr-50 course_detal_box " style="display: none;" >
        <div class="row">
          <div class="box-search-depart">
            <div class="set-line">
              <div id="rate_score_box" class="col-sm-12 col-xs-12" style="display: block;">  
                <div class="row">
                  <table>
                    <tbody style="border: none;">
                      <tr id="get_day_set">
                       
                      </tr>

                    </tbody>
                  </table>
                  <table class="mt-20">
                    <tbody style="border: none;">

                      <tr>
                        <td class="text-before-box3 text-bold" style="float: right;">
                          สัปดาห์
                        </td> 
                        <td width="200px">

                          <form id="frm_data_legth_score">
                            <select onchange="get_day_list()" id="length_list_val" name="length_list_val" class="form-control search-drop-length-ob mt-5 week_m">
                               
                            </select> 
                           
                          </form>
                        </td>
                      </tr>
                    </tbody>                                         
                  </table>
                </div>                               
              </div>  
            </div>                              
          </div>
        </div>
      </div>
     <div class="alert_attend_day_chk ml-50 mr-50 mt-20 " style="display: none;">
        <div class="row">
          <div class="col-md-12">
            <div style="width: 70%;background-color: #ac68cc;margin: 0 auto;padding: 30px;">
              <p style="color: #fff;font-size: 30px;text-align: center;">กรุณากำหนดวันเรียน</p>
            </div>
          </div>
        </div>
      </div>
      <div class=" ml-50 mr-50 mt-20 course_detal_box num_attend_day_chk" style="display: none;">
        <div class="row">
          <div class="col-md-12">
            <div class="table-responsive">
              <table class="table table-striped-violet border-set-violet" style="text-align: center;">
                <thead class="header-table">
                  <tr class="text-middle">
                    <td  rowspan = "3" width="8%" style="  vertical-align: middle;">เลขที่</td>
                    <td  rowspan = "3" width="8%" style="  vertical-align: middle;">รหัส</td>
                    <td id="room_col" rowspan = "3" width="8%" style="display: none; vertical-align: middle;">ห้อง</td>
                    <td rowspan = "3" width="35%" style="  vertical-align: middle;">ชื่อ-สกุล</td>

                    <td id="set_colspan_save_score_title" colspan="6">บันทึกเข้าเรียน</td>      

                  </tr>
                  <tr>
                    <td colspan="5" id="week_title"></td> 
                    <td style="width: 8%">เวลาเรียน</td>
                    <td style="width: 8%">เฉลี่ย<br>(ร้อยละ)</td>
                  </tr>

                  <tr id="week_header">
                   
                  </tr>

                </thead>
                <tbody id="detail_std" class="body-table">
                  
                </tbody>
              </table> 
            </div>
          </div>                                     
        </div>   
       <!-- 
        <div class="btn-group-set-add-delete row pd-30 ">                                                     
          <div class="btn-grey">
            ยกเลิก
          </div>    
          <div data-toggle="modal" data-target="#modalAddAttend" class="btn-violet">
            บันทึก
          </div>                   
        </div>-->
        <input id="all_attendID" hidden="hidden" type="text" name="" value="">
        <div class="ml-50">
          <div class="row">
            <div class="col-sm-2">
              <p>หมายเหตุ : </p>
            </div>
            <div class="col-sm-6">
              <table>

                <tbody class="border-none">
                  <tr>
                    <td width="20px">1</td>
                    <td width="70px">หมายถึง</td>
                    <td width="70px">มา</td>
                    <td width="80px">มีค่าเท่ากับ</td>
                    <td width="30px">1</td>
                    <td width="40">คะแนน</td>
                  </tr>
                  <tr>
                    <td width="20px">ล</td>
                    <td width="70px">หมายถึง</td>
                    <td width="70px">ลากิจ</td>
                    <td width="80px">มีค่าเท่ากับ</td>
                    <td width="30px">0</td>
                    <td width="40">คะแนน</td>
                  </tr>
                  <tr>
                    <td width="20px">ป</td>
                    <td width="70px">หมายถึง</td>
                    <td width="70px">ลาป่วย</td>
                    <td width="80px">มีค่าเท่ากับ</td>
                    <td width="30px">0</td>
                    <td width="40">คะแนน</td>
                  </tr>
                  <tr>
                    <td width="20px">ข</td>
                    <td width="70px">หมายถึง</td>
                    <td width="70px">ขาด</td>
                    <td width="80px">มีค่าเท่ากับ</td>
                    <td width="30px">0</td>
                    <td width="40">คะแนน</td>
                  </tr>
                  <tr>
                    <td width="20px">น</td>
                    <td width="70px">หมายถึง</td>
                    <td width="70px">หนีเรียน</td>
                    <td width="80px">มีค่าเท่ากับ</td>
                    <td width="30px">0</td>
                    <td width="40">คะแนน</td>
                  </tr>

                </tbody>
              </table>
            </div>
          </div>

        </div>
      </div>
    </div>
  
    <input id="std_id_all" type="text" hidden="hidden" name="">
  </div><file_sep>/modules/mobile_api/config.php
<?php
	@header( 'Pragma: no-cache' );
	@header( 'Content-Type:text/html; charset=utf-8');
	date_default_timezone_set('Asia/Bangkok');
	error_reporting(0);


	define("DB_SERVER","localhost");
	define("DB_USER","admin_eva");	
	define("DB_PASS","<PASSWORD>");
	define("DB_DATABASE","sratongact_eva");


?>

<file_sep>/modules/attend_class/backup/process.php
<?php
@ob_start();
@session_start();

require_once('../../init.php');
include('../../src/class.pagination.php');
include('../../src/class.inputfilter.php');
$InputFilter = new InputFilter();

##CLASS_DB_CONNECT##
include('class_modules.php');
$class_data = new ClassData();
##CLASS_DB_CONNECT##

if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_week_between"){
	$coures_id_list_val=$_GET['coures_id_list_val'];
	echo $class_data->get_week_between($coures_id_list_val);	
}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_count_adttend_class_val"){
	$coures_id_list_val=$_GET['coures_id_list_val'];
	echo $class_data->get_count_adttend_class_val($coures_id_list_val);	
}
if(isset($_POST['acc_action']) and $_POST['acc_action'] == "save_attend_score_std"){
	$std_id_all=$_POST['std_id_all'];	
	$value_attend_week=$_POST['value_attend_week'];
	$all_attendID=$_POST['all_attendID'];

	$coures_id_list_val=$_POST['coures_id_list_val'];
	//$set_count_adttend_class_val=$_POST['set_count_adttend_class_val'];
	
	$arr_std_id_all = explode("-", $std_id_all);
	$arr_value_attend_week = explode(",", $value_attend_week);
	$arr_all_attendID = explode("-", $all_attendID);
	$num_1=0;

	for ($i=0; $i <count($arr_std_id_all) ; $i++) {
		for ($k=0; $k < 10; $k++) { 
			$class_data->sql ="
			UPDATE tbl_attend_class SET score_status='$arr_value_attend_week[$num_1]' WHERE DataID=$arr_all_attendID[$num_1]
			";	
   	 		echo $class_data->query();		
	   	 	$num_1++;
		}
	}
	//echo $class_data->set_count_adttend_class_val($coures_id_list_val,$set_count_adttend_class_val);
}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_week_list_data"){	
	$room_search=$_GET['room_search'];
	$coures_id_list_val=$_GET['coures_id_list_val'];
	$length_list_val=$_GET['length_list_val'];	
	echo $class_data->get_week_list_data($coures_id_list_val,$length_list_val,$room_search);
}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_week_list"){	
	$length_list_val=$_GET['length_list_val'];
	echo $class_data->get_week_list($length_list_val);
}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "search_course_detail"){	
	$coures_id_list=$_GET['coures_id_list'];
	$room_search=$_GET['room_search'];
	echo $class_data->search_course_detail($coures_id_list,$room_search);
}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_class_level"){	
	$coures_id_list_val=$_GET['coures_id_list_val'];
	echo $class_data->get_class_level($coures_id_list_val);
}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_coures_id_list"){	
	echo $class_data->get_coures_id_list();
}<file_sep>/modules/report/pdf_form.php
<link href="../../assets/css/bootstrap.css" rel="stylesheet" type="text/css">
<link href="../../assets/css/custom.css" rel="stylesheet" type="text/css">
<link href="../../assets/css/margin-padding.css" rel="stylesheet" type="text/css">
<link href="../../assets/css/responsive.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
 table {
    border-collapse: collapse;
}

td, th {
    border: 1px solid black;
    padding: 5px;
}
-->
</style>
<?php
 @session_start();
    include('logo.php');
    require_once('../../init.php');
    include('class_modules.php');
    $class_data = new ClassData();

$class_data->sql ="SELECT *
        FROM tbl_add_delete_course   
        WHERE DataID=$data_id
        ";
  $class_data->select();
  $class_data->setRows();
  $courseID=$class_data->rows[0]['courseID'];
  $name=$class_data->rows[0]['name'];
  $class_level=$class_data->rows[0]['class_level'];

  //$class_level_new=$class_data->get_class_level_new($class_level);
  if ($class_level=='p1' || $class_level=='p2' || $class_level=='p3' || $class_level=='p4' || $class_level=='p5' || $class_level=='p6') { 
   $class_level_remove=str_replace('p','',$class_level);
  }else{
   $class_level_remove=str_replace('m','',$class_level);
  }
  $get_grade_summary=$class_data->get_grade_summary($data_id,$room_search,$status);
  if($status==1/* || $page=='all_page'*/){
   
   $attend=$class_data->get_attend($data_id,$status,$room_search);
   $objective_list=$class_data->get_objective_list($data_id,$room_search);
   $std_desirable=$class_data->get_std_desirable($data_id,$room_search);
  }
  if ($status==2) {
    $attend=$class_data->get_attend($data_id,$status,$room_search);
    $std_desirable=$class_data->get_std_desirable($data_id,$room_search);
    $dev_summary=$class_data->get_dev_summary($data_id); 
    $num_all_std_dev=$dev_summary['num_all_std'];

    $data_atte_pass=$dev_summary['data_atte_pass'];
    $data_atte_nopass=$dev_summary['data_atte_nopass'];

    $summary_atte_pass_per=round(($data_atte_pass*100)/$num_all_std_dev,2);
    $summary_atte_nopass_per=round(($data_atte_nopass*100)/$num_all_std_dev,2);
  }

  $num_all_std=$get_grade_summary['num_all_std'];

  $data_i=$get_grade_summary['data_i'];
  $data_atte=$get_grade_summary['data_atte'];

  $data_00=$get_grade_summary['data_00'];
  $data_10=$get_grade_summary['data_10'];
  $data_15=$get_grade_summary['data_15'];
  $data_20=$get_grade_summary['data_20'];
  $data_25=$get_grade_summary['data_25'];
  $data_30=$get_grade_summary['data_30'];
  $data_35=$get_grade_summary['data_35'];
  $data_40=$get_grade_summary['data_40'];

  $data_i=$get_grade_summary['data_i'];
  $data_atte=$get_grade_summary['data_atte'];

  $get_per_00=round(($data_00*100)/$num_all_std,2);
  $get_per_10=round(($data_10*100)/$num_all_std,2);
  $get_per_15=round(($data_15*100)/$num_all_std,2);
  $get_per_20=round(($data_20*100)/$num_all_std,2);
  $get_per_25=round(($data_25*100)/$num_all_std,2);
  $get_per_30=round(($data_30*100)/$num_all_std,2);
  $get_per_35=round(($data_35*100)/$num_all_std,2);
  $get_per_40=round(($data_40*100)/$num_all_std,2);

  $get_per_i=round(($data_i*100)/$num_all_std,2);
  $get_per_atte=round(($data_atte*100)/$num_all_std,2);

  $data_desirable_nopass=$get_grade_summary['data_desirable_nopass'];
  $data_desirable_pass=$get_grade_summary['data_desirable_pass'];
  $data_desirable_good=$get_grade_summary['data_desirable_good'];
  $data_desirable_verygood=$get_grade_summary['data_desirable_verygood'];

  $get_per_desirable_nopass=round(($data_desirable_nopass*100)/$num_all_std,2);
  $get_per_desirable_pass=round(($data_desirable_pass*100)/$num_all_std,2);
  $get_per_desirable_good=round(($data_desirable_good*100)/$num_all_std,2);
  $get_per_desirable_verygood=round(($data_desirable_verygood*100)/$num_all_std,2);

  $data_read_think_write_nopass=$get_grade_summary['data_read_think_write_nopass'];
  $data_read_think_write_pass=$get_grade_summary['data_read_think_write_pass'];
  $data_read_think_write_good=$get_grade_summary['data_read_think_write_good'];
  $data_read_think_write_verygood=$get_grade_summary['data_read_think_write_verygood'];

  $get_per_read_think_write_nopass=round(($data_read_think_write_nopass*100)/$num_all_std,2);
  $get_per_read_think_write_pass=round(($data_read_think_write_pass*100)/$num_all_std,2);
  $get_per_read_think_write_good=round(($data_read_think_write_good*100)/$num_all_std,2);
  $get_per_read_think_write_verygood=round(($data_read_think_write_verygood*100)/$num_all_std,2);

 
?>
    <page>

    <img style="margin-left: 300px;" class="logo-print-size" src="<?php echo $image_logo ?>">
     <br>
    <div class="col-sm-12 text-center " style="font-size: 24px;margin-top: -5px;">
      <p class="text-bold " style="margin-top: -8px;">แบบบันทึกผลการพัฒนาคุณภาพผู้เรียน (ปพ.5)</p>
      <p class="text-bold " style="margin-top: -8px;">โรงเรียนเทศบาลวัดสระทอง สังกัดเทศบาลเมืองร้อยเอ็ด อำเภอเมือง จังหวัดร้อยเอ็ด</p>
      <p style="margin-top: -8px;">รหัสวิชา <span class="text-bold"><?php echo  $courseID; ?></span> รายวิชา <span class="text-bold"><?php echo  $name; ?></span></p>
      <?php if ($class_level=='p1' || $class_level=='p2' || $class_level=='p3' || $class_level=='p4' || $class_level=='p5' || $class_level=='p6' || $status==2) {  ?>
        <?php
          if ($status==2) {
         ?>
          <p style="margin-top: -8px;">ระดับชั้นประถมศึกษาปีที่ <span class="text-bold"><?php echo $class_level_remove; ?></span> ปีการศึกษา <span class="text-bold">2560</span> </p>
        <?php  }else{ ?>
          <p style="margin-top: -8px;">ระดับชั้นประถมศึกษาปีที่ <span class="text-bold"><?php echo $class_level_remove.'/'.$room_search; ?></span> ปีการศึกษา <span class="text-bold">2560</span> </p>
        <?php } ?>
      <?php }else{ ?>
        <p style="margin-top: -8px;">ระดับชั้นมัธยมศึกษาปีที่ <span class="text-bold"><?php echo $class_level_remove.'/'.$room_search; ?></span> ภาคเรียนที่  <span class="text-bold">1</span> ปีการศึกษา <span class="text-bold">2560</span> </p>
      <?php } ?>
    </div>
     <br>
<?php if($status==1){ ?>
  <table cellspacing="0" style="width: 92%; text-align: center; font-size: 11pt;margin-left: 30px;border: 1px solid black;margin-top: 10px;">
              <thead>
                <tr class="text-middle">
                  <td rowspan="2"  style="  vertical-align: middle;width: 16%;">จำนวนนักเรียนทั้งหมด</td>
                  <td colspan="10" style="width: 60%;padding: 5px;">สรุปผลการพัฒนาคุณภาพผู้เรียน</td>    
                  <td rowspan="3"  style="  vertical-align: middle;width: 14%;">หมายเหตุ</td> 
                </tr>
                <tr>
                  <td colspan="10" style="padding: 5px;border-left: none;">จำนวนนักเรียนที่ได้ระดับผลการเรียน</td>
                </tr>
                <tr>
                  <td style="width: 7%;"><?php echo $num_all_std.'&nbsp;&nbsp;คน'; ?></td>
                  <td style="width: 7%;">4.0</td>
                  <td style="width: 7%;">3.5</td>
                  <td style="width: 7%;">3.0</td>
                  <td style="width: 7%;">2.5</td>
                  <td style="width: 7%;">2.0</td>
                  <td style="width: 7%;">1.5</td>
                  <td style="width: 7%;">1.0</td>
                  <td style="width: 7%;">0</td>
                  <td style="width: 7%;">ร</td>
                  <td style="width: 7%;">มส</td>
                </tr>
              </thead>
              <tbody>
                 <tr>
                  <td>จำนวนที่ได้</td>
                  <td><?php echo $data_40; ?></td>
                  <td><?php echo $data_35; ?></td>
                  <td><?php echo $data_30; ?></td>
                  <td><?php echo $data_25; ?></td>
                  <td><?php echo $data_20; ?></td>
                  <td><?php echo $data_15; ?></td>
                  <td><?php echo $data_10; ?></td>
                  <td><?php echo $data_00; ?></td>
                  <td><?php echo $data_i; ?></td>
                  <td><?php echo $data_atte; ?></td>
                  <td></td>
                </tr>
                 <tr>
                  <td>คิดเป็นร้อยละ</td>
                  <td><?php echo $get_per_40; ?></td>
                  <td><?php echo $get_per_35; ?></td>
                  <td><?php echo $get_per_30; ?></td>
                  <td><?php echo $get_per_25; ?></td>
                  <td><?php echo $get_per_20; ?></td>
                  <td><?php echo $get_per_15; ?></td>
                  <td><?php echo $get_per_10; ?></td>
                  <td><?php echo $get_per_00; ?></td>
                  <td><?php echo $get_per_i; ?></td>
                  <td><?php echo $get_per_atte; ?></td>
                  <td></td>
                </tr>
              </tbody>
    </table> 
    
    <table cellspacing="0" style="width: 92%; text-align: center; font-size: 11pt;margin-left: 30px;">
              <thead>
                <tr class="text-middle">
                  <td rowspan="2"  style="  vertical-align: middle;width: 16%;border-top: none;">ผลการประเมิน</td>
                  <td colspan="4" style="width: 35%;padding: 5px;border-top: none;">ผลการประเมินคุณลักษณะอันพึงประสงค์</td>   
                  <td colspan="4" style="width: 35%;padding: 5px;border-top: none;">ผลการประเมินการอ่าน คิดวิเคราะห์ เขียน</td>    
                  <td style="  vertical-align: middle;width: 14%;border-top: none;"></td> 
                </tr>
                
                <tr>
                  <td style="width: 7%;border-left: none;">ดีเยี่ยม</td>
                  <td style="width: 7%;">ดี</td>
                  <td style="width: 7%;">ผ่าน</td>
                  <td style="width: 7%;">ไม่ผ่าน</td>
                  <td style="width: 7%;">ดีเยี่ยม</td>
                  <td style="width: 7%;">ดี</td>
                  <td style="width: 7%;">ผ่าน</td>
                  <td style="width: 7%;">ไม่ผ่าน</td>
                  <td style="width: 7%;"></td>
                </tr>
              </thead>
              <tbody>
                 <tr>
                  <td>จำนวนที่ได้</td>
                  <td><?php echo $data_desirable_verygood; ?></td>
                  <td><?php echo $data_desirable_good; ?></td>
                  <td><?php echo $data_desirable_pass; ?></td>
                  <td><?php echo $data_desirable_nopass; ?></td>
                  <td><?php echo $data_read_think_write_verygood; ?></td>
                  <td><?php echo $data_read_think_write_good; ?></td>
                  <td><?php echo $data_read_think_write_pass; ?></td>
                  <td><?php echo $data_read_think_write_nopass; ?></td>
                  
                  <td></td>
                </tr>
                 <tr>
                  <td>คิดเป็นร้อยละ</td>
                  <td><?php echo $get_per_desirable_verygood; ?></td>
                  <td><?php echo $get_per_desirable_good; ?></td>
                  <td><?php echo $get_per_desirable_pass; ?></td>
                  <td><?php echo $get_per_desirable_nopass; ?></td>
                  <td><?php echo $get_per_read_think_write_verygood; ?></td>
                  <td><?php echo $get_per_read_think_write_good; ?></td>
                  <td><?php echo $get_per_read_think_write_pass; ?></td>
                  <td><?php echo $get_per_read_think_write_nopass; ?></td>
                  
                  <td></td>
                </tr>
              </tbody>
    </table> 
    <?php }else{ ?>

       <table cellspacing="0" style="width: 92%; text-align: center; font-size: 11pt;margin-left: 30px;border: 1px solid black;margin-top: 10px;">
        <thead>
          <tr>
            <td rowspan="2" style="width: 16%;">จำนวนนักเรียนทั้งหมด</td>
            <td colspan="2" style="width: 70%;">สรุปผลการพัฒนาคุณภาพผู้เรียน</td>
            <td rowspan="3" style="width: 14%;">หมายเหตุ</td>
          </tr>
          <tr>
            <td colspan="2" style="border-left: none;">จำนวนนักเรียนที่ได้ระดับผลการเรียน</td>
          </tr>
          <tr>
            <td><?php echo $num_all_std_dev.'&nbsp;&nbsp;คน'; ?></td>
            <td style="width: 13.8px;">ผ่าน</td>
            <td>ไม่ผ่าน</td>
          </tr>
        </thead>
        <tbody>
          <tr>
            <td>จำนวนที่ได้</td> 
            <td><?php echo $data_atte_pass; ?></td>
            <td><?php echo $data_atte_nopass; ?></td>
            <td></td>
          </tr>
          <tr>
            <td>คิดเป็นร้อยละ</td>
            <td><?php echo $summary_atte_pass_per; ?></td>
            <td><?php echo $summary_atte_nopass_per; ?></td>
            <td></td>
          </tr>
        </tbody>
       </table>
       <table cellspacing="0" style="width: 92%; text-align: center; font-size: 11pt;margin-left: 30px;">
              <thead>
                <tr class="text-middle">
                  <td rowspan="2"  style="  vertical-align: middle;width: 16%;border-top: none;">ผลการประเมิน</td>
                  <td colspan="4" style="width: 35%;padding: 5px;border-top: none;">ผลการประเมินคุณลักษณะอันพึงประสงค์</td>   
                  <td colspan="4" style="width: 35%;padding: 5px;border-top: none;">ผลการประเมินการอ่าน คิดวิเคราะห์ เขียน</td>    
                  <td style="  vertical-align: middle;width: 14%;border-top: none;"></td> 
                </tr>
                
                <tr>
                  <td style="width: 7%;border-left: none;">ดีเยี่ยม</td>
                  <td style="width: 7%;">ดี</td>
                  <td style="width: 7%;">ผ่าน</td>
                  <td style="width: 7%;">ไม่ผ่าน</td>
                  <td style="width: 7%;">ดีเยี่ยม</td>
                  <td style="width: 7%;">ดี</td>
                  <td style="width: 7%;">ผ่าน</td>
                  <td style="width: 7%;">ไม่ผ่าน</td>
                  <td style="width: 7%;"></td>
                </tr>
              </thead>
              <tbody>
                 <tr>
                  <td>จำนวนที่ได้</td>
                  <td><?php echo $data_desirable_verygood; ?></td>
                  <td><?php echo $data_desirable_good; ?></td>
                  <td><?php echo $data_desirable_pass; ?></td>
                  <td><?php echo $data_desirable_nopass; ?></td>
                  <td><?php echo $data_read_think_write_verygood; ?></td>
                  <td><?php echo $data_read_think_write_good; ?></td>
                  <td><?php echo $data_read_think_write_pass; ?></td>
                  <td><?php echo $data_read_think_write_nopass; ?></td>
                  
                  <td></td>
                </tr>
                 <tr>
                  <td>คิดเป็นร้อยละ</td>
                  <td><?php echo $get_per_desirable_verygood; ?></td>
                  <td><?php echo $get_per_desirable_good; ?></td>
                  <td><?php echo $get_per_desirable_pass; ?></td>
                  <td><?php echo $get_per_desirable_nopass; ?></td>
                  <td><?php echo $get_per_read_think_write_verygood; ?></td>
                  <td><?php echo $get_per_read_think_write_good; ?></td>
                  <td><?php echo $get_per_read_think_write_pass; ?></td>
                  <td><?php echo $get_per_read_think_write_nopass; ?></td>
                  
                  <td></td>
                </tr>
              </tbody>
    </table> 
    <?php } ?>
    <div style="margin-left: 100px;margin-top: 60px;">
      <p>.................................................................ครูผู้สอน </p>
     
      <p style="margin-left: 2px;">(</p> <p style="margin-top: -24px;margin-left:140px;"> )</p>

      <p style="margin-left: 12px;">................/................/...................</p>
    </div>
     <div style="margin-left: 410px;margin-top: -64px;">
      <p>.................................................................หัวหน้างานวัดผล </p>
     
      <p style="margin-left: 2px;">(</p> <p style="margin-top: -24px;margin-left:140px;"> )</p>

      <p style="margin-left: 12px;">................/................/...................</p>
    </div>
    <div style="margin-left: 100px;margin-top: 60px;">
      <p>.................................................................หัวหน้ากลุ่มสาระ</p>
     
      <p style="margin-left: 2px;">(</p> <p style="margin-top: -24px;margin-left:140px;"> )</p>

      <p style="margin-left: 12px;">................/................/...................</p>
    </div>
    <div style="margin-left: 410px;margin-top: -64px;">
      <p>.................................................................ครูประจำชั้น </p>
     
      <p style="margin-left: 2px;">(</p> <p style="margin-top: -24px;margin-left:140px;"> )</p>

      <p style="margin-left: 12px;">................/................/...................</p>
    </div>
    <div style="margin-left: 440px;margin-top: 40px;">
      <p>( ) อนุมัติ</p>
      <p style="margin-top: -25px;margin-left: 60px;">( ) ไม่อนุมัติ</p>
    </div>
    <div style="margin-left: 100px;margin-top: 40px;">
      <p>.................................................................รองผู้อำนวยการ</p>
     
      <p style="margin-left: 2px;">(</p> <p style="margin-top: -24px;margin-left:140px;"> )</p>

      <p style="margin-left: 12px;">................/................/...................</p>
    </div>
     <div style="margin-left: 410px;margin-top: -64px;">
      <p>..................................................................ผู้อำนวยการ</p>
     
      <p style="margin-left: 2px;">(</p> <p style="margin-top: -24px;margin-left:140px;"> )</p>

      <p style="margin-left: 12px;">................/................/...................</p>
    </div>
</page>
<?php if($page=='all_page'){ ?>
<page orientation="<?php if($attend['set_page']=='land'){echo "landscape";}else{echo "portrait";}?>">

  <p style="font-size:22px ;margin-left: 30px;margin-top: 10px;">บันทึกเวลาเข้าเรียน</p>
<table cellspacing="0" style="width: 92%; text-align: center; font-size: 11pt;margin-left: 30px;">
              <thead>
                <?php if($attend['set_page']=='port'){ ?>
                <tr class="text-middle">
                  <td rowspan="3" style="width: 10%;vertical-align: middle;">เลขที่</td>
                  <td rowspan="3" style="width: 22%;vertical-align: middle;">ชื่อ-สกุล</td>
                  <td colspan="20" style="width: 60%;padding: 5px;"><?php echo $attend['num_day']; ?> ชั่วโมง/สัปดาห์</td>      
                  <td rowspan="3" style="width: 5%;">รวม&nbsp;<?php echo $attend['total_hr'];?>&nbsp;ชั่วโมง</td>
                  <td rowspan="3" style="width: 5%;">ร้อยละ</td>
                </tr>
                <tr>
                  <td colspan="20" style="width: 60%;padding: 5px;border-left:none;">สัปดาห์ที่</td>      
                </tr> 
                 <tr>
                  <td style="border-left: none;width: 3%;">1</td>
                  <td style="width: 3%;">2</td>
                  <td style="width: 3%;">3</td>
                  <td style="width: 3%;">4</td>
                  <td style="width: 3%;">5</td>
                  <td style="width: 3%;">6</td>
                  <td style="width: 3%;">7</td>
                  <td style="width: 3%;">8</td>
                  <td style="width: 3%;">9</td>
                  <td style="width: 3%;">10</td>
                  <td style="width: 3%;">11</td>
                  <td style="width: 3%;">12</td>
                  <td style="width: 3%;">13</td>
                  <td style="width: 3%;">14</td>
                  <td style="width: 3%;">15</td>
                  <td style="width: 3%;">16</td>
                  <td style="width: 3%;">17</td>
                  <td style="width: 3%;">18</td>
                  <td style="width: 3%;">19</td>
                  <td style="width: 3%;">20</td>               
                </tr> 
               
                <?php }else{ ?>   

                  <tr class="text-middle">
                  <td rowspan="3" style="width: 4%;vertical-align: middle;">เลขที่</td>
                  <td rowspan="3" style="width: 14%;vertical-align: middle;">ชื่อ-สกุล</td>
                  <td colspan="40" style="width: 76%;padding: 5px;"><?php echo $attend['num_day']; ?> ชั่วโมง/สัปดาห์</td>      
                  <td rowspan="3" style="width: 3%;"><div style="rotate:90;">รวม&nbsp;<?php echo $attend['total_hr'];?>&nbsp;ชั่วโมง</div></td>
                  <td rowspan="3" style="width: 3%;"><div style="rotate:90;">ร้อยละ</div></td>
                </tr>
                <tr>
                  <td colspan="40" style="width: 60%;padding: 5px;border-left:none;">สัปดาห์ที่</td>      
                </tr> 
                 <tr>
                  <td style="border-left: none;width: 3%;">1</td>
                  <td style="width: 2%;">2</td>
                  <td style="width: 2%;">3</td>
                  <td style="width: 2%;">4</td>
                  <td style="width: 2%;">5</td>
                  <td style="width: 2%;">6</td>
                  <td style="width: 2%;">7</td>
                  <td style="width: 2%;">8</td>
                  <td style="width: 2%;">9</td>
                  <td style="width: 2%;">10</td>
                  <td style="width: 2%;">11</td>
                  <td style="width: 2%;">12</td>
                  <td style="width: 2%;">13</td>
                  <td style="width: 2%;">14</td>
                  <td style="width: 2%;">15</td>
                  <td style="width: 2%;">16</td>
                  <td style="width: 2%;">17</td>
                  <td style="width: 2%;">18</td>
                  <td style="width: 2%;">19</td>
                  <td style="width: 2%;">20</td>  
                  <td style="width: 2%;">21</td>  
                  <td style="width: 2%;">22</td>  
                  <td style="width: 2%;">23</td>  
                  <td style="width: 2%;">24</td>  
                  <td style="width: 2%;">25</td>  
                  <td style="width: 2%;">26</td>  
                  <td style="width: 2%;">27</td>  
                  <td style="width: 2%;">28</td>  
                  <td style="width: 2%;">29</td>  
                  <td style="width: 2%;">30</td>  
                  <td style="width: 2%;">31</td>  
                  <td style="width: 2%;">32</td>  
                  <td style="width: 2%;">33</td>  
                  <td style="width: 2%;">34</td>  
                  <td style="width: 2%;">35</td>  
                  <td style="width: 2%;">36</td>  
                  <td style="width: 2%;">37</td>  
                  <td style="width: 2%;">38</td>  
                  <td style="width: 2%;">39</td>  
                  <td style="width: 2%;">40</td>               
                </tr> 
               
                <?php } ?>  
                <!--<tr>
                  <?php echo $attend['num_day']; ?>
                  
                </tr>-->

              </thead>
              <tbody >
                <?php echo $attend['detail_std']; ?>
              </tbody>
            </table>
         <!-- <table style="width: 80%;margin-left: 50px;margin-top: 20px;" > 
            <tr>
              <td style="border: none;">หมายเหตุ :</td>
              <td style="border: none;">1</td>
              <td style="border: none;">หมายถึง</td>
              <td style="border: none;">มา</td>
              <td style="border: none;">มีค่าเท่ากับ</td>
              <td style="border: none;">1</td>
              <td style="width: 16%;border: none;">คะแนน</td>
              <td style="border: none;">แปรผล</td>
              <td style="border: none;">ร</td>
              <td style="border: none;">หมายถึง</td>
              <td style="border: none;">รอแก้ผลการเรียน</td>
            </tr>
            <tr>
              <td style="border: none;" rowspan="6"></td>
            </tr>
            <tr>
              <td style="border: none;">ล</td>
              <td style="border: none;">หมายถึง</td>             
              <td style="border: none;">ลากิจ</td>
              <td style="border: none;">มีค่าเท่ากับ</td>
              <td style="border: none;">0</td>
              <td style="border: none;">คะแนน</td>
              <td style="border: none;"></td>
              <td style="border: none;">มส</td>
              <td style="border: none;">หมายถึง</td>             
              <td style="border: none;">ไม่มีสิทธิ์สอบ</td>
              
            </tr>
           
            <tr>
              <td style="border: none;">ป</td>
              <td style="border: none;">หมายถึง</td>             
              <td style="border: none;">ลาป่วย</td>
              <td style="border: none;">มีค่าเท่ากับ</td>
              <td style="border: none;">0</td>
              <td style="border: none;">คะแนน</td>
            </tr>
            <tr>
              <td style="border: none;">ข</td>
              <td style="border: none;">หมายถึง</td>             
              <td style="border: none;">ขาด</td>
              <td style="border: none;">มีค่าเท่ากับ</td>
              <td style="border: none;">0</td>
              <td style="border: none;">คะแนน</td>
            </tr>
            <tr>
              <td style="border: none;">น</td>
              <td style="border: none;">หมายถึง</td>             
              <td style="border: none;">หนีเรียน</td>
              <td style="border: none;">มีค่าเท่ากับ</td>
              <td style="border: none;">0</td>
              <td style="border: none;">คะแนน</td>
            </tr>
          </table>-->
        
 </page>

  <page orientation="portrait">
     <?php if($status==1){ ?>
    <p style="font-size:22px ;margin-left: 30px;margin-top: 10px;">การประเมินผลการเรียน</p>
    <table cellspacing="0" style="width: 92%; text-align: center; font-size: 11pt;margin-left: 30px;">
              <thead>
                <tr class="text-middle">
                  <td rowspan="3" style="vertical-align: middle;width: 5%;">เลขที่</td>
                  <td rowspan="3" style="vertical-align: middle;width: 20%;">ชื่อ-สกุล</td>
                  <td colspan="<?php echo $objective_list['chk_loop']-1; ?>" style="width: 50%">ตัวชี้วัดข้อที่</td>      
                  <td rowspan="2" style="width: 7%;">สอบ<br>กลางภาค</td>
                  <td rowspan="2" style="width: 7%;">สอบ<br>ปลายภาค</td>
                  <td rowspan="2" style="width: 7%;">คะแนน<br>รวม</td>
                  <td rowspan="2" style="width: 5%;">GPA</td>
                </tr>

                <tr>
                  <?php echo $objective_list['ob_title_table_col']; ?>
                </tr>
                  <tr>
                  <?php echo $objective_list['score_title_table_col']; ?>
                  <td><?php echo $objective_list['mid_exam']; ?></td>
                  <td><?php echo $objective_list['final_exam']; ?></td>
                  <td><?php echo $objective_list['sum_score_main']+$objective_list['mid_exam']+$objective_list['final_exam']; ?></td>

                  <td>4.0</td>
                </tr>                                                
              </thead>
              <tbody >
                <?php echo $objective_list['detail_std']; ?>
              
              </tbody>
            </table>
     
              <p style="margin-left: 30px;margin-top: 20px;">ตัวชี้วัด</p>
   
            <table style="width: 80%;margin-left: 50px;margin-top: -10px;" >  
              <?php echo $objective_list['objective_conclude_detail']; ?>

          </table>
             <?php }else{ ?>
              <p style="font-size:22px ;margin-left: 30px;margin-top: 10px;">สรุปผลการเรียน</p>
              <table cellspacing="0" style="width: 92%; text-align: center; font-size: 11pt;margin-left: 30px;border: 1px solid black;margin-top: 10px;">
                <thead>
                  <tr>
                    <td rowspan="2" style="width: 20%;">เลขที่</td>
                    <td rowspan="2" style="width: 50%;">ชื่อ-สกุล</td>
                    <td colspan="2" style="width: 30%;">สรุปผลการเรียน</td>
                  </tr>
                  <tr>
                    <td style="border-left: none;">ผ่าน</td>
                    <td>ไม่ผ่าน</td>
                  </tr>
                </thead>
                <tbody>
                  <?php echo $dev_summary['std_list']; ?>
                  
                </tbody>
              </table>

             <?php } ?>

  </page>

 <page orientation="portrait"> 
   <?php if($status==1){ ?>
  <table cellspacing="0" style="width: 92%; text-align: center; font-size: 11pt;margin-left: 30px;border: 1px solid black;margin-top: 10px;">
              <thead>
                <tr class="text-middle">
                  <td rowspan="2"  style="  vertical-align: middle;width: 16%;">จำนวนนักเรียนทั้งหมด</td>
                  <td colspan="10" style="width: 60%;padding: 5px;">สรุปผลการพัฒนาคุณภาพผู้เรียน</td>    
                  <td rowspan="3"  style="  vertical-align: middle;width: 14%;">หมายเหตุ</td> 
                </tr>
                <tr>
                  <td colspan="10" style="padding: 5px;border-left: none;">จำนวนนักเรียนที่ได้ระดับผลการเรียน</td>
                </tr>
                <tr>
                  <td style="width: 7%;"><?php echo $num_all_std.'&nbsp;&nbsp;คน'; ?></td>
                  <td style="width: 7%;">4.0</td>
                  <td style="width: 7%;">3.5</td>
                  <td style="width: 7%;">3.0</td>
                  <td style="width: 7%;">2.5</td>
                  <td style="width: 7%;">2.0</td>
                  <td style="width: 7%;">1.5</td>
                  <td style="width: 7%;">1.0</td>
                  <td style="width: 7%;">0</td>
                  <td style="width: 7%;">ร</td>
                  <td style="width: 7%;">มส</td>
                </tr>
              </thead>
              <tbody>
                 <tr>
                  <td>จำนวนที่ได้</td>
                  <td><?php echo $data_40; ?></td>
                  <td><?php echo $data_35; ?></td>
                  <td><?php echo $data_30; ?></td>
                  <td><?php echo $data_25; ?></td>
                  <td><?php echo $data_20; ?></td>
                  <td><?php echo $data_15; ?></td>
                  <td><?php echo $data_10; ?></td>
                  <td><?php echo $data_00; ?></td>
                  <td><?php echo $data_i; ?></td>
                  <td><?php echo $data_atte; ?></td>
                  <td></td>
                </tr>
                 <tr>
                  <td>คิดเป็นร้อยละ</td>
                  <td><?php echo $get_per_40; ?></td>
                  <td><?php echo $get_per_35; ?></td>
                  <td><?php echo $get_per_30; ?></td>
                  <td><?php echo $get_per_25; ?></td>
                  <td><?php echo $get_per_20; ?></td>
                  <td><?php echo $get_per_15; ?></td>
                  <td><?php echo $get_per_10; ?></td>
                  <td><?php echo $get_per_00; ?></td>
                  <td><?php echo $get_per_i; ?></td>
                  <td><?php echo $get_per_atte; ?></td>
                  <td></td>
                </tr>
              </tbody>
    </table> 
    
    <table cellspacing="0" style="width: 92%; text-align: center; font-size: 11pt;margin-left: 30px;">
              <thead>
                <tr class="text-middle">
                  <td rowspan="2"  style="  vertical-align: middle;width: 16%;border-top: none;">ผลการประเมิน</td>
                  <td colspan="4" style="width: 35%;padding: 5px;border-top: none;">ผลการประเมินคุณลักษณะอันพึงประสงค์</td>   
                  <td colspan="4" style="width: 35%;padding: 5px;border-top: none;">ผลการประเมินการอ่าน คิดวิเคราะห์ เขียน</td>    
                  <td style="  vertical-align: middle;width: 14%;border-top: none;"></td> 
                </tr>
                
                <tr>
                  <td style="width: 7%;border-left: none;">ดีเยี่ยม</td>
                  <td style="width: 7%;">ดี</td>
                  <td style="width: 7%;">ผ่าน</td>
                  <td style="width: 7%;">ไม่ผ่าน</td>
                  <td style="width: 7%;">ดีเยี่ยม</td>
                  <td style="width: 7%;">ดี</td>
                  <td style="width: 7%;">ผ่าน</td>
                  <td style="width: 7%;">ไม่ผ่าน</td>
                  <td style="width: 7%;"></td>
                </tr>
              </thead>
              <tbody>
                 <tr>
                  <td>จำนวนที่ได้</td>
                  <td><?php echo $data_desirable_verygood; ?></td>
                  <td><?php echo $data_desirable_good; ?></td>
                  <td><?php echo $data_desirable_pass; ?></td>
                  <td><?php echo $data_desirable_nopass; ?></td>
                  <td><?php echo $data_read_think_write_verygood; ?></td>
                  <td><?php echo $data_read_think_write_good; ?></td>
                  <td><?php echo $data_read_think_write_pass; ?></td>
                  <td><?php echo $data_read_think_write_nopass; ?></td>
                  
                  <td></td>
                </tr>
                 <tr>
                  <td>คิดเป็นร้อยละ</td>
                  <td><?php echo $get_per_desirable_verygood; ?></td>
                  <td><?php echo $get_per_desirable_good; ?></td>
                  <td><?php echo $get_per_desirable_pass; ?></td>
                  <td><?php echo $get_per_desirable_nopass; ?></td>
                  <td><?php echo $get_per_read_think_write_verygood; ?></td>
                  <td><?php echo $get_per_read_think_write_good; ?></td>
                  <td><?php echo $get_per_read_think_write_pass; ?></td>
                  <td><?php echo $get_per_read_think_write_nopass; ?></td>
                  
                  <td></td>
                </tr>
              </tbody>
    </table> 
    <?php }else{ ?>

      <table cellspacing="0" style="width: 92%; text-align: center; font-size: 11pt;margin-left: 30px;border: 1px solid black;margin-top: 10px;">
        <thead>
          <tr>
            <td rowspan="2" style="width: 16%;">จำนวนนักเรียนทั้งหมด</td>
            <td colspan="2" style="width: 70%;">สรุปผลการพัฒนาคุณภาพผู้เรียน</td>
            <td rowspan="3" style="width: 14%;">หมายเหตุ</td>
          </tr>
          <tr>
            <td colspan="2" style="border-left: none;">จำนวนนักเรียนที่ได้ระดับผลการเรียน</td>
          </tr>
          <tr>
            <td><?php echo $num_all_std_dev.'&nbsp;&nbsp;คน'; ?></td>
            <td style="width: 13.8px;">ผ่าน</td>
            <td>ไม่ผ่าน</td>
          </tr>
        </thead>
        <tbody>
          <tr>
            <td>จำนวนที่ได้</td> 
            <td><?php echo $data_atte_pass; ?></td>
            <td><?php echo $data_atte_nopass; ?></td>
            <td></td>
          </tr>
          <tr>
            <td>คิดเป็นร้อยละ</td>
            <td><?php echo $summary_atte_pass_per; ?></td>
            <td><?php echo $summary_atte_nopass_per; ?></td>
            <td></td>
          </tr>
        </tbody>
       </table>
       <table cellspacing="0" style="width: 92%; text-align: center; font-size: 11pt;margin-left: 30px;">
              <thead>
                <tr class="text-middle">
                  <td rowspan="2"  style="  vertical-align: middle;width: 16%;border-top: none;">ผลการประเมิน</td>
                  <td colspan="4" style="width: 35%;padding: 5px;border-top: none;">ผลการประเมินคุณลักษณะอันพึงประสงค์</td>   
                  <td colspan="4" style="width: 35%;padding: 5px;border-top: none;">ผลการประเมินการอ่าน คิดวิเคราะห์ เขียน</td>    
                  <td style="  vertical-align: middle;width: 14%;border-top: none;"></td> 
                </tr>
                
                <tr>
                  <td style="width: 7%;border-left: none;">ดีเยี่ยม</td>
                  <td style="width: 7%;">ดี</td>
                  <td style="width: 7%;">ผ่าน</td>
                  <td style="width: 7%;">ไม่ผ่าน</td>
                  <td style="width: 7%;">ดีเยี่ยม</td>
                  <td style="width: 7%;">ดี</td>
                  <td style="width: 7%;">ผ่าน</td>
                  <td style="width: 7%;">ไม่ผ่าน</td>
                  <td style="width: 7%;"></td>
                </tr>
              </thead>
              <tbody>
                 <tr>
                  <td>จำนวนที่ได้</td>
                  <td><?php echo $data_desirable_verygood; ?></td>
                  <td><?php echo $data_desirable_good; ?></td>
                  <td><?php echo $data_desirable_pass; ?></td>
                  <td><?php echo $data_desirable_nopass; ?></td>
                  <td><?php echo $data_read_think_write_verygood; ?></td>
                  <td><?php echo $data_read_think_write_good; ?></td>
                  <td><?php echo $data_read_think_write_pass; ?></td>
                  <td><?php echo $data_read_think_write_nopass; ?></td>                 
                  <td></td>
                </tr>
                 <tr>
                  <td>คิดเป็นร้อยละ</td>
                  <td><?php echo $get_per_desirable_verygood; ?></td>
                  <td><?php echo $get_per_desirable_good; ?></td>
                  <td><?php echo $get_per_desirable_pass; ?></td>
                  <td><?php echo $get_per_desirable_nopass; ?></td>
                  <td><?php echo $get_per_read_think_write_verygood; ?></td>
                  <td><?php echo $get_per_read_think_write_good; ?></td>
                  <td><?php echo $get_per_read_think_write_pass; ?></td>
                  <td><?php echo $get_per_read_think_write_nopass; ?></td>
                  
                  <td></td>
                </tr>
              </tbody>
    </table> 
    <?php } ?>
     <div style="margin-left: 30px;margin-top: 20px;">
              <p>เกณฑ์ระดับคุณภาพ</p>
              <p style="margin-left: 12px;margin-top: 10px;">ระดับผลการเรียน</p>
              <p style="margin-left: 12px;margin-top: -5px;">ระดับ 4</p>
              <p style="margin-left: 12px;margin-top: -5px;">ระดับ 3.5</p>
              <p style="margin-left: 12px;margin-top: -5px;">ระดับ 3</p>
              <p style="margin-left: 12px;margin-top: -5px;">ระดับ 2.5</p>
              <p style="margin-left: 12px;margin-top: -5px;">ระดับ 2</p>
              <p style="margin-left: 12px;margin-top: -5px;">ระดับ 1.5</p>
              <p style="margin-left: 12px;margin-top: -5px;">ระดับ 1</p>
              <p style="margin-left: 12px;margin-top: -5px;">ระดับ 0</p>
        
            </div>
    <div style="margin-left: 160px;margin-top: -180px;">
      
              <p style="margin-left: 12px;margin-top: 10px;">ความหมาย</p>
              <p style="margin-left: 12px;margin-top: -5px;">ดีเยี่ยม</p>
              <p style="margin-left: 12px;margin-top: -5px;">ดีมาก</p>
              <p style="margin-left: 12px;margin-top: -5px;">ดี</p>
              <p style="margin-left: 12px;margin-top: -5px;">ค่อนข้างดี</p>
              <p style="margin-left: 12px;margin-top: -5px;">ปานกลาง</p>
              <p style="margin-left: 12px;margin-top: -5px;">พอใช้</p>
              <p style="margin-left: 12px;margin-top: -5px;">ผ่านเกณฑ์ขั้นต่ำ</p>
              <p style="margin-left: 12px;margin-top: -5px;">ต่ำกว่าเกณฑ์</p>
        
            </div>
     <div style="margin-left:290px;margin-top: -180px;">             
              <p style="margin-left: 12px;margin-top: 10px;">ช่วงคะแนน</p>
              <p style="margin-left: 12px;margin-top: -5px;">80-100</p>
              <p style="margin-left: 12px;margin-top: -5px;">75-79</p>
              <p style="margin-left: 12px;margin-top: -5px;">70-74</p>
              <p style="margin-left: 12px;margin-top: -5px;">65-69</p>
              <p style="margin-left: 12px;margin-top: -5px;">60-64</p>
              <p style="margin-left: 12px;margin-top: -5px;">55-59</p>
              <p style="margin-left: 12px;margin-top: -5px;">50-54</p>
              <p style="margin-left: 12px;margin-top: -5px;">0-49</p>
              
        
            </div>
  </page>
<page orientation="portrait">
    <p style="font-size:22px ;margin-left: 30px;margin-top: 10px;">การประเมินคุณลักษณะอันพึงประสงค์และการอ่าน เขียน คิดวิเคราะห์</p>
    <table cellspacing="0" style="width: 92%; text-align: center; font-size: 11pt;margin-left: 30px;">
              <thead>
                <tr class="text-middle">
                  <td rowspan="2"  style="  vertical-align: middle;width: 6%;">เลขที่</td>
                  <td rowspan="2"  style="  vertical-align: middle;width: 20%;">ชื่อ-สกุล</td>
                  <td colspan="10" style="width: 18%;padding: 5px;">คุณลักษณะอันพึงประสงค์</td>                       
                  <td colspan="7" style="vertical-align: middle;width: 22%;">การอ่าน เขียน คิดวิเคราะห์</td> 
                </tr>
                
                <tr>
             
                  <td style="width: 4%;border-left: none;height: 60px;"><div style="rotate: 90;margin-top: 10px;">ข้อที่&nbsp;&nbsp;1</div></td>

                  <td style="width: 4%;"><div style="rotate: 90;margin-top: 10px;">ข้อที่&nbsp;&nbsp;2</div></td>
                  <td style="width: 4%;"><div style="rotate: 90;margin-top: 10px;">ข้อที่&nbsp;&nbsp;3</div></td>
                  <td style="width: 4%;"><div style="rotate: 90;margin-top: 10px;">ข้อที่&nbsp;&nbsp;4</div></td>
                  <td style="width: 4%;"><div style="rotate: 90;margin-top: 10px;">ข้อที่&nbsp;&nbsp;5</div></td>
                  <td style="width: 4%;"><div style="rotate: 90;margin-top: 10px;">ข้อที่&nbsp;&nbsp;6</div></td>
                  <td style="width: 4%;"><div style="rotate: 90;margin-top: 10px;">ข้อที่&nbsp;&nbsp;7</div></td>
                  <td style="width: 4%;"><div style="rotate: 90;margin-top: 10px;">ข้อที่&nbsp;&nbsp;8</div></td>
                  <td style="width: 4%;"><div style="rotate: 90;margin-top: 10px;">คะแนนรวม</div></td>
                  <td style="width: 4%;"><div style="rotate: 90;margin-top: 10px;">คะแนนเฉลี่ย</div></td>
                  <td style="width: 5%;"><div style="rotate: 90;margin-top: 10px;">ตัวชี้วัดที่&nbsp;&nbsp;1</div></td>
                  <td style="width: 5%;"><div style="rotate: 90;margin-top: 10px;">ตัวชี้วัดที่&nbsp;&nbsp;2</div></td>
                  <td style="width: 5%;"><div style="rotate: 90;margin-top: 10px;">ตัวชี้วัดที่&nbsp;&nbsp;3</div></td>
                  <td style="width: 5%;"><div style="rotate: 90;margin-top: 10px;">ตัวชี้วัดที่&nbsp;&nbsp;4</div></td>
                  <td style="width: 5%;"><div style="rotate: 90;margin-top: 10px;">ตัวชี้วัดที่&nbsp;&nbsp;5</div></td>
                  <td style="width: 5%;"><div style="rotate: 90;margin-top: 10px;">คะแนนรวม</div></td>
                  <td style="width: 5%;"><div style="rotate: 90;margin-top: 10px;">คะแนนเฉลี่ย</div></td>
                </tr>

              </thead>
              <tbody>
                <?php echo $std_desirable; ?>
              </tbody>
    </table>
   
        <table style="width: 80%;margin-left: 50px;margin-top: 20px;" >    
            <tr>
              <td style="width: 40%;border: none;">
                <p style="margin-left: -20px;">ตัวชี้วัดคุณลักษณะอันพึงประสงค์</p>
                <p style="line-height: 0.9">1.รักชาติ ศาสน์ กษัตริย์</p>
                <p style="line-height: 0.9">2.ซื่อสัตย์สุจริต</p>
                <p style="line-height: 0.9">3.มีวินัย</p>
                <p style="line-height: 0.9">4.ใฝ่เรียนรู้</p>
                <p style="line-height: 0.9">5.อยู่อย่างพอเพียง</p>
                <p style="line-height: 0.9">6.มุ่งมั่นในการทำงาน</p>
                <p style="line-height: 0.9">7.รักความเป็นไทย</p>
                <p style="line-height: 0.9">8.มีจิตสาธารณะ</p>
              </td>
              <td style="width: 40%;border: none;">
               
                <p style="margin-left: -20px;margin-top: -89px;">เกณฑ์ระดับคุณภาพ</p>
                <p style="line-height: 0.9">3  ดีเยี่ยม  คะแนน 2.5-3.0</p>
                <p style="line-height: 0.9">2  ดี  คะแนน 1.5-2.4</p>
                <p style="line-height: 0.9">1  ผ่าน  คะแนน 0.5-1.4</p>
                <p style="line-height: 0.9">0  ไม่ผ่าน คะแนน 0-0.4</p>      
                      
              </td>
            </tr>

    </table>
  </page>
<?php  } ?><file_sep>/modules/regis_teacher/upload_one.php
<?php
@ob_start();
@session_start();

require_once('../../init.php');
include('../../src/class.pagination.php');
include('../../src/class.inputfilter.php');
$InputFilter = new InputFilter();

##CLASS_DB_CONNECT##
include('class_modules.php');
$class_data = new ClassData();
##CLASS_DB_CONNECT##

$file_path="../../file_managers/exel/";
		//$user_id=$_SESSION['ss_user_id'];
		/*$ext=pathinfo(basename($_FILES['file']['name']),PATHINFO_EXTENSION);
		$new_file='file_'.uniqid().".".$ext;
		$up_path=$file_path.$new_file;
		$oldFileName=$_FILES['file']['name'];
		$upload=move_uploaded_file($_FILES['file']['tmp_name'], $up_path);*/

		$file = $_FILES['file']['tmp_name'];
		$handle = fopen($file, "r");
		fgetcsv($handle);
		$c = 0;
		while(($filesop = fgetcsv($handle, 1000, ",")) !== false){
			$positionID = trim($filesop[0]);
			$fname_th = trim($filesop[1]);
			$lname_th = trim($filesop[2]);
			$fname_en = trim($filesop[3]);
			$lname_en = trim($filesop[4]);
			$lname_en_pass = substr($lname_en, 0, 1);
			$username=$fname_en.'.'.$lname_en_pass;

			$birthday_set = trim($filesop[5]);
			list($day,$month,$year_set) = split('[/]', $birthday_set);
			$password_set=$day.$month.$year_set;
			$password=MD5($password_set);

			$year=$year_set-543;
			$birth_val=$year.'-'.$month.'-'.$day;
			$class_data->sql = "INSERT INTO tbl_regis_teacher(positionID,username,password,fname_th,lname_th,fname_en,lname_en,birthday,status) VALUES ('$positionID','$username','$password','$fname_th','$lname_th','$fname_en','$lname_en','$birth_val',1)";
			$class_data->query();
			$data_res.='
				 <tr>

	                  <td style="text-align:center;">'.$positionID.'</td>
	                  <td style="text-align:center;">'.$username.'</td>
	                  <td style="text-align:center;">'.$password_set.'</td>
	                  <td style="text-align:center;">'.$fname_th.'</td>
	                  <td style="text-align:center;">'.$lname_th.'</td>
	                  <td style="text-align:center;">'.$birthday_set.'</td>
               	</tr>    
			';
			$c = $c + 1;
		}
	    echo $data_res;  



?><file_sep>/modules/authen_user/class_modules.php
<?php 

class ClassData extends Databases {
	var $role;
	var $role_id;

	public function __construct()
	{
		$this->role = new ClassRole();
		$this->role_id = (int)$_SESSION['ss_user_id'];
		// You don't have permission to access
	}
/*************************************** PROCESS DB ****************************************/
	
	public function get_data_list($arr_search_val,$pages_current,$sort_column,$sort_by){
		$edit_user_ath = $this->role->ath_user_reletion_tasks('edit_user_ath',$this->role_id); // สามารถแก้ไขหมวดหมู่สินค้าได้

		## SQL CONDITION ##
		$sql_condition = " atu.user_id > 0 ";
		$data_name = $arr_search_val['data_name'];
		$data_status = $arr_search_val['data_status'];
		if (isset($data_name)) {
			$sql_condition .= " AND ( atu.first_name LIKE '%{$data_name}%' OR atu.first_name LIKE '%{$data_name}%' OR atu.last_name LIKE '%{$data_name}%' )  ";
		}
		if (isset($data_status)) {
			$sql_condition .= " AND ( atu.status LIKE '%{$data_status}%' )  ";
		}
		## SQL CONDITION ##	

		## PAGINATION ##
		$this->sql = " SELECT count(user_id) as data_id_total FROM ath_users as atu WHERE {$sql_condition} ";
		$this->select();
		$this->setRows();
		$dataidtotal = (int)$this->rows[0]['data_id_total'];
		$pagination = new pagination();
		$pages = (int)$pages_current;
		$rowsperpage = 20; 
		$arrpage = $pagination->calculate_pages($dataidtotal, $rowsperpage, $pages);
		$sequence = ($arrpage['current'] == 1) ? 1 : ($arrpage['current'] * $rowsperpage)-1 ; 
		## PAGINATION ##

		## DATA TBLE ##
		$data_response = array();
		$data_response['data_list'] = "";
		if($dataidtotal > 0){

		$arr_status = array('Save Draft','Published');
		$sql_order_by = " {$sort_column} {$sort_by} ";

		$sql = "SELECT atu.* , rol.role_name 
				FROM ath_users  as atu   
				LEFT JOIN ath_roles as rol ON atu.role_id = rol.role_id 
				WHERE {$sql_condition} 
				ORDER BY {$sql_order_by} {$arrpage['limit']} ";
		$this->sql = $sql;
		$this->select();
		$this->setRows();
		foreach($this->rows as $key => $value) {

			$user_id = $this->rows[$key]['user_id'];
			$prefix_name = $this->rows[$key]['prefix_name'];
			$first_name = $this->rows[$key]['first_name'];
			$last_name = $this->rows[$key]['last_name'];
			$role_name = $this->rows[$key]['role_name'];

			$status = $this->rows[$key]['status'];

			$edit_hyperlink = ($edit_user_ath) ? "index.php?op=authen_user-from&id={$user_id}" : 'index.php?op=messages-error403';

			$data_response['data_list'] .= "<tr>
							                  <td class=\"v-align-middle\">
							                    <div class=\"checkbox check-success\">
							                      <input type=\"checkbox\" value=\"{$user_id}\" name=\"checkbox_delete[]\" id=\"checkbox{$user_id}\" class=\"checkbox_data\">
							                      <label for=\"checkbox{$user_id}\">&nbsp;</label>
							                    </div>
							                  </td>
							                  <td class=\"v-align-middle semi-bold\"><a href=\"{$edit_hyperlink}\">{$prefix_name} {$first_name} {$last_name}</a> </td>
							                  <td class=\"v-align-middle semi-bold\"><a href=\"{$edit_hyperlink}\">{$role_name}</a> </td>
							                  <td class=\"v-align-middle\">{$arr_status[$status]}</td>
							                </tr>";

			$data_response['data_list'] .= "<a class=\"btn btn-inverse btn_edit \" data-id=\"{$user_id}\" href=\"javascript:;\"><i class=\"fa fa-edit\"></i></a>" ;
			$data_response['data_list'] .= "<a class=\"btn btn-danger bt_delete\" data-id=\"{$user_id}\" href=\"javascript:;\"><i class=\"fa fa-trash-o\"></i></a>";
			$data_response['data_list'] .= "</td></tr>";

			$sequence++;

		}}

		## DATA TBLE ##
        $data_response['data_pagination'] .= "<li><a href=\"javascript:;\" data-id=\"{$arrpage['previous']}\" class=\"chg_pagination\">&laquo;</a></li>";
		for($p=0; $p<count($arrpage['pages']); $p++){ 
			$activepages = ($arrpage['pages'][$p]==$arrpage['current']) ? "active" : ""; 
			$data_response['data_pagination'] .= "<li class=\"{$activepages}\"><a href=\"javascript:;\" data-id=\"{$arrpage['pages'][$p]}\" class=\"chg_pagination\">{$arrpage['pages'][$p]}</a></li>";
		}
        $data_response['data_pagination'] .= " <li><a href=\"javascript:;\" data-id=\"{$arrpage['next']}\" class=\"chg_pagination\">&raquo;</a></li>";

		return json_encode($data_response);
		// return $data_response;

	}

	public function get_data_from($user_id){
		$data_response = array();
		$this->sql = "SELECT * FROM ath_users WHERE user_id={$user_id} " ;
		$this->select();
		$this->setRows();
		$data_response['role_id'] = $this->rows[0]['role_id'];
		$data_response['username'] = $this->rows[0]['username'];
		$data_response['first_name'] = $this->rows[0]['first_name'];
		$data_response['last_name'] = $this->rows[0]['last_name'];
		$data_response['status'] = $this->rows[0]['status'];
		return json_encode($data_response);
	}

	public function get_data($user_id){
		$this->sql = "SELECT * FROM ath_users WHERE user_id={$user_id} " ;
		$this->select();
		return $this->getRows();
	}

	public function get_data_uniquevalue($field_name,$sql_where){
		$this->sql = "SELECT {$field_name} FROM ath_users WHERE {$sql_where} " ;
		$this->select();
		$this->setRows();
		return trim($this->rows[0][$field_name]);
	}

	public function insert_data($insert){

		$this->sql = "INSERT INTO ath_users(".implode(",",array_keys($insert)).") VALUES (".implode(",",array_values($insert)).")";
		$this->query();
		$new_id = $this->insertID();
		$this->sql = "UPDATE tbl_users_gallery SET usersID = $new_id , status = $new_id  WHERE usersID = 0 AND status = 0  ";
		$this->query();
		return $new_id;
	}

	public function update_data($update,$user_id){
		$this->sql = "UPDATE ath_users SET ".implode(",",$update)." WHERE user_id='".$user_id."'";
		$this->query();
	}

	public function get_data_delete($data_val){

		$arr_id = explode(",", $data_val);
		for ($i=0; $i < count($arr_id) ; $i++) { 
			$targetfile = "../../../file_managers/userprofile/";

		    $this->sql = " SELECT FileName FROM tbl_users_gallery WHERE usersID = {$arr_id[$i]}";
		    $this->select();
		    $this->setRows();
		    foreach($this->rows as $key => $value) {
		    	$FileName =  $this->rows[$key]['FileName'];
		    	
		        if(@file_exists($targetfile."thumbnails/{$FileName}")){
				  @unlink($targetfile."thumbnails/{$FileName}");	
	            }
	            if(@file_exists($targetfile."photo/{$FileName}")){
				  @unlink($targetfile."photo/{$FileName}");	
	            }
        	}

            $this->sql ="DELETE FROM tbl_users_gallery WHERE usersID = {$arr_id[$i]}";
            $this->query();

			$this->sql ="DELETE FROM ath_users WHERE user_id={$arr_id[$i]}";
	        $this->query();
		}

	}

	public function fetchRole() { 
		$this->sql = " SELECT count(role_id) as data_id_total FROM ath_roles WHERE status = 1  ORDER BY role_id DESC ";
		$this->select();
		$this->setRows();
		$num_options = (int)$this->rows[0]['data_id_total'];
		if ($num_options > 0) {
			$this->sql = "SELECT role_id,role_name  FROM ath_roles WHERE status = 1  ORDER BY role_id DESC";
			$this->select();
			$this->setRows();
			foreach($this->rows as $key => $value) {
				$options .="<option value=\"{$value['role_id']}\">{$value['role_name']}</option>\n";
			}
		}
		return $options;
	} 

	public function update_ath_tasks($ath_tasks,$user_id){

		/// DELETE OLD VALUE
		$this->sql = "DELETE FROM ath_user_reletion_tasks WHERE task_id NOT IN ({$ath_tasks}) AND user_id='".$user_id."'";
		$this->query();

		// TASKS MANAGEMENT //////////////
		$arr_ath_tasks = explode(',', $ath_tasks);
		for ($i=0; $i < count($arr_ath_tasks); $i++) { 
			$task_id = $arr_ath_tasks[$i];
			if (self::num_user_reletion_tasks($task_id,$user_id) == 0) {
				$insert = array();
				$insert["task_id"]= "'".trim($task_id)."'";
	   			$insert["user_id"]= "'".trim($user_id)."'";
				$this->sql = "INSERT INTO ath_user_reletion_tasks(".implode(",",array_keys($insert)).") VALUES (".implode(",",array_values($insert)).")";
				$this->query();
			}
		}

	}


	public function get_tasks_list($user_id,$data_id){ 
		$sql = "SELECT * FROM ath_main_function WHERE status = 1 ORDER BY sequence DESC, fun_id ASC ";
		$this->sql = $sql;
		$this->select();
		$this->setRows();
		foreach($this->rows as $key => $value) {
			$fun_id = $value['fun_id'];
			$fun_name = $value['fun_name'];
		
			$tasks_list .= '<div class="panel panel-default">
	            <div class="panel-heading">
	              <h4 class="panel-title">
	                  <a class="collapsed" data-parent="#accordion" data-toggle="collapse" href="#collapse'.$fun_id.'">'.$fun_name.'</a>
	                </h4>
	            </div>
	            <div class="panel-collapse collapse in" id="collapse'.$fun_id.'">
	              <div class="panel-body">';


			$sql = "SELECT * FROM ath_tasks WHERE fun_id = {$fun_id} AND status=1 ORDER BY sequence DESC, fun_id ASC ";
			$this->sql = $sql;
			$this->select();
			$this->setRows();
			foreach($this->rows as $task_key => $task_val) {
				$task_id = $task_val['task_id'];
				$task_description = $task_val['task_description'];
				$num_task_id = (int)self::num_user_reletion_tasks($task_id,$data_id);
				$checked_val = ($num_task_id == 0 ) ? "" : "checked";
	        	$tasks_list .= '<div class="checkbox check-info">
	        						<input type="checkbox" class="checkbox_data ath_fun_'.$fun_id.'" value="'.$task_id.'" id="ath_tasks_'.$task_id.'" name="checkbox_ath_tasks[]" '.$checked_val.' >
	                  				<label for="ath_tasks_'.$task_id.'">'.$task_description.'</label>
	                  			</div>';
	        }


	        $tasks_list .= '</div>
	            </div>
	          </div>';

        }

		$data_response['tasks_list'] = $tasks_list;
		return json_encode($data_response);

	}

	public function num_user_reletion_tasks($task_id,$user_id){
		$this->sql = " SELECT count(rel_id) as data_id_total FROM ath_user_reletion_tasks WHERE task_id={$task_id} AND user_id={$user_id} ";
		$this->select();
		$this->setRows();
		return (int)$this->rows[0]['data_id_total'];
	}

	public function get_role_reletion_tasks($role_id){ //ath_role_reletion_tasks
		$data_response = array();
		$sql = "SELECT task_id FROM ath_role_reletion_tasks WHERE role_id = {$role_id} ";
		$this->sql = $sql;
		$this->select();
		$this->setRows();
		foreach($this->rows as $task_key => $task_val) {
        	$data_response['task_id'][] = $task_val['task_id'];
        }
		return json_encode($data_response);
	}


	public function ex_add_thumb($insert){

		$this->sql = "INSERT INTO tbl_users_gallery(".implode(",",array_keys($insert)).") VALUES (".implode(",",array_values($insert)).")";
		$this->query();
		$photo_id = $this->insertID();

		$this->sql = "UPDATE tbl_users_gallery SET sequence=$photo_id WHERE DataID='".$photo_id."'";
		$this->query();	

		return $photo_id;
	}

	public function get_thumb($data_id){
		
		$sql_condition = "WHERE usersID = {$data_id} AND Type = 0 ";

		$sql_order_by = "sequence ASC ";

		$sql = "SELECT DataID,FileName
				FROM tbl_users_gallery 
				 {$sql_condition} 
				";
		$this->sql = $sql;
		$this->select();
		$this->setRows();
		foreach($this->rows as $key => $value) {
			$DataID = $value['DataID'];
			$FileName = $value['FileName'];//unchkhtmlspecialchars
			$file_name = (@file_exists("../../../file_managers/userprofile/thumbnails/{$FileName}")) ? $FileName : "thumbnail.jpg";
			$data_response .= "
			        <center>
					<div class=\"col-lg-12 col-md-10\">
						<p class=\"small no-margin\"><img src=\"../file_managers/userprofile/thumbnails/{$FileName}?".time()."\" style=\"width:auto;\" class=\"img-rounded m-r-25  m-b-10\"></p>
						<div class=\"btn-group btn-group-xs text-center\">
						  <a href=\"javascript:;\"  data-id=\"{$DataID}\" class=\" btn btn-danger btn_remove_thumb\">Remove</a>
						</div>                    
						<hr/>
					</div>
					</center>";
			$sequence++;
		}

		return $data_response;
	}
	
	public function remove_thumb($data_id){
		$targetfile = "../../../file_managers/userprofile/";

		$this->sql = " SELECT FileName FROM tbl_users_gallery WHERE DataID = {$data_id} LIMIT 0,1 ";
		$this->select();
		$this->setRows();
		$FileName =  $this->rows[0]['FileName'];
	    if(@file_exists($targetfile."thumbnails/{$FileName}")){
			@unlink($targetfile."thumbnails/{$FileName}");	

		}

        $this->sql ="DELETE FROM tbl_users_gallery WHERE DataID={$data_id} ";
        $this->query();
		return "y";

	}
/*************************************** PROCESS DB ****************************************/

}


?><file_sep>/modules/report/person_p_form.php
<link href="../../assets/css/bootstrap.css" rel="stylesheet" type="text/css">
<link href="../../assets/css/custom.css" rel="stylesheet" type="text/css">
<link href="../../assets/css/margin-padding.css" rel="stylesheet" type="text/css">
<link href="../../assets/css/responsive.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
 table {
    border-collapse: collapse;
}

td, th {
    border: 1px solid black;
    padding: 5px;
}
-->
</style>
<?php
 @session_start();
    include('logo.php');
    require_once('../../init.php');
    include('class_modules.php');
    $class_data = new ClassData();
  ?>
<page orientation="portrait">
    <p class="text-bold" style="margin-left: 710px;font-size: 22px;margin-top: 25px;">ปพ.6</p>
    <img style="margin :10px 0px 10px 320px;display:block;width: 120px;height: 120px;"src="<?php echo $image_logo ?>">
   	<br>
   	<div class="col-sm-12 text-center " style="font-size: 22px;margin-top: -5px;">
      <p class="text-bold" style="margin-top: -8px;">รายงานการพัฒนาคุณภาพผู้เรียนเป็นรายบุคคล</p>
      <p class="text-bold " style="margin-top: -8px;">โรงเรียนเทศบาลวัดสระทอง</p>
    </div>
      <table cellspacing="0" style="width: 94%; text-align: center; font-size: 22px;margin-left:10px;border: 1px solid black;margin-top: 20px;">
        <thead>
          <tr>
            <td style="border: none;"><span class="text-bold">ชื่อ - สกุล</span> เด็กชายสมหมาย สุขสบาย</td>
            <td style="border: none;"><span class="text-bold">ประถมศึกษาปีที่</span> 1/1</td>
            <td style="border: none;"><span class="text-bold">เลขที่</span> 1</td>
            <td style="border: none;"><span class="text-bold">เลขประจำตัวนักเรียน</span> 00010</td>
          </tr>
        </thead>
         <tr>
            <td style="padding-left: 35px;border: none;"><span class="text-bold">เลขประจำตัวประชาชน</span> 1234567890123</td>
            <td style="border: none;"><span class="text-bold">ภาคเรียนที่</span> 1</td>
            <td style="border: none;"><span class="text-bold">ปีการศึกษา</span> 2560</td>
          </tr>
      </table>
     <table cellspacing="0" style="width: 94%; text-align: center; font-size: 18px;margin-left:50px;border: 1px solid black;margin-top: 35px;">
              <thead style="font-weight: bold;">
                
                <tr style="background-color: #e0e0e0;">
                  
                  <td rowspan="4" style="width: 4%;height: 65px;">ที่</td>
                  <td colspan="7" style="width: 40%;">การพัฒนาคุณภาพผู้เรียน</td>
                  <td rowspan="4" style="width: 8%;"><div style="rotate:90;margin-left: -12px;">หมายเหตุ</div></td>
               
                </tr>
                <tr style="background-color: #e0e0e0;">
                  <td rowspan="3" style="border-left:none; width: 25%;">รายวิชา</td>
                  <td rowspan="3" style="width:13%;">รหัสวิชา</td>
                  <td rowspan="3" style="width:8%;">น้ำหนัก</td>
                  <td colspan="3">คะแนน</td>
                  <td rowspan="3" style="width: 7%;">GPA</td>
                </tr>
                <tr style="background-color: #e0e0e0;">
                  <td style="border-left:none;width: 10%; ">ภาคเรียนที่1</td>
                  <td style="width: 10%;">ภาคเรียนที่2</td>
                  <td style="width: 10%;">รวม</td>
                </tr>
                <tr style="background-color: #e0e0e0;">
                  <td style="border-left:none; ">50</td>
                  <td>50</td>
                  <td>100</td>
                </tr>
              </thead>
              <tbody>
                <tr>
                  <td>1</td>
                  <td>ภาษาไทย</td>
                  <td>ท11001</td>
                  <td>1</td>
                  <td>30</td>
                  <td>30</td>
                  <td>60</td>
                  <td>3.14</td>
                  <td></td>
                </tr>
                <tr>
                  <td>2</td>
                  <td>คณิตศาสตร์</td>
                  <td>ค11001</td>
                  <td>1</td>
                  <td>30</td>
                  <td>30</td>
                  <td>60</td>
                  <td>3.14</td>
                  <td></td>
                </tr>
                <tr>
                  <td>3</td>
                  <td>วิทยาศาสตร์</td>
                  <td>ว11001</td>
                  <td>1</td>
                  <td>30</td>
                  <td>30</td>
                  <td>60</td>
                  <td>3.14</td>
                  <td></td>
                </tr>
                <tr>
                  <td>4</td>
                  <td>วิทยาศาสตร์เพิ่มเติม</td>
                  <td>ว11002</td>
                  <td>1</td>
                  <td>30</td>
                  <td>30</td>
                  <td>60</td>
                  <td>3.14</td>
                  <td></td>
                </tr>
                <tr>
                  <td>5</td>
                  <td>สังคมศึกษา ศาสนาและวัฒนธรรม</td>
                  <td>ส11001</td>
                  <td>1</td>
                  <td>30</td>
                  <td>30</td>
                  <td>60</td>
                  <td>3.14</td>
                  <td></td>
                </tr>
                <tr>
                  <td>6</td>
                  <td>สุขศึกษา</td>
                  <td>พ11001</td>
                  <td>1</td>
                  <td>30</td>
                  <td>30</td>
                  <td>60</td>
                  <td>3.14</td>
                  <td></td>
                </tr>
                <tr>
                  <td>7</td>
                  <td>ภาษาอังกฤษ</td>
                  <td>อ11001</td>
                  <td>1</td>
                  <td>30</td>
                  <td>30</td>
                  <td>60</td>
                  <td>3.14</td>
                  <td></td>
                </tr>
                <tr>
                  <td>8</td>
                  <td>การงานอาชีพและเทคโนโลยี</td>
                  <td>ง11001</td>
                  <td>1</td>
                  <td>30</td>
                  <td>30</td>
                  <td>60</td>
                  <td>3.14</td>
                  <td></td>
                </tr>
                <tr>
                  <td>9</td>
                  <td>คอมพิวเตอร์</td>
                  <td>ง11010</td>
                  <td>1</td>
                  <td>30</td>
                  <td>30</td>
                  <td>60</td>
                  <td>3.14</td>
                  <td></td>
                </tr>
                <tr>
                  <td colspan="3">รวม</td>
                  <td>10</td>
                  <td></td>
                  <td></td>
                  <td></td>
                  <td></td>
                  <td></td>
                 
                </tr>
                <tr style="background-color: #e0e0e0;font-weight: bold;">
                  <td ></td>
                  <td colspan="2">กิจกรรมพัฒนาผู้เรียน</td>
                  <td colspan="2">รหัสวิชา</td>
                  <td>น้ำหนัก</td>
                  <td colspan="2">ผลการประเมิน</td>
                  <td></td>                 
                </tr>
                 <tr>
                  <td>1</td>
                  <td colspan="2">แนะแนว</td>
                  <td colspan="2">ก11001</td>
                  <td>-</td>
                  <td colspan="2">ผ่าน</td>
                  <td></td>                 
                </tr>
                 <tr>
                  <td>2</td>
                  <td colspan="2">ลูกเสือ เนตรนารี</td>
                  <td colspan="2">ก11002</td>
                  <td>-</td>
                  <td colspan="2">ผ่าน</td>
                  <td></td>                 
                </tr>
                <tr>
                  <td>3</td>
                  <td colspan="2">ชุมนุมคอมพิวเตอร์</td>
                  <td colspan="2">ก11003</td>
                  <td>-</td>
                  <td colspan="2">ผ่าน</td>
                  <td></td>                 
                </tr>
                <tr>
                  <td>4</td>
                  <td colspan="2">กิจกรรมเพื่อสังคม</td>
                  <td colspan="2">ก11004</td>
                  <td>-</td>
                  <td colspan="2">ผ่าน</td>
                  <td></td>                 
                </tr>
                 <tr style="font-weight: bold;">
                  <td colspan="5">รวม</td>
                  <td></td>
                  <td colspan="2">ผ่าน</td>
                  <td></td>                
                </tr>
              </tbody>
    </table> 
  
</page>

<page orientation="portrait">
    <p class="text-bold" style="margin-left: 710px;font-size: 22px;margin-top: 25px;">ปพ.6</p>    
    <br>

     <table cellspacing="0" style="width: 94%; text-align: center; font-size: 18px;margin-left:50px;border: 1px solid black;margin-top: 10px;">
              <thead style="font-weight: bold;">
                
                <tr style="background-color: #e0e0e0;">                  
                  <td colspan="3" style="width: 4%;">ผลการประเมินคุณลักษณะอันพึงประสงค์</td>            
                </tr>
                <tr style="background-color: #e0e0e0;">
                  <td style="width: 6%">ที่</td>
                  <td style="width: 65%;">คุณลักษณะอันพึงประสงค์</td>
                  <td style="width: 24%;">ผลการประเมิน</td>
      
                </tr>              
              </thead>
              <tbody>
                <tr>
                  <td>1</td>
                  <td style="text-align: left;">รักชาติ ศาสน์ กษัตริย์</td>
                  <td>3</td>                 
                </tr>
                <tr>
                  <td>2</td>
                  <td style="text-align: left;">ซื่อสัตย์สุจริต</td>
                  <td>3</td>                 
                </tr>
                <tr>
                  <td>3</td>
                  <td style="text-align: left;">มีวินัย</td>
                  <td>3</td>                 
                </tr>
                <tr>
                  <td>4</td>
                  <td style="text-align: left;">ใฝ่เรียนรู้</td>
                  <td>3</td>                 
                </tr>
                <tr>
                  <td>5</td>
                  <td style="text-align: left;">อยู่อย่างพอเพียง</td>
                  <td>3</td>                 
                </tr>
                <tr>
                  <td>6</td>
                  <td style="text-align: left;">มุ่งมั่นในการทำงาน</td>
                  <td>3</td>                 
                </tr>
                <tr>
                  <td>7</td>
                  <td style="text-align: left;">รักความเป็นไทย</td>
                  <td>3</td>                 
                </tr>
                <tr>
                  <td>8</td>
                  <td style="text-align: left;">มีจิตสาธารณะ</td>
                  <td>3</td>                 
                </tr>
                <tr style="font-weight: bold;">
                  <td colspan="2">สรุปผลการประเมิน</td>
                  <td>3</td>                 
                </tr>
              </tbody>
    </table> 
    <table cellspacing="0" style="width: 94%; text-align: center; font-size: 18px;margin-left:50px;border: 1px solid black;margin-top: 35px;">
             <thead style="font-weight: bold;">
                
                <tr style="background-color: #e0e0e0;">                  
                  <td colspan="3" style="width: 4%;">ผลการประเมินการอ่าน&nbsp;เขียน&nbsp;คิดวิเคราะห์</td>            
                </tr>
                <tr style="background-color: #e0e0e0;">
                  <td style="width: 6%">ที่</td>
                  <td style="width: 65%;">การอ่าน&nbsp;เขียน&nbsp;คิดวิเคราะห์</td>
                  <td style="width: 24%;">ผลการประเมิน</td>
      
                </tr>              
              </thead>
              <tbody>
                <tr>
                  <td>1</td>
                  <td style="text-align: left;">การอ่าน</td>
                  <td>3</td>                 
                </tr>
                <tr>
                  <td>2</td>
                  <td style="text-align: left;">การเขียน</td>
                  <td>3</td>                 
                </tr>
                <tr>
                  <td>3</td>
                  <td style="text-align: left;">การคิด วิเคราะห์</td>
                  <td>3</td>                 
                </tr>
               
                <tr style="font-weight: bold;">
                  <td colspan="2">สรุปผลการประเมิน</td>
                  <td>3</td>                 
                </tr>
              </tbody>
    </table> 
    <table cellspacing="0" style="width: 94%; text-align: center; font-size: 18px;margin-left:50px;border: 1px solid black;margin-top: 35px;">
             <thead style="font-weight: bold;">
                
                <tr style="background-color: #e0e0e0;">                  
                  <td colspan="6" style="width: 4%;">สรุปผลการประเมิน</td>            
                </tr>
                <tr style="background-color: #e0e0e0;">
                  <td style="width: 6%">ผลการเรียนเฉลี่ย</td>
                  <td style="width: 6%">ผลการเรียนเฉลี่ย สะสม</td>
                  <td style="width: 6%;">ลำดับที่<br>ในห้องเรียน</td>
                  <td style="width: 6%;">กิจกรรมพัฒนา ผู้เรียน</td>
                  <td style="width: 6%;">คุณลักษณะอันพึง ประสงค์</td>
                  <td style="width: 6%;">อ่าน&nbsp;เขียน คิดวิเคราะห์</td>
                
                </tr>              
              </thead>
              <tbody>
                <tr>
                  <td style="width: 16%">4.00</td>
                  <td style="width: 16%">4.00</td>
                  <td style="width: 16%">1</td>    
                  <td style="width: 16%">ผ่าน</td>  
                  <td style="width: 16%">3</td>  
                  <td style="width: 16%">3</td>               
                </tr>
               
              </tbody>
             
    </table> 
     <div style="margin-left: 120px;margin-top: 40px;font-size: 16px;">
                <p>.................................................................ครูประจำชั้น </p>
               
                <p style="margin-left: 2px;">(</p> <p style="margin-top: -24px;margin-left:160px;"> )</p>

                <p style="margin-left: 12px;">................/................/...................</p>
              </div>
               <div style="margin-left: 420px;margin-top: -74px;font-size: 16px;">
                <p>.................................................................ผู้ปกครอง </p>
               
                <p style="margin-left: 2px;">(</p> <p style="margin-top: -24px;margin-left:170px;"> )</p>

                <p style="margin-left: 12px;">................/................/...................</p>
              </div>
              <div style="margin-left: 420px;margin-top: 55px;font-size: 16px;">
                <p>.................................................................ผู้อำนวยการ</p>
               
                <p style="margin-left: 2px;">(</p> <p style="margin-top: -24px;margin-left:140px;"> )</p>

                <p style="margin-left: 12px;">................/................/...................</p>
              </div>
</page>
<file_sep>/index_local.php
<?php
/*
 * Web-Based Instruction PHP Programming :: ND Technology Co.,Ltd.  (Thailand)
 * Web-Design ::  ND Technology Co.,Ltd.  (Thailand )
 * Copyright (C) 2007-2015
 * Contact :: <EMAIL> 
 * This is the integration file for PHP (versions 5)
*/
@ob_start();
@session_start();

if( !$_SESSION['ss_user_id'] ){
	header('location:login.php');
} 

require_once('init.php');


function cURLData($url, $data){

	$postData = http_build_query($data);

	$ch = curl_init();
	curl_setopt_array(
	    $ch, array( 
	    CURLOPT_URL => $url,
	   	CURLOPT_RETURNTRANSFER => true,
	    CURLOPT_POST => true,
	    CURLOPT_POSTFIELDS => $postData,
	    CURLOPT_FOLLOWLOCATION => true
	));
	$response = curl_exec($ch);
	curl_close ($ch); //close curl handle	
	return $response;
}

$template_dir = 'templates/';
$index_templat = file_get_contents(HOME_PATH.$template_dir.'index.html');
$index_templat = str_replace('{TITLE_PAGE}', TITLE_PAGE, $index_templat);

//SLIDER_PAGE
$inc_data = file_get_contents(HOME_PATH."includes/inc.slider_page.php");
$index_templat = str_replace("{SLIDER_PAGE}", $inc_data, $index_templat);

//HEADER_PAGE
$inc_data = file_get_contents(HOME_PATH."includes/inc.header.php");
$BACKOFFICE_ACCOUNT_NAME = "{$_SESSION['ss_prefix_name']} {$_SESSION['ss_first_name']} {$_SESSION['ss_last_name']}";
$inc_data = str_replace("{BACKOFFICE_ACCOUNT_NAME}", $BACKOFFICE_ACCOUNT_NAME, $inc_data);
$index_templat = str_replace("{HEADER_PAGE}", $inc_data, $index_templat);

//FOOTER_PAGE
$inc_data = file_get_contents(HOME_PATH."includes/inc.footer_page.php");
$index_templat = str_replace("{FOOTER_PAGE}", $inc_data, $index_templat);

//BODY_PAGE
if(!empty($_GET['op'])){
	$OPURL			=	trim($_GET['op']);
	$GETOP			=	explode("-",$OPURL);
	$OPEN_PAGE		= 	"modules/".$GETOP[0];
	$CONFIG_PAGE 	= 	"{$OPEN_PAGE}/{$GETOP[1]}.php";
	$CONFIG_JS_PAGE = 	"{$OPEN_PAGE}/{$GETOP[1]}.js";
	$CONFIG_CSS_PAGE = 	"{$OPEN_PAGE}/{$GETOP[1]}.css";
	if (empty($GETOP[1]) || !file_exists($CONFIG_PAGE)) {
		header('location:index.php?op=messages-error404');
	}
}else{
	$OPEN_PAGE		= 	"modules/dashboard";
	$CONFIG_PAGE 	=	$OPEN_PAGE."/index.php";
	$CONFIG_JS_PAGE =	$OPEN_PAGE."/index.js";
	$CONFIG_CSS_PAGE =	$OPEN_PAGE."/index.css";

}

$POSTDATA = array();
foreach ($_GET as $key => $value) { $POSTDATA[$key] = $value; }
foreach ($_POST as $key => $value) { $POSTDATA[$key] = $value; }


$inc_data = cURLData(BASE_URL.'9cabling/backoffice/'.$CONFIG_PAGE,$POSTDATA);
$index_templat = str_replace("{BODY_PAGE}", $inc_data, $index_templat);

//OTHER_JS_PAGE
$CONFIG_JS_PAGE = (file_exists($CONFIG_JS_PAGE)) ? '<script src="'.$CONFIG_JS_PAGE.'" type="text/javascript"></script>' : '';
$CONFIG_CSS_PAGE = (file_exists($CONFIG_CSS_PAGE)) ? '<link href="'.$CONFIG_CSS_PAGE.'" rel="stylesheet" type="text/css" />' : '';
$index_templat = str_replace("{OTHER_CSS_PAGE}", $CONFIG_CSS_PAGE, $index_templat);
$index_templat = str_replace("{OTHER_JS_PAGE}", $CONFIG_JS_PAGE, $index_templat);

echo $index_templat;

?>


<file_sep>/modules/maneger_student/edit.php
<?php
include('modules/maneger_student/class_modules.php');
$class_data = new ClassData();
$data_id=$_GET['id'];
$extra_data=$class_data->get_extra_data($data_id);
?>
<div class="container set-content-pad-20" >
                 <div class="bg-whte" style="position: relative;padding-bottom: 60px">
                    <div class="circle-bg-violet">
                      <img class="head-img-circle" src="assets/images/4.png">
                    </div>
                    <div class="text-head-title">
                      <p>แก้ไขข้อมูลนักเรียน</p>
                    </div>
                     <div class="text-head-desc">
                     <p>ใช้สำหรับการแก้ไขข้อมูลนักเรียน โรงเรียนเทศบาลวัดสระทอง</p>
                     </div>
                      <div class="row pd-50 pt-80 stage-set" >
                     
                      <div class="col-sm-12">
                           <form id="frm_data">
                        <div class="bg-grey">
                          <div class="row">
                              <div class="col-sm-12">
                                <p class="text-title-in-grey text-violet ml-50 mb-20">ข้อมูลนักเรียน</p>
                              </div>
                             <div class="mb-15 col-sm-6">                        
                              <p class="text-bold text-search set-text-teacher-1" >รหัสนักเรียน</p>
                             
                                <div class="input-group form-add-teacher">
                                  <input id="std_ID" name="std_ID" type="text" class="form-control form-set-search" aria-describedby="basic-addon1">
                                </div>                          
                            </div>
                            <div class="mb-15 col-sm-6">                        
                              <p class="text-bold text-search set-text-teacher-2">รหัสประจำตัวประชาชน</p>
                              
                                <div class="input-group form-add-teacher">
                                  <input id="card_ID" name="card_ID" type="text" class="form-control form-set-search" aria-describedby="basic-addon1">
                                </div>                          
                               
                            </div>
                  
                            <div class="mb-10 col-sm-12">                        
                              <p class="text-bold text-search set-text-teacher-3" >ชั้น</p> 
                              <select disabled="disabled" id="class_level" name="class_level" class="form-control form-add-class-2">
                                <option id="calss_p1" value="p1">ป.1</option>
                                <option id="calss_p2" value="p2">ป.2</option>
                                <option id="calss_p3" value="p3">ป.3</option>
                                <option id="calss_p4" value="p4">ป.4</option>
                                <option id="calss_p5" value="p5">ป.5</option>
                                <option id="calss_p6" value="p6">ป.6</option>
                                <option id="calss_m1" value="m1">ม.1</option>
                                <option id="calss_m2" value="m2">ม.2</option>
                                <option id="calss_m3" value="m3">ม.3</option>
                                <option id="calss_m4" value="m4">ม.4</option>
                                <option id="calss_m5" value="m5">ม.5</option>
                                <option id="calss_m6" value="m6">ม.6</option>
                              </select>
                               <p class="text-bold text-search set-text-teacher-4" style="left: 30%;" >ห้อง</p> 
                              <select disabled="disabled" id="room" name="room" class="form-control form-add-class-3" style="margin-left: 10%">
                                <option id="room_1" value="1">1</option>
                                <option id="room_2" value="2">2</option>
                                <option id="room_3" value="3">3</option>
                                <option id="room_4" value="4">4</option>
                                <option id="room_5" value="5">5</option>
                                <option id="room_6" value="6">6</option>
                                <option id="room_7" value="7">7</option>
                                <option id="room_8" value="8">8</option>
                                <option id="room_9" value="9">9</option>
                                <option id="room_10" value="10">10</option>
                               
                              </select>        
                            </div>
                             <div class="mb-5 col-sm-12">                        
                              <p class="text-bold text-search set-text-teacher-3" >คำนำหน้าชื่อ</p> 
                              <select id="name_title" name="name_title" class="form-control form-add-class-2-2">
                                <option id="name_title_dekchai" value="dekchai">เด็กชาย</option>
                                <option id="name_title_dekying" value="dekying">เด็กหญิง</option>
                                <option id="name_title_nai" value="nai">นาย</option>
                                <option id="name_title_nangsaw" value="nangsaw">นางสาว</option>
                                
                              </select>
                            </div>
                            <div class="mb-10 col-sm-6">                        
                              <p class="text-bold text-search set-text-teacher-1" >ชื่อ</p>
                             
                                <div class="input-group form-add-teacher">
                                  <input id="fname" name="fname" type="text" class="form-control form-set-search" aria-describedby="basic-addon1">
                                </div>                          
                            </div>
                            <div class="mb-10 col-sm-6">                        
                              <p class="text-bold text-search set-text-teacher-2">สกุล</p>
                              
                                <div class="input-group form-add-teacher">
                                  <input id="lname" name="lname" type="text" class="form-control form-set-search" aria-describedby="basic-addon1">
                                </div>                          
                               
                            </div>

                             <div class="mb-10 col-sm-6">  

                              <p class="text-bold text-search set-text-teacher-1" >วัน/เดือน/ปีเกิด</p>            
                               <select name="years" id="years_set" class="form-control border-violet born-box-years">
                                   <?php
                                          for ($i=2560; $i >=2490 ; $i--) {  ?>            

                                          <option <?php 
                                              if ($extra_data['year']==$i) {
                                                echo "selected";
                                              }
                                           ?> value="<?php echo $i; ?>"><?php echo $i; ?></option>
                                      
                                          <?php  } ?>
                              </select>                       

                              <select name="mouth" onchange="get_day(this.value)" class="form-control border-violet born-box-month">
                                <option selected disabled>เดือนเกิด</option>
                                <option value="1" <?php if($extra_data['month']==1){echo "selected";} ?>>ม.ค.</option>
                                <option value="2" <?php if($extra_data['month']==2){echo "selected";} ?>>ก.พ.</option>
                                <option value="3" <?php if($extra_data['month']==3){echo "selected";} ?>>มี.ค.</option>
                                <option value="4" <?php if($extra_data['month']==4){echo "selected";} ?>>เม.ย.</option>
                                <option value="5" <?php if($extra_data['month']==5){echo "selected";} ?>>พ.ค.</option>
                                <option value="6" <?php if($extra_data['month']==6){echo "selected";} ?>>มิ.ย.</option>
                                <option value="7" <?php if($extra_data['month']==7){echo "selected";} ?>>ก.ค.</option>
                                <option value="8" <?php if($extra_data['month']==8){echo "selected";} ?>>ส.ค.</option>
                                <option value="9" <?php if($extra_data['month']==9){echo "selected";} ?>>ก.ย.</option>
                                <option value="10" <?php if($extra_data['month']==10){echo "selected";} ?>>ต.ค.</option>
                                <option value="11" <?php if($extra_data['month']==11){echo "selected";} ?>>พ.ย.</option>
                                <option value="12" <?php if($extra_data['month']==12){echo "selected";} ?>>ธ.ค.</option>
                              </select>    
                                <select name="day" id="day_set" class="form-control border-violet born-box-day">
                                    <option selected disabled>วันเกิด</option>    
                                     <?php echo $extra_data['day']; ?>  
                              </select>               
                            </div>
                             <div class="col-sm-6 mt-5">                        
                              <p class="text-bold text-search set-text-teacher-2" >หมู่โลหิต</p> 
                              <select id="blood_group" name="blood_group" class="form-control form-add-class-4">
                                <option id="blood_group_A" value="A">A</option>
                                <option id="blood_group_B" value="B">B</option>
                                <option id="blood_group_AB" value="AB">AB</option>
                                <option id="blood_group_O" value="O">O</option>                             
                              </select>
                            </div>
                            <div class="mb-30 col-sm-12">                        
                              <p class="text-bold text-search set-text-teacher-address" >ที่อยู่</p>
                             <div class="textarea-address">
                                <textarea id="address" name="address" class="form-control border-violet left " rows="3"></textarea>       
                             </div>                                          
                            </div>
                             <div class="mb-30 col-sm-12">                        
                              <p class="text-bold text-search set-text-teacher-3" >สถานะ</p> 
                              <select id="status_alive" name="status_alive" class="form-control form-add-class-2-2" style="width: 140px;">
                                <option value="1">กำลังศึกษา</option>
                                <option value="2">สำเร็จการศึกษา</option>
                                <option value="3">ย้ายสถานศึกษา</option>
                                <option value="4">ลาออก</option>
                                <option value="5">เสียชีวิต</option>        
                              </select>
                            </div>
                            <div class="col-sm-12">
                                <p class="text-title-in-grey text-violet ml-50 mb-20">ข้อมูลผู้ปกครอง</p>
                            </div> 
                             <div class="mb-5 col-sm-12">                        
                              <p class="text-bold text-search set-text-teacher-3" >คำนำหน้าชื่อ</p> 
                              <select id="parent_name_title" name="parent_name_title" class="form-control form-add-class-2-2">                        
                                <option id="parent_name_title_nai" value="nai">นาย</option>
                                <option id="parent_name_title_nang" value="nang">นาง</option>
                                <option id="parent_name_title_nangsaw" value="nangsaw">นางสาว</option>
                                
                              </select>
                            </div>
                            <div class="mb-10 col-sm-6">                        
                              <p class="text-bold text-search set-text-teacher-1" >ชื่อ</p>
                             
                                <div class="input-group form-add-teacher">
                                  <input id="parent_fname" name="parent_fname" type="text" class="form-control form-set-search" aria-describedby="basic-addon1">
                                </div>                          
                            </div>
                            <div class="mb-10 col-sm-6">                        
                              <p class="text-bold text-search set-text-teacher-2">สกุล</p>
                              
                                <div class="input-group form-add-teacher">
                                  <input id="parent_lname" name="parent_lname" type="text" class="form-control form-set-search" aria-describedby="basic-addon1">
                                </div>                          
                               
                            </div>
                              <div class="mb-10 col-sm-6">                        
                              <p class="text-bold text-search set-text-teacher-1" >โทรศัพท์</p>
                             
                                <div class="input-group form-add-teacher">
                                  <input id="tell" name="tell" type="text" class="form-control form-set-search" aria-describedby="basic-addon1">
                                </div>                          
                            </div>
                             <div class="mb-30 col-sm-12">                        
                              <p class="text-bold text-search set-text-teacher-address" >ที่อยู่</p>
                             <div class="textarea-address">
                                <textarea id="parent_address" name="parent_address" class="form-control border-violet left address-box" rows="3"></textarea>       
                             </div>                                          
                            </div>
                            <div class="btn-group-set-add-delete row pd-30 ">                                                     
                              <div onclick="get_data_form()" class="btn-grey">
                                ยกเลิก
                              </div>    
                              <div data-toggle="modal" data-target="#modalEdit" class="btn-violet">
                                บันทึก
                              </div>                   
                            </div>  

                            </div>

                           </div>   

                         </form>  

                      </div>
                      </div>
                        </div>
                       
                      </div><file_sep>/modules/mobile_api/newsDetailSub.php
<?php	
	@session_start();

	require_once('config.php');
    require_once('src/database.php');
    
	include('class_modules.php');
	$class_data = new ClassData();
	##CLASS_DB_CONNECT##
	$condition = false;
	$num=  $class_data->rows[0]['num'];		
	$json = json_decode(file_get_contents('php://input'), true);
	$newsSendId=$json['newsSendId'];
    $token=$json['token'];
    $token_set='4939d40bd21d4b987edc18a1911a6b94';
    if (MD5($token)==$token_set) {
        $products_arr=array();
        $products_arr["records"]=array();
        $class_data->sql = "SELECT DataID,file_name FROM tbl_news_gallery_sub WHERE newsID=$newsSendId";
    	$class_data->select();
        $class_data->setRows();

        foreach($class_data->rows as $key => $value) {
            $DataID= $value['DataID'];
            $file_name= $value['file_name'];	
            $img_url='/file_managers/news_sub/'.$file_name;
            $data_res['status']=1;
            $product_item=array(
                "key" => $DataID,
                "img_url_sub" => $img_url,
            );
            array_push($products_arr["records"], $product_item);
        }
    }
	echo json_encode($products_arr);

   

 ?>
<file_sep>/modules/mobile_api/host/config.php
<?php
	@header( 'Pragma: no-cache' );
	@header( 'Content-Type:text/html; charset=utf-8');
	date_default_timezone_set('Asia/Bangkok');
	error_reporting(0);


$connectstr_dbhost = '';
$connectstr_dbname = '';
$connectstr_dbusername = '';
$connectstr_dbpassword = '';

foreach ($_SERVER as $key => $value) {
    if (strpos($key, "MYSQLCONNSTR_localdb") !== 0) {
        continue;
    }
    
    $connectstr_dbhost = preg_replace("/^.*Data Source=(.+?);.*$/", "\\1", $value);
    $connectstr_dbname = preg_replace("/^.*Database=(.+?);.*$/", "\\1", $value);
    $connectstr_dbusername = preg_replace("/^.*User Id=(.+?);.*$/", "\\1", $value);
    $connectstr_dbpassword = preg_replace("/^.*Password=(.+?)$/", "\\1", $value);
}

// ** MySQL settings - You can get this info from your web host ** //
/** MySQL hostname : this contains the port number in this format host:port . Port is not 3306 when using this feature*/
define('DB_SERVER', $connectstr_dbhost);

/** MySQL database username */
define('DB_USER', $connectstr_dbusername);

/** MySQL database password */
define('DB_PASS', $connectstr_dbpassword);

/** The name of the database for WordPress */
define('DB_DATABASE', 'sratong_eva');

?>

<file_sep>/modules/profile/backup/edit.php
<?php
include('modules/profile/class_modules.php');
$class_data = new ClassData();
$extra_data=$class_data->get_extra_data();
?>
<div class="container set-content-pad-20" >
                 <div class="bg-whte" style="position: relative;padding-bottom: 60px">
                  <div class="row">
                    <div class="col-sm-5"> 
                       <form id="frm_data_up" method="post" enctype="multipart/form-data">
                             <input id="uploadBtn" type="file" name="file_up" style="display: none;" />
                        </form>
                        <div class="profile-set" id="uploadBtn_select">
                          <span class="glyphicon glyphicon-picture span-profile" aria-hidden="true"></span>
                          <div id="get_profile_img">
                           
                          </div>      
                        </div>
                    </div>
                    <div class="col-sm-7 mt-40" >
                      <center>        
                          <a href="index.php?op=profile-index">            
                            <div class="btn-profile-header-first  text-black">
                              ข้อมูลส่วนตัว
                            </div>
                          </a>
                          <a href="index.php?op=profile-edit">
                            <div class="btn-profile-header-sec soft-violet text-black">
                              แก้ไข
                            </div>    
                          </a>                    
                      </center> 
                    </div>

                  </div>
                   <div class="row stage-se mt-10">
                    <div class="col-sm-5">
                      <h3 class="text-bold center-col" id="full_name_th"></h3>
                      <h4 class="text-bold center-col">กลุ่มสาระ <label id="department_pro"></label></h4>

                    </div>
                    <div class="line-divide-col"></div>
                    <div class="col-sm-7">
                      <div class="profile-detail-box mt-20 fs-16 ml-20">
                      <form id="frm_data">
                        <table class="table table-borderless">
                          <tbody style="border: none;">
                          <tr>
                            <th>เลขประจำตำแหน่ง</th>
                            <td>
                              <div id="profile-edit-box_chk" class="profile-edit-box">
                                <input type="text" id="positionID" name="positionID" >
                              </div>  
                            </td>
                          </tr>
                          <tr>
                            <th width="35%">ชื่อ</th>
                            <td>
                              <div class="profile-edit-box">
                                <input type="text" id="fname_th" name="fname_th">
                              </div>                              
                            </td>
                          </tr>
                           <tr>
                            <th width="35%">นามสกุล</th>
                            <td>
                              <div class="profile-edit-box">
                                <input type="text" id="lname_th" name="lname_th">
                              </div>                              
                            </td>
                          </tr>
                          <tr>
                            <th width="35%">Firstname</th>
                            <td>
                              <div class="profile-edit-box">
                                <input type="text" id="fname_en" name="fname_en" >
                              </div>                              
                            </td>
                          </tr>
                           <tr>
                            <th width="35%">Lastname</th>
                            <td>
                              <div class="profile-edit-box">
                                <input type="text" id="lname_en" name="lname_en" >
                              </div>                              
                            </td>
                          </tr>
                          <tr>
                            <th>การศึกษา</th>
                            <td>
                              <div class="profile-edit-box">
                                <textarea rows="3" id="study_history" name="study_history"> </textarea>     
                              </div>
                            </td>
                          </tr>
                          <tr>
                            <th>วัน/เดือน/ปีเกิด</th>
                            <td>
                              <div class="profile-edit-box">
                                <div class="row"> 
                                  <div class="col-md-3 col-sm-3">
                                      <select id="day_set" name="day"  class="form-control">
                                          <option selected disabled>วันเกิด</option>    
                                          <?php echo $extra_data['day']; ?>                                    
                                      </select>
                                  </div>

                                  <div class="col-md-3 col-sm-3">
                                      <select onchange="get_day(this.value)" name="month" id="month" class="form-control">
                                          <option selected disabled>เดือนเกิด</option>
                                          <option value="1" <?php if($extra_data['month']==1){echo "selected";} ?>>ม.ค.</option>
                                          <option value="2" <?php if($extra_data['month']==2){echo "selected";} ?>>ก.พ.</option>
                                          <option value="3" <?php if($extra_data['month']==3){echo "selected";} ?>>มี.ค.</option>
                                          <option value="4" <?php if($extra_data['month']==4){echo "selected";} ?>>เม.ย.</option>
                                          <option value="5" <?php if($extra_data['month']==5){echo "selected";} ?>>พ.ค.</option>
                                          <option value="6" <?php if($extra_data['month']==6){echo "selected";} ?>>มิ.ย.</option>
                                          <option value="7" <?php if($extra_data['month']==7){echo "selected";} ?>>ก.ค.</option>
                                          <option value="8" <?php if($extra_data['month']==8){echo "selected";} ?>>ส.ค.</option>
                                          <option value="9" <?php if($extra_data['month']==9){echo "selected";} ?>>ก.ย.</option>
                                          <option value="10" <?php if($extra_data['month']==10){echo "selected";} ?>>ต.ค.</option>
                                          <option value="11" <?php if($extra_data['month']==11){echo "selected";} ?>>พ.ย.</option>
                                          <option value="12" <?php if($extra_data['month']==12){echo "selected";} ?>>ธ.ค.</option>
                                      </select>
                                  </div>

                                  <div class="col-md-4 col-sm-4">
                                      <select name="years" class="form-control">
                                          <?php
                                          for ($i=2560; $i >=2490 ; $i--) {  ?>            

                                          <option <?php 
                                              if ($extra_data['year']==$i) {
                                                echo "selected";
                                              }
                                           ?> value="<?php echo $i; ?>"><?php echo $i; ?></option>
                                      
                                          <?php  } ?>
                                      </select>
                                  </div>
                              </div>
                          </div>
                            </td>
                          </tr>
                          <tr>
                            <th>เพศ</th>
                            <td>
                              <div class="radio radio-inline">
                                <label><input type="radio" name="gender" value="male" <?php if($extra_data['gender']=="male"){echo "checked";} ?>>ชาย</label>
                              </div>
                              <div class="radio radio-inline">
                                <label><input type="radio" name="gender" value="female" <?php if($extra_data['gender']=="female"){echo "checked";} ?>>หญิง</label>
                              </div>
                            </td>
                          </tr>
                           <tr>
                            <th>หมู่โลหิต</th>
                            <td>
                              <div class="profile-edit-box">
                                <div class="row"> 
                                  <div class="col-md-4 col-sm-4">
                                      <select id="blood_group" name="blood_group"  class="form-control">
                                     
                                          <option value="" <?php  if($extra_data['blood_group']==""){echo "selected";} ?>>เลือก</option> 
                                          <option value="A" <?php  if($extra_data['blood_group']=="A"){echo "selected";} ?>>A</option>
                                          <option value="B" <?php  if($extra_data['blood_group']=="B"){echo "selected";} ?>>B</option>
                                          <option value="AB" <?php if($extra_data['blood_group']=="AB"){echo "selected";} ?>>AB</option>
                                          <option value="O" <?php  if($extra_data['blood_group']=="O"){echo "selected";} ?>>O</option>                  
                                      </select>
                                  </div>
                                </div>
                              
                              </div>
                              
                            </td>
                          </tr>
                           <tr>
                            <th>ที่อยู่</th>
                            <td>
                              <div class="profile-edit-box">
                                <textarea rows="3" id="address" name="address"></textarea>     
                              </div>
                            </td>
                          </tr>
                           
                           <tr>
                            <th>ตำแหน่ง</th>
                            <td>
                              <div class="profile-edit-box">
                                <input type="text" id="position_name" name="position_name" >
                              </div> 
                            </td>
                          </tr>
                           <tr>
                            <th>กลุ่มสาระ</th>
                            <td>
                              <div class="profile-edit-box">
                                <div class="row"> 

                                  <div class="col-md-8 col-sm-8">
                                      <select  name="department"  class="form-control">
                           
                                          <option value="" <?php if($extra_data['department']==""){echo "selected";} ?>>เลือก</option>
                                          <option value="1" <?php if($extra_data['department']=="1"){echo "selected";} ?>>ภาษาไทย</option>
                                          <option value="2" <?php if($extra_data['department']=="2"){echo "selected";} ?>>คณิตศาสตร์</option>
                                          <option value="3" <?php if($extra_data['department']=="3"){echo "selected";} ?>>วิทยาศาสตร์</option>
                                          <option value="4" <?php if($extra_data['department']=="4"){echo "selected";} ?>>สังคมศึกษา ศาสนาและวัฒนธรรม </option>  
                                          <option value="5" <?php if($extra_data['department']=="5"){echo "selected";} ?>>สุขศึกษาและพลศึกษา </option>            
                                          <option value="6" <?php if($extra_data['department']=="6"){echo "selected";} ?>>ศิลปะ </option> 
                                          <option value="7" <?php if($extra_data['department']=="7"){echo "selected";} ?>>การงานอาชีพและเทคโนโลยี</option> 
                                          <option value="8" <?php if($extra_data['department']=="8"){echo "selected";} ?>>ภาษาต่างประเทศ</option>            
                                
                                      </select>
                                  </div>
                                </div>
                              
                              </div>
                            </td>
                          </tr>
                           <tr>
                            <th>ฝ่ายงาน</th>
                            <td>
                              <div class="profile-edit-box">
                                <input type="text" id="work" name="work" placeholder="*เช่น ฝ่ายวิชาการ ฝ่ายบุคคล" >
                              </div> 
                            </td>
                          </tr>
                           <tr>
                            <th>เพิ่มเติม</th>
                            <td>
                              <div class="profile-edit-box">
                                <textarea rows="3" id="more_detail" name="more_detail"></textarea>     
                              </div>
                            </td>
                          </tr>
                           <tr>
                            <th>โทรศัพท์</th>
                            <td>
                              <div class="profile-edit-box">
                                <input type="text" name="tell" id="tell" >
                              </div> 
                            </td>
                          </tr>
                           <tr>
                            <th>อีเมล</th>
                            <td>
                              <div class="profile-edit-box">
                                <input type="text" name="email" id="email" >
                              </div> 
                            </td>
                          </tr>
                          </tbody>
                        </table>  
                      
                          <div class="btn-confirm-regis-profile pd-40">
                            <div class="btn-grey close-modal-alert" data-dismiss="modal">
                              ยกเลิก
                            </div> 
                            <div  data-toggle="modal" data-target="#modalEdit" class="btn-violet">
                              ยืนยัน
                            </div> 
                          </div>  

                         </form>                   
                      </div>                           
                    </div>
                   </div>
                 </div>   

                </div><file_sep>/modules/report_std_personal/class_modules_m.php
<?php 

class ClassData extends Databases {
	
	public function get_pw6_m($std_ID,$term,$year){
		$this->sql ="		
					SELECT tbl_pp6.name_title,tbl_pp6.fname,tbl_pp6.lname,tbl_pp6.class_level,tbl_pp6.room,tbl_pp6.DataID as pp6_ID,tbl_pp6.term,tbl_pp6.year,tbl_sub_pp6.name as course_name,tbl_sub_pp6.courseID as courseID,tbl_sub_pp6.department as department,tbl_sub_pp6.unit as unit,tbl_sub_pp6.status as status_course,tbl_sub_pp6.status_form as status_form,tbl_sub_pp6.score_mid as score_mid,tbl_sub_pp6.score_final as score_final,tbl_sub_pp6.score_total as score_total,tbl_sub_pp6.score_desirable as score_desirable,tbl_sub_pp6.score_rtw as score_rtw,tbl_sub_pp6.score_attend as score_attend
					FROM tbl_pp6,tbl_sub_pp6
					WHERE tbl_pp6.DataID=tbl_sub_pp6.pp6_ID
					AND tbl_pp6.std_ID='$std_ID'
					AND term='$term'
					AND year='$year'
							";
		$this->select();
		$this->setRows();
		$card_ID=$this->rows[0]['card_ID'];
		$name_title_data=$this->rows[0]['name_title'];
		$fname=$this->rows[0]['fname'];
		$lname=$this->rows[0]['lname'];
		$class_level_data=$this->rows[0]['class_level'];
		$room=$this->rows[0]['room'];
		$term_data=$this->rows[0]['term'];
		$year_data=$this->rows[0]['year'];
		
		$class_level=$this->get_class_level_number($class_level_data);
		$name_title=$this->get_name_title($name_title_data);
		$data_response['std_ID']=$std_ID;
		$data_response['card_ID']=$card_ID;
		$data_response['std_name']=$name_title.$fname.' '.$lname;
		$data_response['class_level_room']=$class_level.'/'.$room;
		$data_response['term']=$term_data;
		$data_response['year']=$year_data;

		$unit_count_main=0;
		$unit_count_add=0;
		$score_mid_count=0;
		$score_final_count=0;
		$score_total_count=0;
		$score_desirable_count=0;
		$score_rtw_count=0;
		$unit_not_cout_main=0;
		$unit_not_cout_add=0;
		$attend_not_pass_count=0;

		$result_row=0;

		$count=0;
		$count_all=0;

		$num_main=1;
		$num_add=1;
		$num_dev=1;
		foreach($this->rows as $key => $value) {
			$course_name =  $value['course_name'];	
			$courseID =  $value['courseID'];	
			$unit =  $value['unit'];

			$score_mid =  $value['score_mid'];
			$score_final =  $value['score_final'];
			$score_total =  $value['score_total'];
			$status_course=$value['status_course'];
			$status_form=$value['status_form'];
			
			$score_desirable =  number_format($value['score_desirable'],0);
			$score_rtw =  number_format($value['score_rtw'],0);
			$score_attend =  $value['score_attend'];
			$department_data=$value['department'];
		
			//$department=$this->get_department($department_data);
			if ($status_course==1) {
				if ($status_form==11) {
					if($score_total==-1){
						$grade_set='ร';
						$score_total=$score_mid+$score_final;
						$unit_not_cout_main=$unit_not_cout_main+$unit;
					}else{
						$grade_set=$this->get_grade($score_total);
						$score_total_count=$score_total_count+$score_total;
						$score_mid_count=$score_mid_count+$score_mid;
						$score_final_count=$score_final_count+$score_final;

						$score_desirable_count=$score_desirable_count+$score_desirable;
						$score_rtw_count=$score_rtw_count+$score_rtw;
					}
					$data_response['sub_main_list'].='
						 <tr>
				            <td>'.$num_main.'</td>
				            <td style="text-align: left;">'.$course_name.'</td>
				            <td>'.$courseID.'</td>
				            <td>'.$unit.'</td>
				            <td>'.$score_total.'</td>
				            <td>'.$grade_set.'</td>
				            <td>'.$score_desirable.'</td>
				            <td>'.$score_rtw.'</td>
				            <td></td>
				          </tr>
					';
				$unit_count_main=$unit_count_main+$unit;
				$num_main++;
				}else{
					if($score_total==-1){
						$grade_set='ร';
						$score_total=$score_mid+$score_final;
						$unit_not_cout_add=$unit_not_cout_add+$unit;
					}else{
						$grade_set=$this->get_grade($score_total);
						$score_total_count=$score_total_count+$score_total;
						$score_mid_count=$score_mid_count+$score_mid;
						$score_final_count=$score_final_count+$score_final;

						$score_desirable_count=$score_desirable_count+$score_desirable;
						$score_rtw_count=$score_rtw_count+$score_rtw;
					}
					$data_response['sub_add_list'].='
						 <tr>
				            <td>'.$num_add.'</td>
				            <td style="text-align: left;">'.$course_name.'</td>
				            <td>'.$courseID.'</td>
				            <td>'.$unit.'</td>
				            <td>'.$score_total.'</td>
				            <td>'.$grade_set.'</td>
				            <td>'.$score_desirable.'</td>
				            <td>'.$score_rtw.'</td>
				            <td></td>
				          </tr>
					';
					$unit_count_add=$unit_count_add+$unit;
					$num_add++;
				}

				

				$result_row=$result_row+($grade_set*$unit);
				$count++;
			}else{				
				if ($score_attend==1) {
					$attend_text='ผ่าน';
				}else{
					$attend_text='ไม่ผ่าน';
					$attend_not_pass_count++;
				}
				$data_response['sub_dev_list'].='
						  <tr>
				            <td>'.$num_dev.'</td> 
				            <td  style=";text-align: left;">'.$course_name.'</td>
				            <td>'.$courseID.'</td>
				            <td>-</td>          
				            <td>-</td>         
				            <td style=";text-align: center;">'.$attend_text.'</td>
				            <td>'.$score_desirable.'</td>
				            <td>'.$score_rtw.'</td>
				            <td></td>
				          </tr>
				';
				$score_desirable_count_dev=$score_desirable_count_dev+$score_desirable;
				$score_rtw_count_dev=$score_rtw_count_dev+$score_rtw;
				$num_dev++;
			}
			
			
			
			$unit_all=number_format($unit_count_main+$unit_count_add,1);


			
			
			$count_all++;

		}
		
		$data_response['sub_sum_list']='
				  <tr style="text-align: center;font-weight:bold;">
		            <td colspan="3">รวม</td>
		            <td>'.$unit_all.'</td>
		            <td>'.$score_total_count.'</td>
		            <td>'.number_format($result_row/($unit_count_main+$unit_count_add),2).'</td>
		            <td>'.$score_desirable_count.'</td>
		            <td>'.$score_rtw_count.'</td>
		            <td></td>
		          </tr>
		';
		$find_score_average=$score_total_count/$count;
		$find_desirable_average=number_format(($score_desirable_count+$score_desirable_count_dev)/$count_all,0);
		$find_rtw_average=number_format(($score_rtw_count+$score_rtw_count_dev)/$count_all,0);
		/*
		$data_response['sub_average_list']='
					 <tr style="text-align: center;font-weight:bold;">
			            <td colspan="6">เฉลี่ย</td>
			            <td>'.$find_score_average.'</td>
			            <td></td>
			            <td>'.$find_desirable_average.'</td>
			            <td>'.$find_rtw_average.'</td>
			            <td></td>
			          </tr>
		';*/
		$unit_posible_main=number_format($unit_count_main-$unit_not_cout_main,1);
		$unit_posible_add=number_format($unit_count_add-$unit_not_cout_add,1);

		$rtw_text=$this->get_rtw_text($find_rtw_average);
		$desirable_text=$this->get_desirable_text($find_desirable_average);
		if ($attend_not_pass_count>0) {
			$attend_text_set='ไม่ผ่าน';
		}else{
			$attend_text_set='ผ่าน';
		}
		
		$find_position=$this->find_position($year_data,$term,$class_level_data,$room);
		arsort($find_position);
		/*$arrayValuePosition=$this->arrayValuePosition($std_ID,$find_position);
		$new_position=$arrayValuePosition+1;*/
		
		$arrayValuePosition=$this->arrayValuePositionNew($find_position,$std_ID);
		
		
		$data_response['sub_conclution_list']='
					<tbody style="text-align: center;">
			          <tr style="background-color: #ddddddb3;font-weight: bold;">
			            <th rowspan="2" style="text-align: center;">สรุปผลการประเมิน</th>
			            <th colspan="2" style="text-align: center;">ผลการเรียน</th>
			          </tr>
			          <tr style="background-color: #ddddddb3;font-weight: bold;">
			            <th style="text-align: center;width:14%;">ที่เรียน</th>
			            <th style="text-align: center;width:14%;">ที่ได้</th>
			          </tr>
			          <tr>
			            <td  style="text-align: left;">จำนวนหน่วยกิตวิชาพื้นฐาน</td>
			            <td>'.number_format($unit_count_main,1).'</td>
			            <td>'.number_format($unit_posible_main,1).'</td>
			          </tr>
			          <tr>
			            <td style="text-align: left;">จำนวนหน่วยกิตวิชาเพิ่มเติม</td>
			            <td>'.number_format($unit_count_add,1).'</td>
			            <td>'.number_format($unit_posible_add,1).'</td>
			          </tr>
			          <tr>
			            <td style="text-align: left;">รวมจำนวนหน่วยกิต</td>
			            <td>'.number_format($unit_count_main+$unit_count_add,1).'</td>
			            <td>'.number_format($unit_posible_main+$unit_posible_add,1).'</td>
			          </tr>
			          <tr>
			            <td style="text-align: left;">ระดับผลการเรียนเฉลี่ย</td>
			            <td colspan="2">'.number_format($result_row/($unit_count_main+$unit_count_add),2).'</td>
			          </tr>
			          <tr>
			            <td style="text-align: left;">ลำดับที่ในห้องเรียน</td>
			            <td colspan="2">'.$arrayValuePosition.'</td>
			          </tr>
			          
			          <tr>
			            <td style="text-align: left;">คุณลักษณะอันพึงประสงค์</td>
			            <td colspan="2">'.$desirable_text.'</td>
			          </tr>
			          <tr>
			            <td style="text-align: left;">อ่าน เขียน คิดวิเคราะห์</td>
			            <td colspan="2">'.$rtw_text.'</td>
			          </tr>
			          <tr>
			            <td style="text-align: left;">ผลการประเมินกิจกรรมพัฒนาผู้เรียน</td>
			            <td colspan="2">'.$attend_text_set.'</td>
			          </tr>
			          
			        </tbody>
		';
		return $data_response;
	}
	public function arrayValuePositionNew($find_position,$std_ID){	
			$result = array();
			$pos = $real_pos = 0;
			$prev_score = -1;
			foreach ($find_position as $exam_n => $score) {
			    $real_pos += 1;// Natural position.
			    $pos = ($prev_score != $score) ? $real_pos : $pos;// If I have same score, I have same position in ranking, otherwise, natural position.
			    $result[$exam_n] = array(
			                     "score" => $score, 
			                     "position" => $pos, 
			                     "exam_no" => $exam_n
			                     );
			    $prev_score = $score;// update last score.
			}

		    return $result[$std_ID]["position"];
	}
	public function arrayValuePosition($value, $array){	
		    return array_search($value, array_keys($array));
	}
	public function get_data_big_std($std_pp6_id,$pp6_id){
		$this->sql ="SELECT unit,score_total
					FROM tbl_pp6,tbl_sub_pp6
					WHERE tbl_pp6.DataID=tbl_sub_pp6.pp6_ID
					AND tbl_sub_pp6.pp6_ID=$pp6_id
					AND score_total!=-1
		";
		$this->select();
		$this->setRows();
		$find_row_sum=0;
		foreach($this->rows as $key => $value) {
			 $unit=$value['unit'];
			 $score_total=$value['score_total'];
			 $grade= $this->get_grade($score_total);
			 $find_row_sum=$find_row_sum+($unit*$grade);
		}
		$this->sql ="SELECT SUM(unit) as unit_sum
					FROM tbl_pp6,tbl_sub_pp6
					WHERE tbl_pp6.DataID=tbl_sub_pp6.pp6_ID
					AND tbl_sub_pp6.pp6_ID=$pp6_id
					AND tbl_sub_pp6.status=1
		";
		$this->select();
		$this->setRows();
		$unit_sum=$this->rows[0]['unit_sum'];
		return $find_row_sum/$unit_sum;
	}
	public function find_position($year_data,$term,$class_level_data,$room){
		$data_response = array();	
		$this->sql ="SELECT distinct(tbl_pp6.std_ID) as std_pp6_id,tbl_pp6.DataID as pp6_id
					FROM tbl_pp6,tbl_sub_pp6
					WHERE tbl_pp6.DataID=tbl_sub_pp6.pp6_ID
					AND tbl_pp6.year='$year_data'
					AND tbl_pp6.term='$term'
					AND tbl_pp6.room='$room'
					AND tbl_pp6.class_level='$class_level_data'
					AND tbl_sub_pp6.status=1
		";
		$this->select();
		$this->setRows();
		$find_gpa_sum=0;	
		$score_final_count=0;
		foreach($this->rows as $key => $value) {
			 $std_pp6_id=$value['std_pp6_id'];
			 $pp6_id=$value['pp6_id'];
			 $data_big_std= $this->get_data_big_std($std_pp6_id,$pp6_id);
			 $test[$std_pp6_id] = $data_big_std;
			 /*
			 $pick_poi= $this->get_pick_poi($registed_courseID,$stdID,$term_data,$year);
			 $grade_text=$this->get_grade_text($score_exam,$pick_poi);
			 $unit=$this->get_unit($registed_courseID);
			 $find_gpa=$grade_text*$unit;
			
			 $find_gpa_sum=$find_gpa_sum+$find_gpa;*/

			 //$tt.=$stdID.'='.$insert.',';
		}
		//$total= $final_poi+$mid_poi;

		return $test;
	}
	public function get_rtw_text($find_rtw_average){
		switch ($find_rtw_average) {
			case 0:
		       	$rtw='ไม่ผ่าน';
		        break;
		    case 1:
		       	$rtw='ผ่าน';
		        break;
		    case 2:
		        $rtw='ดี';
		        break;
		    case 3:
		        $rtw='ดีเยี่ยม';
		        break; 
		    default:
		     	$rtw='';
		}
		return $rtw;
	}
	public function get_desirable_text($find_desirable_average){
		switch ($find_desirable_average) {
			case 0:
		       	$desirable='ไม่ผ่าน';
		        break;
		    case 1:
		       	$desirable='ผ่าน';
		        break;
		    case 2:
		        $desirable='ดี';
		        break;
		    case 3:
		        $desirable='ดีเยี่ยม';
		        break; 
		    default:
		     	$desirable='';
		}
		return $desirable;
	}
	public function get_department($data){
		
		switch ($data) {
		    case 1:
		       	$department='ภาษาไทย';
		        break;
		    case 2:
		        $department='คณิตศาสตร์';
		        break;
		    case 3:
		        $department='วิทยาศาสตร์';
		        break;
		    case 31:
		        $department='วิทยาศาสตร์และเทคโนโลยี';
		        break;    
		    case 4:
		        $department='สังคมศึกษา ศาสนาและวัฒนธรรม';
		        break;
		    case 41:
		        $department='สังคมศึกษา';
		        break;
		    case 42:
		        $department='ภูมิศาสตร์';
		        break;
		    case 43:
		        $department='ประวัติศาสตร์';
		        break;
		    case 5:
		        $department='สุขศึกษาและพลศึกษา';
		        break;
		    case 6:
		        $department='ศิลปะ';
		        break;
		    case 7:
		        $department='การงานอาชีพและเทคโนโลยี';
		        break; 
		    case 71:
		        $department='การงานอาชีพ';
		        break; 
		    case 8:
		        $department='ภาษาต่างประเทศ';
		        break;     
		    default:
		     	$department='';
		}
		return $department;
	}
	public function get_grade($total){
		if ($total<50) {
			$grade='0.0';
		}elseif($total<55){
			$grade='1.0';
		}elseif($total<60){
			$grade='1.5';
		}elseif($total<65){
			$grade='2.0';
		}elseif($total<70){
			$grade='2.5';
		}elseif($total<75){
			$grade='3.0';
		}elseif($total<80){
			$grade='3.5';
		}elseif($total>=80){
			$grade='4.0';
		}
		return $grade;
	}
	public function get_year(){
		$this->sql ="SELECT  distinct(year) as year
					FROM tbl_pp6
							";
		$this->select();
		$this->setRows();
		foreach($this->rows as $key => $value) {
			$year=  $value['year'];	
			$data_response.='
					 <option value="'.$year.'">'.$year.'</option>
			';
		}
		return json_encode($data_response);
	}


	
	public function get_std_list($class_search,$room_search,$name_id_search,$search_status,$term,$year){
		$data_response = array();	
		$sql_condition = "";
		if ($search_status=="class_room") {
			$sql_condition = " AND ( class_level LIKE '%{$class_search}%')  AND ( room LIKE '%{$room_search}%')";
		}elseif ($search_status=="name_id") {
			$sql_condition = " AND (std_ID LIKE '%{$name_id_search}%')  OR ( fname LIKE '%{$name_id_search}%') OR ( lname LIKE '%{$name_id_search}%')";
		}	
		$this->sql ="		
					SELECT *
					FROM tbl_pp6
					WHERE term='$term'
					AND year='$year'
					$sql_condition
							";
		$this->select();
		$this->setRows();
		foreach($this->rows as $key => $value) {
			$std_ID=  $value['std_ID'];	
			$name_title_data=  $value['name_title'];	
			$fname=  $value['fname'];	
			$lname=  $value['lname'];	
			$class_level_data=  $value['class_level'];
			$class_level=$this->get_class_level($class_level_data);
			$name_title=$this->get_name_title($name_title_data);
			$room=  $value['room'];
			$pp6_ID=  $value['pp6_ID'];
			if ($class_level_data=='p1' || $class_level_data=='p2' || $class_level_data=='p3' || $class_level_data=='p4' || $class_level_data=='p5' || $class_level_data=='p6') {
				$data_link='modules/report_std_personal/report_form_p.php?std_ID='.$std_ID.'&year='.$year.'&term='.$term.'';
			}else{
				$data_link='modules/report_std_personal/report_form_m.php?std_ID='.$std_ID.'&year='.$year.'&term='.$term.'';
			}
			$data_response.='
							<tr>
			                  <td style="text-align: center;">      
			                    <input class="checkbox_data" type="checkbox" value="'.$pp6_ID.'" name="checkbox_print[]" id="'.$pp6_ID.'">   

			                  </td>
			                  <td style="text-align: center;">'.$std_ID.'</td>
			                  <td>'.$name_title.$fname.'</td>
			                  <td>'.$lname.'</td>
			                  <td style="text-align: center;">'.$class_level.'</td>
			                  <td style="text-align: center;">'.$room.'</td>
			                  <td style="text-align: center;">
			                  	<a target="_blank" href="'.$data_link.'" style="color: #ac68cc;">
			                  		<span class="glyphicon glyphicon-print" aria-hidden="true"></span>
			                  	</a>
			                  </td>
			                </tr>
                           
			';
		}
		echo json_encode($data_response); 
	}
	public function get_name_title($name_title_data){
		if ($name_title_data=="dekchai") {
			$name_title="เด็กชาย";
		}elseif($name_title_data=="dekying"){
			$name_title="เด็กหญิง";
		}elseif($name_title_data=="nai"){
			$name_title="นาย";
		}elseif($name_title_data=="nangsaw"){
			$name_title="นางสาว";
		}
		return $name_title;
	}
	
	public function get_class_level_number($class_level_data){
		if ($class_level_data=="p1") {
			$class_level="1";
		}elseif($class_level_data=="p2"){
			$class_level="2";	
		}elseif($class_level_data=="p3"){
			$class_level="3";	
		}elseif($class_level_data=="p4"){
			$class_level="4";	
		}elseif($class_level_data=="p5"){
			$class_level="5";	
		}elseif($class_level_data=="p6"){
			$class_level="6";	
		}elseif($class_level_data=="m1"){
			$class_level="1";	
		}elseif($class_level_data=="m2"){
			$class_level="2";	
		}elseif($class_level_data=="m3"){
			$class_level="3";	
		}elseif($class_level_data=="m4"){
			$class_level="4";	
		}elseif($class_level_data=="m5"){
			$class_level="5";	
		}elseif($class_level_data=="m6"){
			$class_level="6";	
		}
		return $class_level;
	}
	public function get_class_level($class_level_data){
		if ($class_level_data=="p1") {
			$class_level="ป.1";
		}elseif($class_level_data=="p2"){
			$class_level="ป.2";	
		}elseif($class_level_data=="p3"){
			$class_level="ป.3";	
		}elseif($class_level_data=="p4"){
			$class_level="ป.4";	
		}elseif($class_level_data=="p5"){
			$class_level="ป.5";	
		}elseif($class_level_data=="p6"){
			$class_level="ป.6";	
		}elseif($class_level_data=="m1"){
			$class_level="ม.1";	
		}elseif($class_level_data=="m2"){
			$class_level="ม.2";	
		}elseif($class_level_data=="m3"){
			$class_level="ม.3";	
		}elseif($class_level_data=="m4"){
			$class_level="ม.4";	
		}elseif($class_level_data=="m5"){
			$class_level="ม.5";	
		}elseif($class_level_data=="m6"){
			$class_level="ม.6";	
		}
		return $class_level;
	}
}<file_sep>/modules/conclusion/class_modules/learing_resualt_level.php
<?php 
class ClassData extends Databases {
	
	public function get_loop_data($class_level,$year,$term){
		$this->sql ="SELECT DISTINCT(department) AS department,courseID
						FROM tbl_sub_pp6
						WHERE status=1
						AND pp6_ID in(
							SELECT DataID
							FROM tbl_pp6
							WHERE class_level='$class_level'
							AND term='$term'
							AND year='$year'
							
						)
						ORDER BY pp6_ID ASC
							";
			$this->select();
			$this->setRows();
			$order=1;
			$amount_std_all=0;
			$grade_amount_40=0;
			$grade_amount_35=0;
			$grade_amount_30=0;
			$grade_amount_25=0;
			$grade_amount_20=0;
			$grade_amount_15=0;
			$grade_amount_10=0;
			$grade_amount_00=0;

			$grade_amount_higher_3=0;
			$grade_amount_higher_3_percentage=0;
			foreach($this->rows as $key => $value) {
			$department_set=$value['department'];
			$courseID=$value['courseID'];
			
			$department=$this->get_department($department_set);
			$amount_std=$this->get_amount_std($department_set,$class_level,$year,$term);
			$grade_amount=$this->get_grade_amount($department_set,$class_level,$year,$term);
			$grade_higher_3=$grade_amount['data_40']+$grade_amount['data_35']+$grade_amount['data_30'];
			$grade_higher_3_percentage=number_format(($grade_higher_3*100)/$amount_std,2);
			$data_response.='
				<tr>
					<td>'.$order.'</td>
					<td>'.$courseID.'</td>
					<td style="text-align:left;padding-left:15px;">'.$department.'</td>
					<td>'.$amount_std.'</td>
					<td>'.$grade_amount['data_40'].'</td>
					<td>'.$grade_amount['data_35'].'</td>
					<td>'.$grade_amount['data_30'].'</td>
					<td>'.$grade_amount['data_25'].'</td>
					<td>'.$grade_amount['data_20'].'</td>
					<td>'.$grade_amount['data_15'].'</td>
					<td>'.$grade_amount['data_10'].'</td>
					<td>'.$grade_amount['data_00'].'</td>
					<td>'.$grade_higher_3.'</td>
					<td>'.$grade_higher_3_percentage.'</td>
					<td></td>
				</tr>
			';
			$order++;
			$amount_std_all=$amount_std_all+$amount_std;
			$grade_amount_40=$grade_amount_40+$grade_amount['data_40'];
			$grade_amount_35=$grade_amount_35+$grade_amount['data_35'];
			$grade_amount_30=$grade_amount_30+$grade_amount['data_30'];
			$grade_amount_25=$grade_amount_25+$grade_amount['data_25'];
			$grade_amount_20=$grade_amount_20+$grade_amount['data_20'];
			$grade_amount_15=$grade_amount_15+$grade_amount['data_15'];
			$grade_amount_10=$grade_amount_10+$grade_amount['data_10'];
			$grade_amount_00=$grade_amount_00+$grade_amount['data_00'];
			$grade_amount_higher_3=$grade_amount_higher_3+$grade_higher_3;
			$grade_amount_higher_3_percentage=$grade_amount_higher_3_percentage+$grade_higher_3_percentage;
		}
		$order--;
		$data_response.='
				<tr>
		        	<td colspan="3" style="font-weight:bold">รวม</td>
		        	<td>'.$amount_std_all.'</td>	
		        	<td>'.$grade_amount_40.'</td>
		        	<td>'.$grade_amount_35.'</td>
		        	<td>'.$grade_amount_30.'</td>
		        	<td>'.$grade_amount_25.'</td>
		        	<td>'.$grade_amount_20.'</td>
		        	<td>'.$grade_amount_15.'</td>
		        	<td>'.$grade_amount_10.'</td>
		        	<td>'.$grade_amount_00.'</td>
		        	<td>'.$grade_amount_higher_3.'</td>
		        	<td>'.number_format($grade_amount_higher_3_percentage/$order,2).'</td>
		        	<td></td>	
		        	
		        </tr>
		        <tr>
	            	<td colspan="3" style="font-weight:bold">ร้อยละ</td>
	            	<td>100.00</td>	
	            	<td>'.number_format(($grade_amount_40*100)/$amount_std_all,2).'</td>
	            	<td>'.number_format(($grade_amount_35*100)/$amount_std_all,2).'</td>
	            	<td>'.number_format(($grade_amount_30*100)/$amount_std_all,2).'</td>
	            	<td>'.number_format(($grade_amount_25*100)/$amount_std_all,2).'</td>
	            	<td>'.number_format(($grade_amount_20*100)/$amount_std_all,2).'</td>
	            	<td>'.number_format(($grade_amount_15*100)/$amount_std_all,2).'</td>
	            	<td>'.number_format(($grade_amount_10*100)/$amount_std_all,2).'</td>
	            	<td>'.number_format(($grade_amount_00*100)/$amount_std_all,2).'</td>
	            	<td></td>
	            	<td></td>
	            	<td></td>	
	            	
	            </tr>
	            <tr>
	            	<td colspan="4" style="font-weight:bold">ระดับผลการเรียน 3.0 ขึ้นไป คิดเป็นร้อยละ</td>
	            	<td colspan="3">'.number_format((($grade_amount_40+$grade_amount_35+$grade_amount_30)*100)/$amount_std_all,2).'</td>	
	            	<td colspan="5">'.number_format((($grade_amount_25+$grade_amount_20+$grade_amount_15+$grade_amount_10+$grade_amount_00)*100)/$amount_std_all,2).'</td>
	            	<td></td>
	            	<td></td>
	            	<td></td>	
	            	
	            </tr>
			';

		return $data_response;
	}
	public function get_grade_amount($department_set,$class_level,$year,$term){
		$this->sql ="SELECT *
						FROM tbl_sub_pp6
						WHERE status=1
						AND department=$department_set
						AND pp6_ID in(
							SELECT DataID
							FROM tbl_pp6
							WHERE class_level='$class_level'
							AND term='$term'
							AND year='$year'
							
						)
							";
			$this->select();
			$this->setRows();
			$data_00=0;
			$data_10=0;
			$data_15=0;
			$data_20=0;
			$data_25=0;
			$data_30=0;
			$data_35=0;
			$data_40=0;
			foreach($this->rows as $key => $value) {
				$score_total=$value['score_total'];
				if ($score_total!=-1) {
					$grade=$this->get_grade($score_total);
					if ($grade=='0.0') {
						$data_00++;
					}elseif($grade=='1.0'){
						$data_10++;
					}elseif($grade=='1.5'){
						$data_15++;
					}elseif($grade=='2.0'){
						$data_20++;
					}elseif($grade=='2.5'){
						$data_25++;
					}elseif($grade=='3.0'){
						$data_30++;
					}elseif($grade=='3.5'){
						$data_35++;
					}elseif($grade=='4.0'){
						$data_40++;
					}
				}elseif($score_total==-1){
					$data_00++;
				}
			}
			$data_response['data_00']=$data_00;
			$data_response['data_10']=$data_10;
			$data_response['data_15']=$data_15;
			$data_response['data_20']=$data_20;
			$data_response['data_25']=$data_25;
			$data_response['data_30']=$data_30;
			$data_response['data_35']=$data_35;
			$data_response['data_40']=$data_40;
			return $data_response;
		}
		public function get_amount_std($department_set,$class_level,$year,$term){
		$this->sql ="SELECT COUNT(*) as num_row
						FROM tbl_sub_pp6
						WHERE status=1
						AND department=$department_set
						AND pp6_ID in(
							SELECT DataID
							FROM tbl_pp6
							WHERE class_level='$class_level'
							AND term='$term'
							AND year='$year'
							
						)
							";
			$this->select();
			$this->setRows();
			return $this->rows[0]['num_row'];
		}
	public function get_level_data($class_level,$year,$term,$image_logo,$footer_text_cen_normal){
		if ($class_level=='p1' || $class_level=='p2' || $class_level=='p3' || $class_level=='p4' || $class_level=='p5' || $class_level=='p6') {
				$class_front_text='ประถมศึกษาปีที่';
			}else{
				$class_front_text='มัธยมศึกษาปีที่';
			}
		$loop_data=$this->get_loop_data($class_level,$year,$term);
		$data_response['std_list'].='
						<div style="page-break-after:always;">
					      <page >
					        <div style="text-align: center;line-height: 0.6;font-weight: bold;padding-top: 20px;font-size:16px">
					          <img class="logo-print-size-level" src="'.$image_logo.'">
					          <p >รายงานสรุปการพัฒนาคุณภาพผู้เรียนตามระดับชั้น</p>
					          <p >โรงเรียนเทศบาลวัดสระทอง สังกัดเทศบาลเมืองร้อยเอ็ด อ.เมือง จ.ร้อยเอ็ด</p>
					          <p>
					            <span style="margin-right: 20px;">ระดับชั้น 
					              <span style="font-weight: normal;">'.$class_front_text.' '.substr($class_level,1).'</span>
					            </span> 
					           
					            <span style="margin-right: 20px;">ภาคเรียนที่ 
						              <span style="font-weight: normal;">'.$term.'</span>
						            </span> 
					            <span>ปีการศึกษา <span style="font-weight: normal;">'.$year.'</span> </span>
					          </p>
					         
					        </div>
					        <table cellspacing="0"  style=" text-align: center; font-size: 14px;width:100%;margin-top: 20px;">
					          <thead>
					            <tr class="text-middle">
					              <th rowspan="2" class="rotate" style="width: 3%;height: 0px;text-align: center;">
					                <div >ที่</div>
					              </th>
					              <th rowspan="2" class="rotate" style="width: 10%;height: 0px;text-align: center;">
					                <div >รหัสวิชา</div>
					              </th>
					              <th rowspan="2" style="width: 25%;vertical-align: middle;text-align: center;">
					              	สาระการเรียนรู้
					              </th>
					              <th rowspan="2" class="rotate" style="width: 5%;height: 0px;text-align: center;">
					                <div >จำนวน นักเรียน</div>
					              </th>
					              <th colspan="8" class="rotate" style="width: 5%;height: 0px;text-align: center;">
					                <div >ระดับผลการเรียน</div>
					              </th>
					              <th colspan="2" class="rotate" style="width: 5%;height: 0px;text-align: center;">
					                <div >เกรด 3.0 ขึ้นไป</div>
					              </th>
					              <th rowspan="2" class="rotate" style="width: 5%;height: 0px;text-align: center;">
					                <div >หมายเหตุ</div>
					              </th>
					            </tr> 
					            <tr class="text-middle">
					            	<th rowspan="2" class="rotate" style="width: 5%;height: 0px;text-align: center;">
					                	4
					              	</th>
					            	<th rowspan="2" class="rotate" style="width: 5%;height: 0px;text-align: center;">
					                	3.5
					              	</th>
					              	<th rowspan="2" class="rotate" style="width: 5%;height: 0px;text-align: center;">
					                	3
					              	</th>
					              	<th rowspan="2" class="rotate" style="width: 5%;height: 0px;text-align: center;">
					                	2.5
					              	</th>
					              	<th rowspan="2" class="rotate" style="width: 5%;height: 0px;text-align: center;">
					                	2
					              	</th>
					              	<th rowspan="2" class="rotate" style="width: 5%;height: 0px;text-align: center;">
					                	1.5
					              	</th>
					              	<th rowspan="2" class="rotate" style="width: 5%;height: 0px;text-align: center;">
					                	1
					              	</th>
					              	<th rowspan="2" class="rotate" style="width: 5%;height: 0px;text-align: center;">
					                	0,ร
					              	</th>
					              	<th rowspan="2" class="rotate" style="width: 5%;height: 0px;text-align: center;">
					                	รวม
					              	</th>
					              	<th rowspan="2" class="rotate" style="width: 5%;height: 0px;text-align: center;">
					                	ร้อยละ
					              	</th>

					            </tr>
					          </thead>
					          <tbody >
					            '.$loop_data.'
					          </tbody>
					        </table>
					        <div style="margin-top:40px;">
					        	'.$footer_text_cen_normal.'
					        </div>
					      </page>
					    </div>
					   
			';
		return $data_response;
	}
	
	public function get_year(){
		$this->sql ="SELECT  distinct(year) as year
					FROM tbl_registed_course
					ORDER BY year DESC
							";
		$this->select();
		$this->setRows();
		foreach($this->rows as $key => $value) {
			$year=  $value['year'];	
			$data_response.='
					 <option value="'.$year.'">'.$year.'</option>
			';
		}
		return json_encode($data_response);
	}
	public function get_name_title($name_title_data){
		if ($name_title_data=="dekchai") {
			$name_title="เด็กชาย";
		}elseif($name_title_data=="dekying"){
			$name_title="เด็กหญิง";
		}elseif($name_title_data=="nai"){
			$name_title="นาย";
		}else{
			$name_title="นางสาว";
		}
		return $name_title;
	}
	public function get_class_level($class_level_data){
		if ($class_level_data=="p1") {
			$class_level="ป.1";
		}elseif($class_level_data=="p2"){
			$class_level="ป.2";	
		}elseif($class_level_data=="p3"){
			$class_level="ป.3";	
		}elseif($class_level_data=="p4"){
			$class_level="ป.4";	
		}elseif($class_level_data=="p5"){
			$class_level="ป.5";	
		}elseif($class_level_data=="p6"){
			$class_level="ป.6";	
		}elseif($class_level_data=="m1"){
			$class_level="ม.1";	
		}elseif($class_level_data=="m2"){
			$class_level="ม.2";	
		}elseif($class_level_data=="m3"){
			$class_level="ม.3";	
		}elseif($class_level_data=="m4"){
			$class_level="ม.4";	
		}elseif($class_level_data=="m5"){
			$class_level="ม.5";	
		}elseif($class_level_data=="m6"){
			$class_level="ม.6";	
		}
		return $class_level;
	}
	public function get_department($data){
		
		switch ($data) {
		    case 1:
		       	$department='ภาษาไทย';
		        break;
		    case 2:
		        $department='คณิตศาสตร์';
		        break;
		    case 3:
		        $department='วิทยาศาสตร์';
		        break;
		    case 31:
		        $department='วิทยาศาสตร์และเทคโนโลยี';
		        break;    
		    case 4:
		        $department='สังคมศึกษา ศาสนาและวัฒนธรรม';
		        break;
		    case 41:
		        $department='สังคมศึกษา';
		        break;
		    case 42:
		        $department='ภูมิศาสตร์';
		        break;
		    case 43:
		        $department='ประวัติศาสตร์';
		        break;
		    case 5:
		        $department='สุขศึกษาและพลศึกษา';
		        break;
		    case 6:
		        $department='ศิลปะ';
		        break;
		    case 7:
		        $department='การงานอาชีพฯ';
		        break; 
		    case 71:
		        $department='การงานอาชีพ';
		        break; 
		    case 8:
		        $department='ภาษาต่างประเทศ';
		        break;  
		    case 9:
		        $department='หน้าที่พลเมือง';
		        break;     
		    case 10:
		        $department='ศิลปะพื้นบ้าน';
		        break;     
		    case 11:
		        $department='ศักยภาพ';
		        break;     
		    case 12:
		        $department='ภาษาจีน';
		        break;        
		    default:
		     	$department='';
		}
		return $department;
	}
	public function get_grade($total){
		if ($total<50) {
			$grade='0.0';
		}elseif($total<55){
			$grade='1.0';
		}elseif($total<60){
			$grade='1.5';
		}elseif($total<65){
			$grade='2.0';
		}elseif($total<70){
			$grade='2.5';
		}elseif($total<75){
			$grade='3.0';
		}elseif($total<80){
			$grade='3.5';
		}elseif($total>=80){
			$grade='4.0';
		}
		return $grade;
	}
}<file_sep>/modules/regis_course_teaching/process.php
<?php
@ob_start();
@session_start();

require_once('../../init.php');
include('../../src/class.pagination.php');
include('../../src/class.inputfilter.php');
$InputFilter = new InputFilter();

##CLASS_DB_CONNECT##
include('class_modules.php');
$class_data = new ClassData();
##CLASS_DB_CONNECT##

if(isset($_GET['acc_action']) and $_GET['acc_action'] == "update_exam_mid_object"){	
	$data_id_first=$_GET['data_id_first'];
	$objective_conclude_id=$_GET['objective_conclude_id'];
	echo $class_data->update_exam_mid_object($data_id_first,$objective_conclude_id);
}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "update_exam_final_object"){	
	$data_id_first=$_GET['data_id_first'];
	$objective_conclude_id=$_GET['objective_conclude_id'];
	echo $class_data->update_exam_final_object($data_id_first,$objective_conclude_id);
}

if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_exam_object"){	
	$data_id_first=$_GET['data_id_first'];
	echo $class_data->get_exam_object($data_id_first);
}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_term_year_now"){	
	echo $class_data->get_term_year_now();
}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_teaching_student_only"){	
	$data_id=$_GET['data_id'];
	$data_room=$_GET['data_room'];
	
	echo $class_data->get_teaching_student_only($data_id,$data_room);
}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_course_teaching_student"){	
	$data_id=$_GET['data_id'];
	echo $class_data->get_course_teaching_student($data_id);
}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_propotion_objective"){	
	$data_id_first=$_GET['data_id_first'];
	echo $class_data->get_propotion_objective($data_id_first);
}

if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_objective_place_plus"){
	$data_responds='
		 <tr>
                          <td width="4%">ข้อที่</td>
                          <td width="7%">
                             <div class="input-group">
                              <input name="no_order_new[]"  type="text" class="form-control form-set-search exam_chk_dis"  aria-describedby="basic-addon1" value="">
                            </div> 
                          </td>
                          <td width="12%" style="padding-left: 30px;">ตัวชี้วัด</td>
                          <td width="40%" >
                            <div class="input-group" style="width: 100%;margin-left: -20px;">
                              <input  name="detail_new[]" type="text" class="form-control form-set-search exam_chk_dis"  aria-describedby="basic-addon1" value="">
                            </div> 
                          </td>
                          <td  width="25%">
                            <select id=""  name="object_list_data_new[]" class="form-control search-course-depart" style="width: 100%;">
                              <option value="1">ก่อนกลางภาค</option>              
                              <option value="2">หลังกลางภาค</option>
                            </select>
                          </td>
                          <td width="5%" style="padding-left: 30px;">คะแนน</td>
                          <td width="15%" style="padding-left: 5px;"> 
                             <div class="input-group">
                              <input name="score_data_new[]"  type="text" class="form-control form-set-search"  aria-describedby="basic-addon1" value="" >
                            </div> 
                          </td>
                          <td style="padding-left: 15px;">
                             <div id="btn_plus_objective" style="margin-top: -6px;" class="btn-search">
                              <span class="text-icon">+</span>
                            </div>  
                          </td>
                        </tr>
	';	
	echo json_encode($data_responds);
}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "plus_objective"){	
	
		$class_level_status=$_GET['class_level_status'];
		$no_order_new=$_GET['no_order_new'];
		$detail_new=$_GET['detail_new'];
		$object_list_data_new=$_GET['object_list_data_new'];
		$score_data_new=$_GET['score_data_new'];
		$user_id=$_SESSION['ss_user_id'];
		if ($class_level_status=='p') {
			$text_option_1='ก่อนวัดผลกลางปี';
			$text_option_2='หลังวัดผลกลางปี';
		}else{
			$text_option_1='ก่อนกลางภาค';
			$text_option_2='หลังกลางภาค';
		}

		for ($i=0; $i < count($no_order_new) ; $i++) {
		if ($object_list_data_new[$i]==1) {
				$object_list='
					<option selected value="1">'.$text_option_1.'</option>              
                    <option value="2">'.$text_option_2.'</option>
				';
		}elseif($object_list_data_new[$i]==2){
			$object_list='
					<option value="1">'.$text_option_1.'</option>              
                    <option selected value="2">'.$text_option_2.'</option>
				';
		}
		
		$data_responds.='
							
                                <tr>
		                          <td width="4%">ข้อที่</td>
		                          <td width="7%">
		                             <div class="input-group">
		                              <input name="no_order_new[]"  type="text" class="form-control form-set-search exam_chk_dis"  aria-describedby="basic-addon1" value="'.$no_order_new[$i].'">
		                            </div> 
		                          </td>
		                          <td width="12%" style="padding-left: 30px;">ตัวชี้วัด</td>
		                          <td width="40%" >
		                            <div class="input-group" style="width: 100%;margin-left: -20px;">
		                              <input  name="detail_new[]" type="text" class="form-control form-set-search exam_chk_dis"  aria-describedby="basic-addon1" value="'.$detail_new[$i].'">
		                            </div> 
		                          </td>
		                          <td  width="25%">
		                            <select id=""  name="object_list_data_new[]" class="form-control search-course-depart" style="width: 100%;">
		                              '.$object_list.'
		                            </select>
		                          </td>
		                          <td width="5%" style="padding-left: 30px;">คะแนน</td>
		                          <td width="15%" style="padding-left: 5px;"> 
		                             <div class="input-group">
		                              <input name="score_data_new[]"  type="text" class="form-control form-set-search"  aria-describedby="basic-addon1" value="'.$score_data_new[$i].'" >
		                            </div> 
		                          </td>
		                          <td style="padding-left: 15px;height: 35px;">
		                            
		                          </td>
		                        </tr>
		';
		}
	$data_responds.='
					<tr>
                          <td width="4%">ข้อที่</td>
                          <td width="7%">
                             <div class="input-group">
                              <input name="no_order_new[]"  type="text" class="form-control form-set-search exam_chk_dis"  aria-describedby="basic-addon1" value="">
                            </div> 
                          </td>
                          <td width="12%" style="padding-left: 30px;">ตัวชี้วัด</td>
                          <td width="40%" >
                            <div class="input-group" style="width: 100%;margin-left: -20px;">
                              <input  name="detail_new[]" type="text" class="form-control form-set-search exam_chk_dis"  aria-describedby="basic-addon1" value="">
                            </div> 
                          </td>
                          <td  width="25%">
                            <select id=""  name="object_list_data_new[]" class="form-control search-course-depart" style="width: 100%;">
                              <option value="1">'.$text_option_1.'</option>              
                              <option value="2">'.$text_option_2.'</option>
                            </select>
                          </td>
                          <td width="5%" style="padding-left: 30px;">คะแนน</td>
                          <td width="15%" style="padding-left: 5px;"> 
                             <div class="input-group">
                              <input name="score_data_new[]"  type="text" class="form-control form-set-search"  aria-describedby="basic-addon1" value="" >
                            </div> 
                          </td>
                          <td style="padding-left: 15px;">
                             <div id="btn_plus_objective" style="margin-top: -6px;" class="btn-search">
                              <span class="text-icon">+</span>
                            </div>  
                          </td>
                        </tr>
	';

	echo json_encode($data_responds);
}
if(isset($_POST['acc_action']) and $_POST['acc_action'] == "add_data_proportion"){
	$course_id=$_POST['course_id'];
		$arr_sql["courseID"]="'".chkhtmlspecialchars($InputFilter->clean_script(trim($course_id)))."'";		
		$arr_sql["cumulative_before_mid"]="'".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['cumulative_before_mid'])))."'";	
		$arr_sql["cumulative_after_mid"]="'".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['cumulative_after_mid'])))."'";	
		$arr_sql["mid_exam"]="'".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['mid_exam'])))."'";	
		$arr_sql["final_exam"]="'".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['final_exam'])))."'";	
		echo $class_data->insert_data_proportion($arr_sql,$course_id);	
}
if(isset($_POST['acc_action']) and $_POST['acc_action'] == "add_objective_conclude"){
	$course_id=$_POST['course_id'];
	$no_order_new=$_POST['no_order_new'];
	$detail_new=$_POST['detail_new'];
	$object_list_data_new=$_POST['object_list_data_new'];
	$score_data_new=$_POST['score_data_new'];
	for ($i=0; $i < count($no_order_new) ; $i++) {
			if ($no_order_new[$i]=="" || $detail_new[$i]=="") {			
			}else{
				$class_data->sql ="INSERT INTO tbl_objective_conclude(courseID,no_order,detail,proportion_status,score) VALUES($course_id,$no_order_new[$i],'$detail_new[$i]',$object_list_data_new[$i],$score_data_new[$i])";
	       		echo $class_data->query();		
			}			
		}
}

if(isset($_GET['acc_action']) and $_GET['acc_action'] == "chk_cumulative_over"){
	$course_id=$_GET['course_id'];

	$score_data =$_GET['score_data'];
	$object_list_data=$_GET['object_list_data'];

	$value_score_data = explode("-", $score_data);
	$value_object_list_data = explode("-", $object_list_data);

	$score_before_sql=0;
	$score_after_sql=0;
	for ($i=0; $i <count($value_score_data) ; $i++) { 
		if ($value_object_list_data[$i]==1) {
			$score_before_sql=$score_before_sql+$value_score_data[$i];
		}elseif($value_object_list_data[$i]==2){
			$score_after_sql=$score_after_sql+$value_score_data[$i];
		}
	}

	$score_data_new=$_GET['score_data_new'];
	$object_list_data_new=$_GET['object_list_data_new'];
	$cumulative_before_mid=$_GET['cumulative_before_mid'];
	$cumulative_after_mid=$_GET['cumulative_after_mid'];
	
	$score_data_before_new=0;
	$score_data_after_new=0;
	for ($i=0; $i < count($score_data_new) ; $i++) { 	
		if ($object_list_data_new[$i]==1) {
			$score_data_before_new=$score_data_before_new+$score_data_new[$i];
		}elseif($object_list_data_new[$i]==2){
			$score_data_after_new=$score_data_after_new+$score_data_new[$i];
		}
	}
	$score_before=$score_before_sql+$score_data_before_new;
	$score_after=$score_after_sql+$score_data_after_new;
	if ($score_before<=$cumulative_before_mid) {
		$data_responds['score_before']="pass";
	}else{
		$data_responds['score_before']="nopass";
	}
	
	if ($score_after<=$cumulative_after_mid) {
		$data_responds['score_after']="pass";
	}else{
		$data_responds['score_after']="nopass";
	}
	echo json_encode($data_responds);
}
if(isset($_POST['acc_action']) and $_POST['acc_action'] == "update_objective_conclude"){
	$course_id=$_POST['course_id'];
	$objective_data_all_id=$_POST['objective_data_all_id'];	
	$no_order=$_POST['no_order'];
	$detail=$_POST['detail'];
	$object_list_data=$_POST['object_list_data'];
	$score_data=$_POST['score_data'];
	
	$arr_id = explode("-", $objective_data_all_id);
			$class_data->sql ="SELECT  *
					FROM tbl_objective_conclude 
					WHERE courseID=$course_id
							";
			$class_data->select();
			$class_data->setRows();	
			foreach($class_data->rows as $key => $value) {
				$DataID=$value['DataID'];
				for ($i=0; $i < count($arr_id) ; $i++) { 
					if ($DataID==$arr_id[$i]) {
						$sql="UPDATE tbl_objective_conclude SET no_order=$no_order[$i],detail='$detail[$i]',proportion_status=$object_list_data[$i],score=$score_data[$i] WHERE DataID={$arr_id[$i]}";
						$class_data->sql =$sql;
	    			    $class_data->query();    			
					}
				}				
			}

}
if(isset($_POST['acc_action']) and $_POST['acc_action'] == "add_teaching"){	
		$course_id=$_POST['course_id'];
		$term_search=$_POST['term_search'];
		$year_search=$_POST['year_search'];
		
		echo $class_data->insert_data_teaching($course_id,$term_search,$year_search);

}
if(isset($_POST['acc_action']) and $_POST['acc_action'] == "data_remove_std"){
	$data_val = $_POST['data_val'];
	echo $class_data->data_remove_std($data_val);
}
if(isset($_POST['acc_action']) and $_POST['acc_action'] == "data_remove_objective"){
	$data_val = $_POST['data_val'];
	echo $class_data->data_remove_objective($data_val);
}
if(isset($_POST['acc_action']) and $_POST['acc_action'] == "data_remove"){
	$data_val = $_POST['data_val'];
	echo $class_data->get_data_delete($data_val);
}

if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_registed_course_teaching"){	
		echo $class_data->get_registed_course_teaching();

}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_std_list_new"){	
		$id_std_search=$_GET['id_std_search'];
		$search_class_modal=$_GET['search_class_modal'];
		$search_room_modal=$_GET['search_room_modal'];
		$course_id=$_GET['course_id'];
		$term_search=$_GET['term_search'];
		$year_search=$_GET['year_search'];
		
		echo $class_data->get_std_list($id_std_search,$search_class_modal,$search_room_modal,$course_id,$term_search,$year_search);

}
if(isset($_POST['acc_action']) and $_POST['acc_action'] == "data_add_std"){	
		$data_val = $_POST['data_val'];
		$course_id = $_POST['course_id'];
		$term_search = $_POST['term_search'];
		$year_search = $_POST['year_search'];
		echo $class_data->data_add_std($data_val,$course_id,$term_search,$year_search);

}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_std_list"){	
		$id_std_search=$_GET['id_std_search'];
		$search_class_modal=$_GET['search_class_modal'];
		$search_room_modal=$_GET['search_room_modal'];
		$course_id=$_GET['course_id'];
		
		echo $class_data->get_std_list($id_std_search,$search_class_modal,$search_room_modal,$course_id);

}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_name_to_add_std"){	
		$data_id_first=$_GET['data_id_first'];
		$registed_course_id=$_GET['registed_course_id'];
		$term_search=$_GET['term_search'];
		$year_search=$_GET['year_search'];
		
		echo $class_data->get_name_to_add_std($data_id_first,$registed_course_id,$term_search,$year_search);

}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "search_course_class"){	
		$department_search=$_GET['department_search'];
		$class_level_search=$_GET['class_level_search'];
		$term_search=$_GET['term_search'];
		$year_search=$_GET['year_search'];
		echo $class_data->search_course_class($department_search,$class_level_search,$term_search,$year_search);

}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "hide_class_std"){	
		$data_id_first=$_GET['data_id_first'];
		echo $class_data->hide_class_std($data_id_first);

}

if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_room_list"){	
		$data_id_first=$_GET['data_id_first'];
		$room_active=$_GET['room_active'];
		
		echo $class_data->get_room_list($data_id_first,$room_active);
}
<file_sep>/modules/conclusion/class_modules.php
<?php 
class ClassData extends Databases {
	public function get_data_list_department($class_level,$term_data,$year_data,$department_search){
			if ($class_level=='p') {
				$class_label='ประถมศึกษา';
			}else{

				$class_label='มัธศึกษา';
			}
			if ($term_data=='1,2') {
				$term='ปลายปี';	
			}else{
				$term=$term_data;
			}
			$department_text=$this->get_department($department_search);
			if ($class_level=='m' && $term_data!='1,2') {
				$data_response.='
					 <tr class="text-table-center">
					 	<td>'.$department_text.'</td>
						<td>'.$class_label.'</td>
						<td>'.$term.'</td>
						<td>'.$year_data.'</td>
						<td>
							<a target="_blank" 
								href="modules/conclusion/form/learning_result_department.php?class_level='.$class_level.'&term='.$term_data.'&year='.$year_data.'&department='.$department_search.'" style="color: #ac68cc;">
		                  		<span class="glyphicon glyphicon-print" aria-hidden="true"></span>
		                  	</a>
						</td>
					</tr>
			';
			}elseif ($class_level=='p' && $term_data=='1,2') {
				$data_response.='
					 <tr class="text-table-center">
					 	<td>'.$department_text.'</td>
						<td>'.$class_label.'</td>
						<td>'.$term.'</td>
						<td>'.$year_data.'</td>
						<td>
							<a target="_blank" 
								href="modules/conclusion/form/learning_result_department.php?class_level='.$class_level.'&term='.$term_data.'&year='.$year_data.'&department='.$department_search.'" style="color: #ac68cc;">
		                  		<span class="glyphicon glyphicon-print" aria-hidden="true"></span>
		                  	</a>
						</td>
					</tr>
			';
			}
		return json_encode($data_response);
	}
	public function get_data_list_rtw($class_level,$term_data,$year_data){
		$this->sql ="SELECT DISTINCT(class_level) as class_level,year,term
					FROM tbl_pp6
					WHERE class_level='$class_level'
					AND term='$term_data'
					AND year='$year_data'
						";
		$this->select();
		$this->setRows();
		foreach($this->rows as $key => $value) {
			$room=  $value['room'];	
			$class_level=  $value['class_level'];
			$class_label=$this->get_class_level($class_level);
			$term=$value['term'];		
			if ($term=='1,2') {
				$term='ปลายปี';	
			}	
			$year=$value['year'];		
			$data_response.='
					 <tr class="text-table-center">
						<td>'.$class_label.'</td>
						<td>'.$term.'</td>
						<td>'.$year.'</td>
						<td>
							<a target="_blank" 
								href="modules/conclusion/form/learning_result_rtw.php?class_level='.$class_level.'&term='.$term_data.'&year='.$year.'" style="color: #ac68cc;">
		                  		<span class="glyphicon glyphicon-print" aria-hidden="true"></span>
		                  	</a>
						</td>
					</tr>
			';
		}
	
		
		return json_encode($data_response);
	}
	public function get_data_list_desirable($class_level,$term_data,$year_data){
		$this->sql ="SELECT DISTINCT(class_level) as class_level,year,term
					FROM tbl_pp6
					WHERE class_level='$class_level'
					AND term='$term_data'
					AND year='$year_data'
						";
		$this->select();
		$this->setRows();
		foreach($this->rows as $key => $value) {
			$room=  $value['room'];	
			$class_level=  $value['class_level'];
			$class_label=$this->get_class_level($class_level);
			$term=$value['term'];		
			if ($term=='1,2') {
				$term='ปลายปี';	
			}	
			$year=$value['year'];		
			$data_response.='
					 <tr class="text-table-center">
						<td>'.$class_label.'</td>
						<td>'.$term.'</td>
						<td>'.$year.'</td>
						<td>
							<a target="_blank" 
								href="modules/conclusion/form/learning_result_desirable.php?class_level='.$class_level.'&term='.$term_data.'&year='.$year.'" style="color: #ac68cc;">
		                  		<span class="glyphicon glyphicon-print" aria-hidden="true"></span>
		                  	</a>
						</td>
					</tr>
			';
		}
	
		
		return json_encode($data_response);
	}
	public function get_data_list_level($class_level,$term_data,$year_data){
		$this->sql ="SELECT DISTINCT(class_level) as class_level,year,term
					FROM tbl_pp6
					WHERE class_level='$class_level'
					AND term='$term_data'
					AND year='$year_data'
						";
		$this->select();
		$this->setRows();
		foreach($this->rows as $key => $value) {
			$room=  $value['room'];	
			$class_level=  $value['class_level'];
			$class_label=$this->get_class_level($class_level);
			$term=$value['term'];		
			if ($term=='1,2') {
				$term='ปลายปี';	
			}	
			$year=$value['year'];		
			$data_response.='
					 <tr class="text-table-center">
						<td>'.$class_label.'</td>
						<td>'.$term.'</td>
						<td>'.$year.'</td>
						<td>
							<a target="_blank" 
								href="modules/conclusion/form/learning_result_level.php?class_level='.$class_level.'&term='.$term_data.'&year='.$year.'" style="color: #ac68cc;">
		                  		<span class="glyphicon glyphicon-print" aria-hidden="true"></span>
		                  	</a>
						</td>
					</tr>
			';
		}
	
		
		return json_encode($data_response);
	}
	public function get_data_list_learning($class_level,$room_data,$term_data,$year_data){
		if ($term_data=='mid') {
			$this->sql ="SELECT DISTINCT(room) as room,class_level,year
						FROM tbl_pp6_mid
						WHERE class_level='$class_level'
						AND room='$room_data'
						AND term='1,2'
						AND year='$year_data'
							";
			$this->select();
			$this->setRows();
			foreach($this->rows as $key => $value) {
				$room=  $value['room'];	
				$class_level=  $value['class_level'];
				$class_label=$this->get_class_level($class_level);
				$term=  'กลางปี';	
				$year=  $value['year'];		
				$data_response.='
						 <tr class="text-table-center">
							
							<td>'.$class_label.'</td>
							<td>'.$room.'</td>
							<td>'.$term.'</td>
							<td>'.$year.'</td>
							<td>
								<a target="_blank" 
									href="modules/conclusion/form/learning_result_mid.php?class_level='.$class_level.'&room='.$room.'&term=mid&year='.$year.'" style="color: #ac68cc;">
			                  		<span class="glyphicon glyphicon-print" aria-hidden="true"></span>
			                  	</a>
							</td>
						</tr>
				';
			}
		}else{
			$this->sql ="SELECT DISTINCT(room) as room,class_level,term,year
						FROM tbl_pp6
						WHERE class_level='$class_level'
						AND room='$room_data'
						AND term='$term_data'
						AND year='$year_data'
							";
			$this->select();
			$this->setRows();
			foreach($this->rows as $key => $value) {
				$room=  $value['room'];	
				$class_level=  $value['class_level'];
				$class_label=$this->get_class_level($class_level);
				$year=  $value['year'];	
				if ($class_level=='p1' || $class_level=='p2' || $class_level=='p3' || $class_level=='p4' || $class_level=='p5' || $class_level=='p6') {
					$term='ปลายปี';
					$link='modules/conclusion/form/learning_result_final_p.php?class_level='.$class_level.'&room='.$room.'&term=1,2&year='.$year.'';
				}else{
					$term=  $value['term'];
					$link='modules/conclusion/form/learning_result_final_m.php?class_level='.$class_level.'&room='.$room.'&term='.$term.'&year='.$year.'';
				}
					
				$data_response.='
						 <tr class="text-table-center">
						
							<td>'.$class_label.'</td>
							<td>'.$room.'</td>
							<td>'.$term.'</td>
							<td>'.$year.'</td>
							<td>
								<a target="_blank" href="'.$link.'" style="color: #ac68cc;">
			                  		<span class="glyphicon glyphicon-print" aria-hidden="true"></span>
			                  	</a>
							</td>
						</tr>
				';
			}
		}
		
		return json_encode($data_response);
	}
	public function get_year(){
		$this->sql ="SELECT  distinct(year) as year
					FROM tbl_registed_course
					ORDER BY year DESC
							";
		$this->select();
		$this->setRows();
		foreach($this->rows as $key => $value) {
			$year=  $value['year'];	
			$data_response.='
					 <option value="'.$year.'">'.$year.'</option>
			';
		}
		return json_encode($data_response);
	}
	public function get_name_title($name_title_data){
		if ($name_title_data=="dekchai") {
			$name_title="เด็กชาย";
		}elseif($name_title_data=="dekying"){
			$name_title="เด็กหญิง";
		}elseif($name_title_data=="nai"){
			$name_title="นาย";
		}else{
			$name_title="นางสาว";
		}
		return $name_title;
	}
	public function get_department($data){
		
		switch ($data) {
		    case 1:
		       	$department='ภาษาไทย';
		        break;
		    case 2:
		        $department='คณิตศาสตร์';
		        break;
		    case 3:
		        $department='วิทยาศาสตร์';
		        break;
		    case 31:
		        $department='วิทยาศาสตร์และเทคโนโลยี';
		        break;    
		    case 4:
		        $department='สังคมศึกษา ศาสนาและวัฒนธรรม';
		        break;
		    case 41:
		        $department='สังคมศึกษา';
		        break;
		    case 42:
		        $department='ภูมิศาสตร์';
		        break;
		    case 43:
		        $department='ประวัติศาสตร์';
		        break;
		    case 5:
		        $department='สุขศึกษาและพลศึกษา';
		        break;
		    case 6:
		        $department='ศิลปะ';
		        break;
		    case 7:
		        $department='การงานอาชีพฯ';
		        break; 
		    case 71:
		        $department='การงานอาชีพ';
		        break; 
		    case 8:
		        $department='ภาษาต่างประเทศ';
		        break;  
		    case 9:
		        $department='หน้าที่พลเมือง';
		        break;     
		    case 10:
		        $department='ศิลปะพื้นบ้าน';
		        break;     
		    case 11:
		        $department='ศักยภาพ';
		        break;     
		    case 12:
		        $department='ภาษาจีน';
		        break;        
		    default:
		     	$department='';
		}
		return $department;
	}
	public function get_class_level($class_level_data){
		if ($class_level_data=="p1") {
			$class_level="ป.1";
		}elseif($class_level_data=="p2"){
			$class_level="ป.2";	
		}elseif($class_level_data=="p3"){
			$class_level="ป.3";	
		}elseif($class_level_data=="p4"){
			$class_level="ป.4";	
		}elseif($class_level_data=="p5"){
			$class_level="ป.5";	
		}elseif($class_level_data=="p6"){
			$class_level="ป.6";	
		}elseif($class_level_data=="m1"){
			$class_level="ม.1";	
		}elseif($class_level_data=="m2"){
			$class_level="ม.2";	
		}elseif($class_level_data=="m3"){
			$class_level="ม.3";	
		}elseif($class_level_data=="m4"){
			$class_level="ม.4";	
		}elseif($class_level_data=="m5"){
			$class_level="ม.5";	
		}elseif($class_level_data=="m6"){
			$class_level="ม.6";	
		}
		return $class_level;
	}
}<file_sep>/modules/login/login.js
function resetForm(form_id)
{
	$('#'+form_id)[0].reset();
}

$(function(){

	$('#submit__data').click(function(e){
		e.preventDefault();
		AccessLogin();
		return false;
	});

	$(window).keypress(function(e) {
	    if(e.keyCode == 13) {
			AccessLogin();
			return false;
	    }
	});	
});



function AccessLogin(){

		$('#alert__panel').hide();
		
		if(!$('#username').val()){
			$('#username').focus();
			return false;
		}
		if(!$('#password').val()){
			$('#password').focus();
			return false;
		}

		var formData = $( "#form__data" ).serializeArray();
		// formData.push({ "name": "acc_action", "value": "sale_orders_list" }); 
		// console.log($.param(formData));

		$.post("modules/login/process.php?t="+ new Date().getTime(), formData, function(data, textStatus, xhr) {
			console.log(data);
		});

		$.ajax({
	      type: "POST",
	      dataType: "json",
	      url: "modules/login/process.php?t="+ new Date().getTime(), //Relative or absolute path to response.php file
	      data: formData,
	      success: function(data) {
	    	//console.log(data.success);
	    	//alert(data.pass_birth)
	    	//alert(data.success)
	    	if (data.success == '1') {
	    		if (data.status=='1') {
	    			window.location = 'index.php';
	    		}else{
	    			window.location = 'index.php?op=chk_grade-index';
	    		}
	    		
	    	}else{
	    		$('#alert__panel').show();
	    		$('#alert__panel').html(data.error);
	    		// resetForm('form__data');
	    	}

	      }
	    });

		// $.ajax({
		// 	url: "modules/login/process.php?t="+ new Date().getTime(),
		// 	dataType: "json",
		// 	type: 'POST',
		// 	data: formData,
		// 	error: function(data){
		// 		console.log('An error has occurred');
		// 		$('#alert__panel').html('An error has occurred');
		// 	},
		// 	success: function (data) {
		//     	console.log(data.success);
		//     	if (data.success == '1') {
		//     		// window.location.assign('index.php');
		//     	}else{
		//     		$('#alert__panel').show();
		//     		$('#alert__panel').html(data.error);
		//     		// resetForm('form__data');
		//     	}
		// 	}
		// });
		
}<file_sep>/modules/report/person_m_form.php
<link href="../../assets/css/bootstrap.css" rel="stylesheet" type="text/css">
<link href="../../assets/css/custom.css" rel="stylesheet" type="text/css">
<link href="../../assets/css/margin-padding.css" rel="stylesheet" type="text/css">
<link href="../../assets/css/responsive.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
 table {
    border-collapse: collapse;
}

td, th {
    border: 1px solid black;
    padding: 5px;
}
-->
</style>
<?php
 @session_start();
    include('logo.php');
    require_once('../../init.php');
    include('class_modules.php');
    $class_data = new ClassData();
  ?>
<page orientation="portrait">
    <p class="text-bold" style="margin-left: 710px;font-size: 22px;margin-top: 25px;">ปพ.6</p>
    <img style="margin :10px 0px 10px 320px;display:block;width: 120px;height: 120px;"src="<?php echo $image_logo ?>">
   	<br>
   	<div class="col-sm-12 text-center " style="font-size: 22px;margin-top: -5px;">
      <p class="text-bold" style="margin-top: -8px;">รายงานการพัฒนาคุณภาพผู้เรียนเป็นรายบุคคล</p>
      <p class="text-bold " style="margin-top: -8px;">โรงเรียนเทศบาลวัดสระทอง</p>
    </div>
      <table cellspacing="0" style="width: 94%; text-align: center; font-size: 22px;margin-left:10px;border: 1px solid black;margin-top: 20px;">
        <thead>
          <tr>
            <td style="border: none;"><span class="text-bold">ชื่อ - สกุล</span> เด็กชายสมหมาย สุขสบาย</td>
            <td style="border: none;"><span class="text-bold">มัธยมศึกษาปีที่</span> 1/1</td>
            <td style="border: none;"><span class="text-bold">เลขที่</span> 1</td>
            <td style="border: none;"><span class="text-bold">เลขประจำตัวนักเรียน</span> 00010</td>
          </tr>
        </thead>
         <tr>
            <td style="padding-left: 35px;border: none;"><span class="text-bold">เลขประจำตัวประชาชน</span> 1234567890123</td>
            <td style="border: none;"><span class="text-bold">ภาคเรียนที่</span> 1</td>
            <td style="border: none;"><span class="text-bold">ปีการศึกษา</span> 2560</td>
          </tr>
      </table>
     <table cellspacing="0" style="width: 94%; text-align: center; font-size: 18px;margin-left:50px;border: 1px solid black;margin-top: 35px;">
              <thead style="font-weight: bold;">
                
                <tr style="background-color: #e0e0e0;">
                  
                  <td rowspan="2" style="width: 6%;">ที่</td>
                  <td colspan="5" style="width: 40%;">ภาคเรียนที่1</td>
                  <td rowspan="2" style="width: 8%;"><div style="rotate:90;margin-left: -12px;">หมายเหตุ</div></td>
               
                </tr>
                <tr style="background-color: #e0e0e0;">
                 <td style="border-left: none;width: 25%;">รายวิชา</td>
                 <td style="width: 14%;">รหัสวิชา</td>
                 <td style="width: 14%;">หน่วยกิต</td>
                 <td style="width: 14%;">คะแนน</td>
                 <td style="width: 14%;">GPA</td>
                </tr>
               
              </thead>
              <tbody>
                <tr>
                  <td>1</td>
                  <td style="text-align: left;">ภาษาไทย</td>
                  <td>ท11001</td>
                  <td>1</td>
                  <td>90</td>
                  <td>4.00</td>
                  <td></td>
                </tr>
                <tr>
                  <td>1</td>
                  <td style="text-align: left;">คณิตศาสตร์</td>
                  <td>ค11001</td>
                  <td>1</td>
                  <td>90</td>
                  <td>4.00</td>
                  <td></td>
                </tr>
                <tr>
                  <td>1</td>
                  <td style="text-align: left;">คณิตศาสตร์เพิ่มเติม</td>
                  <td>ค11002</td>
                  <td>1</td>
                  <td>90</td>
                  <td>4.00</td>
                  <td></td>
                </tr>
                <tr>
                  <td>1</td>
                  <td style="text-align: left;">วิทยาศาสตร์</td>
                  <td>ว11001</td>
                  <td>1</td>
                  <td>90</td>
                  <td>4.00</td>
                  <td></td>
                </tr>
                <tr>
                  <td>1</td>
                  <td style="text-align: left;">วิทยาศาสตร์เพิ่มเติม</td>
                  <td>ว11002</td>
                  <td>1</td>
                  <td>90</td>
                  <td>4.00</td>
                  <td></td>
                </tr>
                <tr>
                  <td>1</td>
                  <td style="text-align: left;">สังคมศึกษา ศาสนาและวัฒนธรรม</td>
                  <td>ส11001</td>
                  <td>1</td>
                  <td>90</td>
                  <td>4.00</td>
                  <td></td>
                </tr>
                <tr>
                  <td>1</td>
                  <td style="text-align: left;">สุขศึกษา</td>
                  <td>พ11001</td>
                  <td>1</td>
                  <td>90</td>
                  <td>4.00</td>
                  <td></td>
                </tr>
                <tr>
                  <td>1</td>
                  <td style="text-align: left;">ภาษาอังกฤษ</td>
                  <td>อ11001</td>
                  <td>1</td>
                  <td>90</td>
                  <td>4.00</td>
                  <td></td>
                </tr>
                <tr>
                  <td>1</td>
                  <td style="text-align: left;">การงานอาชีพและเทคโนโลยี</td>
                  <td>ง11001</td>
                  <td>1</td>
                  <td>90</td>
                  <td>4.00</td>
                  <td></td>
                </tr>
               <tr>
                  <td>1</td>
                  <td>คอมพิวเตอร์</td>
                  <td>ง11010</td>
                  <td>1</td>
                  <td>90</td>
                  <td>4.00</td>
                  <td></td>
                </tr>
                <tr style="font-weight: bold;">
                  <td colspan="3">รวม</td>
                  <td>10</td>
                  <td>920</td>
                  <td>4.00</td>
                  <td></td>
                  
                </tr>
                <tr style="background-color:#e0e0e0; ">
                  <td></td>
                  <td >กิจกรรมพัฒนาผู้เรียน</td>
                  <td>รหัสวิชา</td>
                  <td>หน่วยกิต</td>
                  <td>คะแนน</td>
                  <td>ผลการประเมิน</td>
                  <td></td>
                  
                </tr>
                <tr>
                  <td>1</td>
                  <td >แนะแนว</td>
                  <td>ก11001</td>
                  <td>-</td>
                  <td>-</td>
                  <td>ผ่าน</td>
                  <td></td>
                  
                </tr>
                <tr>
                  <td>2</td>
                  <td >ลูกเสือ เนตรนาร</td>
                  <td>ก11002</td>
                  <td>-</td>
                  <td>-</td>
                  <td>ผ่าน</td>
                  <td></td>
                  
                </tr>
                <tr>
                  <td>3</td>
                  <td >ชุมนุมคอมพิวเตอร์</td>
                  <td>ก11003</td>
                  <td>-</td>
                  <td>-</td>
                  <td>ผ่าน</td>
                  <td></td>
                  
                </tr>
                <tr>
                  <td>4</td>
                  <td >กิจกรรมเพื่อสังคม</td>
                  <td>ก11004</td>
                  <td>-</td>
                  <td>-</td>
                  <td>ผ่าน</td>
                  <td></td>
                  
                </tr>
                <tr style="font-weight: bold;">
                  <td colspan="3">รวม</td>
                  <td>-</td>
                  <td>-</td>
                  <td>ผ่าน</td>
                  <td></td>
                  
                </tr>
              </tbody>
    </table> 
  
</page>

<page orientation="portrait">
    <p class="text-bold" style="margin-left: 710px;font-size: 22px;margin-top: 25px;">ปพ.6</p>    
    <br>

     <table cellspacing="0" style="width: 94%; text-align: center; font-size: 18px;margin-left:50px;border: 1px solid black;margin-top: 10px;">
              <thead style="font-weight: bold;">
                
                <tr style="background-color: #e0e0e0;">                  
                  <td colspan="3" style="width: 4%;">ผลการประเมินคุณลักษณะอันพึงประสงค์</td>            
                </tr>
                <tr style="background-color: #e0e0e0;">
                  <td style="width: 6%">ที่</td>
                  <td style="width: 65%;">คุณลักษณะอันพึงประสงค์</td>
                  <td style="width: 24%;">ผลการประเมิน</td>
      
                </tr>              
              </thead>
              <tbody>
                <tr>
                  <td>1</td>
                  <td style="text-align: left;">รักชาติ ศาสน์ กษัตริย์</td>
                  <td>3</td>                 
                </tr>
                <tr>
                  <td>2</td>
                  <td style="text-align: left;">ซื่อสัตย์สุจริต</td>
                  <td>3</td>                 
                </tr>
                <tr>
                  <td>3</td>
                  <td style="text-align: left;">มีวินัย</td>
                  <td>3</td>                 
                </tr>
                <tr>
                  <td>4</td>
                  <td style="text-align: left;">ใฝ่เรียนรู้</td>
                  <td>3</td>                 
                </tr>
                <tr>
                  <td>5</td>
                  <td style="text-align: left;">อยู่อย่างพอเพียง</td>
                  <td>3</td>                 
                </tr>
                <tr>
                  <td>6</td>
                  <td style="text-align: left;">มุ่งมั่นในการทำงาน</td>
                  <td>3</td>                 
                </tr>
                <tr>
                  <td>7</td>
                  <td style="text-align: left;">รักความเป็นไทย</td>
                  <td>3</td>                 
                </tr>
                <tr>
                  <td>8</td>
                  <td style="text-align: left;">มีจิตสาธารณะ</td>
                  <td>3</td>                 
                </tr>
                <tr style="font-weight: bold;">
                  <td colspan="2">สรุปผลการประเมิน</td>
                  <td>3</td>                 
                </tr>
              </tbody>
    </table> 
    <table cellspacing="0" style="width: 94%; text-align: center; font-size: 18px;margin-left:50px;border: 1px solid black;margin-top: 35px;">
             <thead style="font-weight: bold;">
                
                <tr style="background-color: #e0e0e0;">                  
                  <td colspan="3" style="width: 4%;">ผลการประเมินการอ่าน&nbsp;เขียน&nbsp;คิดวิเคราะห์</td>            
                </tr>
                <tr style="background-color: #e0e0e0;">
                  <td style="width: 6%">ที่</td>
                  <td style="width: 65%;">การอ่าน&nbsp;เขียน&nbsp;คิดวิเคราะห์</td>
                  <td style="width: 24%;">ผลการประเมิน</td>
      
                </tr>              
              </thead>
              <tbody>
                <tr>
                  <td>1</td>
                  <td style="text-align: left;">การอ่าน</td>
                  <td>3</td>                 
                </tr>
                <tr>
                  <td>2</td>
                  <td style="text-align: left;">การเขียน</td>
                  <td>3</td>                 
                </tr>
                <tr>
                  <td>3</td>
                  <td style="text-align: left;">การคิด วิเคราะห์</td>
                  <td>3</td>                 
                </tr>
               
                <tr style="font-weight: bold;">
                  <td colspan="2">สรุปผลการประเมิน</td>
                  <td>3</td>                 
                </tr>
              </tbody>
    </table> 
    <table cellspacing="0" style="width: 94%; text-align: center; font-size: 18px;margin-left:50px;border: 1px solid black;margin-top: 35px;">
             <thead style="font-weight: bold;">
                
                <tr style="background-color: #e0e0e0;">                  
                  <td colspan="6" style="width: 4%;">สรุปผลการประเมิน</td>            
                </tr>
                <tr style="background-color: #e0e0e0;">
                  <td style="width: 6%">ผลการเรียนเฉลี่ย</td>
                  <td style="width: 6%">ผลการเรียนเฉลี่ย สะสม</td>
                  <td style="width: 6%;">ลำดับที่<br>ในห้องเรียน</td>
                  <td style="width: 6%;">กิจกรรมพัฒนา ผู้เรียน</td>
                  <td style="width: 6%;">คุณลักษณะอันพึง ประสงค์</td>
                  <td style="width: 6%;">อ่าน&nbsp;เขียน คิดวิเคราะห์</td>
                
                </tr>              
              </thead>
              <tbody>
                <tr>
                  <td style="width: 16%">4.00</td>
                  <td style="width: 16%">4.00</td>
                  <td style="width: 16%">1</td>    
                  <td style="width: 16%">ผ่าน</td>  
                  <td style="width: 16%">3</td>  
                  <td style="width: 16%">3</td>               
                </tr>
               
              </tbody>
             
    </table> 
     <div style="margin-left: 120px;margin-top: 40px;font-size: 16px;">
                <p>.................................................................ครูประจำชั้น </p>
               
                <p style="margin-left: 2px;">(</p> <p style="margin-top: -24px;margin-left:160px;"> )</p>

                <p style="margin-left: 12px;">................/................/...................</p>
              </div>
               <div style="margin-left: 420px;margin-top: -74px;font-size: 16px;">
                <p>.................................................................ผู้ปกครอง </p>
               
                <p style="margin-left: 2px;">(</p> <p style="margin-top: -24px;margin-left:170px;"> )</p>

                <p style="margin-left: 12px;">................/................/...................</p>
              </div>
              <div style="margin-left: 420px;margin-top: 55px;font-size: 16px;">
                <p>.................................................................ผู้อำนวยการ</p>
               
                <p style="margin-left: 2px;">(</p> <p style="margin-top: -24px;margin-left:140px;"> )</p>

                <p style="margin-left: 12px;">................/................/...................</p>
              </div>
</page>
<file_sep>/js/event.js
$(document).delegate('.btn-lang', 'click', function(event) {
	var lang = $(this).attr('data-id');
	var formData = new Array();
	formData.push({ "name": "action", "value": "change_lang" }); 
	formData.push({ "name": "lang", "value": lang }); 

    $.post('modules/lang/process.php', formData, function(data, textStatus, xhr) {
    	window.location.reload();
    });

});<file_sep>/modules/mobile_api/host/login.php
<?php	
	@session_start();

	require_once('config.php');
	require_once('src/database.php');
	include('class_modules.php');
	$class_data = new ClassData();
	##CLASS_DB_CONNECT##
	$condition = false;
	$num=  $class_data->rows[0]['num'];		
	$json = json_decode(file_get_contents('php://input'), true);
	$txt_username=$json['username'];
	$txt_password=$json['<PASSWORD>'];
	$chk_int=is_numeric($json['username']);
	$chk_pass=strlen($txt_password);
	if (!empty($txt_username) && !empty($txt_password)) {
		if ($chk_int==true ) {
			if ($chk_pass==8) {
				$day=substr($txt_password, 0, 2);
				$month=substr($txt_password, 2, 2);
				$year=substr($txt_password, 4,4);
				$year_set=$year-543;
				$pass_birth=$year_set.'-'.$month.'-'.$day;
				//$response['pass_birth'] = $pass_birth;
				$sql = " SELECT count(std_ID) as data_total FROM tbl_student WHERE std_ID = '{$txt_username}' AND birthday = '$pass_birth'";
				$class_data->sql = $sql;
				$class_data->select();
				$class_data->setRows();
				$dataidtotal = (int)$class_data->rows[0]['data_total'];
				$condition = ($dataidtotal > 0) ? true : false;
			}	
		}	
	}
	if ($condition == true) {
		$day=substr($txt_password, 0, 2);
		$month=substr($txt_password, 2, 2);
		$year=substr($txt_password, 4,4);
		$year_set=$year-543;
		$pass_birth=$year_set.'-'.$month.'-'.$day;
		$sql = " SELECT std_ID,name_title,fname,lname,room,class_level FROM tbl_student WHERE std_ID = '{$txt_username}' AND birthday = '$pass_birth'";
		$class_data->sql = $sql;
		$class_data->select();
		$class_data->setRows();
		$data_res['status']=1;
		$data_res['std_ID']=$class_data->rows[0]['std_ID'];
		
		$name_title_data=$class_data->rows[0]['name_title'];
		if ($name_title_data=="dekchai") {
			$name_title="เด็กชาย";
		}elseif($name_title_data=="dekying"){
			$name_title="เด็กหญิง";
		}elseif($name_title_data=="nai"){
			$name_title="นาย";
		}elseif($name_title_data=="nangsaw"){
			$name_title="นางสาว";
		}
		$fname=$class_data->rows[0]['fname'];
		$lname=$class_data->rows[0]['lname'];
		$data_res['name']=$name_title.$fname.' '.$lname;
		$class_level_data=$class_data->rows[0]['class_level'];
		if ($class_level_data=="p1") {
			$class_level="ป.1";
		}elseif($class_level_data=="p2"){
			$class_level="ป.2";	
		}elseif($class_level_data=="p3"){
			$class_level="ป.3";	
		}elseif($class_level_data=="p4"){
			$class_level="ป.4";	
		}elseif($class_level_data=="p5"){
			$class_level="ป.5";	
		}elseif($class_level_data=="p6"){
			$class_level="ป.6";	
		}elseif($class_level_data=="m1"){
			$class_level="ม.1";	
		}elseif($class_level_data=="m2"){
			$class_level="ม.2";	
		}elseif($class_level_data=="m3"){
			$class_level="ม.3";	
		}elseif($class_level_data=="m4"){
			$class_level="ม.4";	
		}elseif($class_level_data=="m5"){
			$class_level="ม.5";	
		}elseif($class_level_data=="m6"){
			$class_level="ม.6";	
		}
		$data_res['class_level']=$class_level;
		$data_res['room']=$class_data->rows[0]['room'];

	}else{
		$data_res['status']=0;
	}
	echo json_encode($data_res);


 ?>
<file_sep>/modules/login/process.php
<?php 
@ob_start();
@session_start();
// require_once('../../config.php');
require_once('../../init.php');

##CLASS_DB_CONNECT##
$db = new Databases();
##CLASS_DB_CONNECT##

$response = array();

$condition = false;
$txt_username = $_REQUEST['username'];
$txt_password = $_REQUEST['password'];

$chk_int=is_numeric($_REQUEST['username']);

if (!empty($txt_username) && !empty($txt_password)) {
	if ($chk_int==true) {
			$day=substr($txt_password, 0, 2);
			$month=substr($txt_password, 2, 2);
			$year=substr($txt_password, 4,4);
			$year_set=$year-543;
			$pass_birth=$year_set.'-'.$month.'-'.$day;
			//$response['pass_birth'] = $pass_birth;
			$sql = " SELECT count(std_ID) as data_total FROM tbl_student WHERE std_ID = '{$txt_username}' AND birthday = '$pass_birth'";
	}else{
		$sql = " SELECT count(positionID) as data_total FROM tbl_regis_teacher WHERE username = '{$txt_username}' AND password = MD5('{$txt_password}') AND status_alive=1";
	}
	$db->sql = $sql;
	$db->select();
	$db->setRows();
	$dataidtotal = (int)$db->rows[0]['data_total'];
	$condition = ($dataidtotal > 0) ? true : false;
}
if ($condition == true) {
	if ($chk_int==true) {
		$day=substr($txt_password, 0, 2);
		$month=substr($txt_password, 2, 2);
		$year=substr($txt_password, 4,4);
		$year_set=$year-543;
		$pass_birth=$year_set.'-'.$month.'-'.$day;
		$sql = " SELECT std_ID,fname,lname FROM tbl_student WHERE std_ID = '{$txt_username}' AND birthday = '$pass_birth' ";
		$db->sql = $sql;
		$db->select();
		$db->setRows();
		$_SESSION['ss_user_id'] = $db->rows[0]['std_ID'];
		$_SESSION['ss_fname'] = $db->rows[0]['fname'];
		$_SESSION['ss_lname'] = $db->rows[0]['lname'];
		$_SESSION['ss_status_std'] = 1;
		$response['status'] = '0';
	}else{
		$sql = " SELECT DataID,positionID,fname_th,lname_th,email,status,status_rang FROM tbl_regis_teacher WHERE username = '{$txt_username}' AND password = MD5('{<PASSWORD>}') AND status_alive=1";
		$db->sql = $sql;
		$db->select();
		$db->setRows();
		$_SESSION['ss_user_id'] = $db->rows[0]['DataID'];
		$_SESSION['ss_username'] = $db->rows[0]['positionID'];
		$_SESSION['ss_fname_th'] = $db->rows[0]['fname_th'];
		$_SESSION['ss_lname_th'] = $db->rows[0]['lname_th'];
		$_SESSION['ss_email'] = $db->rows[0]['email'];
		$_SESSION['ss_status'] = $db->rows[0]['status'];
		$_SESSION['ss_status_rang'] = $db->rows[0]['status_rang'];
		$response['status'] = '1';
	}
	$response['success'] = '1';
	$response['error'] = '';
}else{
	$response['success'] = '0';
	$response['error'] = " <strong>Username or Password incorrect</strong>";
}

echo json_encode($response);



?><file_sep>/src/#class.userauthen.php
<?php

// API authen

class UserAuthen 
{
	public $DB;
	public $BY;
	
	public function __construct()
	{
		$this->DB = new Databases();
		
		$this->BY = ($_SESSION['ssADMIN_ID'])? $_SESSION['ssADMIN_ID']: null;
	}

	public function __escape($inputVar)
	{
		return mysql_real_escape_string(addslashes(htmlentities($inputVar, ENT_QUOTES))); 	
	}
	
	public function login( $user=null, $pass=null )
	{
		$where = ' where ';
		$where .= ' a.username = "'.self::__escape($user).'" and a.password = "'.self::__escape($pass).'" and a.status=1 ';
		
		$this->DB->sql = 'select a.*,b.role_name from ath_users as a left join ath_roles as b on (a.role_id=b.role_id) '. $where .' limit 0,1 ';
		$this->DB->select();
		$result = $this->DB->getRows();
		if($result){
			return $result[0];
		}
		return null;
		
	}

	public function task( $task_key=null, $user_id=null )
	{
		$tasks = self::ath_tasks($task_key);
		$user_id = (!$user_id)? $this->BY: $user_id;
	
		$where = ' where ';
		$where .= ' task_id = "'.self::__escape($tasks['task_id']).'" and user_id = "'.self::__escape($user_id).'" ';
		
		$this->DB->sql = 'select * from ath_user_reletion_tasks '. $where .' limit 0,1 ';
		$this->DB->select();
		$result = $this->DB->getRows();
		
		if($result){
			return true;
		}
		else{
			return false;
		}
	}

	public function menu_authen()
	{
		$this->DB->sql = 'SELECT fun_id FROM ath_tasks as a LEFT JOIN ath_user_reletion_tasks as b on(a.task_id=b.task_id) WHERE b.user_id='.$this->BY.' GROUP BY a.fun_id ';
		$this->DB->select();
		$result = $this->DB->getRows();
		
		foreach( $result as $rs ){
			$data[] = $rs['fun_id'];
		}
		
		return $data;	
		/* $result = self::ath_main_function();
		if(!$result){
			return false;
		}
		// Result
		foreach( $result as $rs ){
			$data[$rs['fun_id']] = $rs['fun_name'];
		}		
		return $data;	 */
	}
	
	public function view_tasks()
	{
		$result = self::ath_tasks();
		if(!$result){
			return false;
		}
		// Result
		foreach( $result as $rs ){
			$data[$rs['task_key']] = $rs['task_description'];
		}		
		return $data;
	}
	
	/* public function logout( $url=null )
	{
		// unset
		unset($_SESSION);
		// location
		if($url){
			header('location:'.$url);
		}
		return true;
	} */

	public function update_last_login($id)
	{
		if($id){
			/* $update = array();
			$update['mdate'] = DATETIME;
			
			$where = array();
			$where['user_id'] = $id; */
			
			$this->DB->sql = 'UPDATE ath_users set mdate="'.DATETIME.'" where user_id='.$id;
			$this->DB->update();
			//$this->DB->update( 'ath_users', $update, $where);
		}
	}

// ==================================================================================
	
	/* protected */

	protected function ath_main_function()
	{
	
		$this->DB->sql = 'select * from ath_main_function where status=1 ';
		$this->DB->select();
		$result = $this->DB->getRows();
		
		return $result;	
	}
	
	protected function ath_tasks($key=null)
	{
		$where = null;
		if($key){
			$where = ' where ';
			$where .= ' task_key = "'.self::__escape($key).'" ';
		}
		
		$this->DB->sql = 'select * from ath_tasks '. $where;
		$this->DB->select();
		$result = $this->DB->getRows();
		
		if($key){
			return $result[0];	
		}
		else{
			return $result;	
		}
		
	}
	
}

<file_sep>/modules/conclusion/class_modules/back/learing_resualt_final_m.php
<?php 
class ClassData extends Databases {
	
	public function get_head($class_level,$room,$year,$term){
		$this->sql ="SELECT DISTINCT(sub_ID),courseID
						FROM tbl_sub_pp6
						WHERE pp6_ID in(
							SELECT DataID
							FROM tbl_pp6
							WHERE class_level='$class_level'
							AND room='$room'
							AND term='$term'
							AND year='$year'

						)
						ORDER BY sub_ID ASC

							";
		$this->select();
		$this->setRows();
		foreach($this->rows as $key => $value) {
			$courseID=  $value['courseID'];
			$data_response['head_list'].='
					<th  style="height: 70px;line-height: 1;width: 1%;text-align: center;">
		                <div style="transform: rotate(-90deg);white-space: nowrap;">
		                  '.$courseID.'
		                </div>
		             </th>
			';
			$data_response['sum_100_list'].='
				<th style="text-align: center;">100</th>
			';
		}
		$data_response['head_list'].='
						<th  style="height: 70px;line-height: 1;width: 1%;text-align: center;">
			                <div style="transform: rotate(-90deg);white-space: nowrap;margin-right:-12px;margin-left:-12px">
			                  คุณลักษณฯ
			                </div>
			             </th>
			             <th  style="height: 70px;line-height: 1;width: 1%;text-align: center;">
			                <div style="transform: rotate(-90deg);white-space: nowrap;margin-right:-12px;margin-left:-12px">
			                  อ่าน เขียนฯ
			                </div>
			             </th>
		              	<th  style="height: 70px;line-height: 1;width: 1%;text-align: center;">
		                	<div style="transform: rotate(-90deg);white-space: nowrap;">
		                  		GPA
		                	</div>
		              	</th>
		              	<th  style="height: 70px;line-height: 1;width: 1%;text-align: center;">
		                	<div style="transform: rotate(-90deg);white-space: nowrap;">
		                  		อันดับที่
		                	</div>
		              	</th>
		';
		return $data_response;
	}
	public function get_list_conclusion($pp6_id){
		$data_response = array();
		$this->sql ="SELECT *
					FROM tbl_sub_pp6
					WHERE pp6_ID=$pp6_id
					";
		$this->select();
		$this->setRows();
		$score_by_unit_row=0;
		$unit_count=0;
		$score_desirable_count=0;
		$score_rtw_count=0;
		$count_all=0;
		$status=0;
		$count_dev_course=0;
		foreach($this->rows as $key => $value) {
			$DataID=$value['DataID'];
			$score_total=  $value['score_total'];
			$unit= $value['unit'];
			$status_course= $value['status'];
			$score_attend= $value['score_attend'];
			
			$score_desirable =  number_format($value['score_desirable'],0);
			$score_rtw =  number_format($value['score_rtw'],0);
			if ($status_course==1) {
				if($score_total==-1){
					$grade_set='ร';
				}else{
					$grade_set=$this->get_grade($score_total);
					$score_by_unit_row=$score_by_unit_row+($grade_set*$unit);
					$score_desirable_count=$score_desirable_count+$score_desirable;
					$score_rtw_count=$score_rtw_count+$score_rtw;
				}
					$unit_count=$unit_count+$unit;
					$count_all++;
			}elseif($status_course==2){
				$count_dev_course++;
				if ($score_attend==-1) {
					$status++;
				}
			}
			
		}
		$find_percentage=number_format($score_by_unit_row/$unit_count,2);
		$find_desirable_average=number_format($score_desirable_count/$count_all,0);
		$find_rtw_average=number_format($score_rtw_count/$count_all,0);
		$data_response['percentage']=$find_percentage;
		$data_response['desirable_average']=$find_desirable_average;
		$data_response['rtw_average']=$find_rtw_average;
		$data_response['status']=$status;
		$data_response['count_dev_course']=$count_dev_course;
		return $data_response;
	}
	public function get_conclusion($class_level,$room,$year,$term,$image_logo,$footer_text_detail,$footer_text_cen){
		$data_response = array();	
		$this->sql ="SELECT COUNT(*) AS num_row
					FROM tbl_pp6
					WHERE term='$term'
					AND year='$year'
					AND room='$room'
					AND class_level='$class_level'
					";
		$this->select();
		$this->setRows();
		$num_row=$this->rows[0]['num_row'];

		$this->sql ="SELECT *
					FROM tbl_pp6
					WHERE term='$term'
					AND year='$year'
					AND room='$room'
					AND class_level='$class_level'
					";
		$this->select();
		$this->setRows();
		$data_000_100=0;
		$data_101_150=0;
		$data_151_200=0;
		$data_201_250=0;
		$data_251_300=0;
		$data_301_350=0;
		$data_351_400=0;
		$eva_not_pass=0;

		$desirable_3=0;
		$desirable_2=0;
		$desirable_1=0;
		$desirable_0=0;

		$average_3=0;
		$average_2=0;
		$average_1=0;
		$average_0=0;

		foreach($this->rows as $key => $value) {
			$DataID=  $value['DataID'];
			$list_conclusion=$this->get_list_conclusion($DataID);
			if ($list_conclusion['percentage']<=1) {
					$data_000_100++;
			}elseif($list_conclusion['percentage']<=1.50){
				$data_101_150++;
			}elseif($list_conclusion['percentage']<=2){
				$data_151_200++;
			}elseif($list_conclusion['percentage']<=2.50){
				$data_201_250++;
			}elseif($list_conclusion['percentage']<=3){
				$data_251_300++;
			}elseif($list_conclusion['percentage']<=3.50){
				$data_301_350++;
			}elseif($list_conclusion['percentage']<=4){
				$data_351_400++;
			}
			if ($list_conclusion['status']>0) {
					$eva_not_pass++;
			}

			if ($list_conclusion['desirable_average']==3) {
				$desirable_3++;
			}elseif($list_conclusion['desirable_average']==2){
				$desirable_2++;
			}elseif($list_conclusion['desirable_average']==1){
				$desirable_1++;
			}elseif($list_conclusion['desirable_average']==0){
				$desirable_0++;
			}
			
			if ($list_conclusion['rtw_average']==3) {
				$average_3++;
			}elseif($list_conclusion['rtw_average']==2){
				$average_2++;
			}elseif($list_conclusion['rtw_average']==1){
				$average_1++;
			}elseif($list_conclusion['rtw_average']==0){
				$average_0++;
			}
			
		}
		$percen_000_100=number_format(($data_000_100*100)/$num_row,2);
		$percen_101_150=number_format(($data_101_150*100)/$num_row,2);
		$percen_151_200=number_format(($data_151_200*100)/$num_row,2);
		$percen_201_250=number_format(($data_201_250*100)/$num_row,2);
		$percen_251_300=number_format(($data_251_300*100)/$num_row,2);
		$percen_301_350=number_format(($data_301_350*100)/$num_row,2);
		$percen_351_400=number_format(($data_351_400*100)/$num_row,2);

		$percen_desirable_3=number_format(($desirable_3*100)/$num_row,2);
		$percen_desirable_2=number_format(($desirable_2*100)/$num_row,2);
		$percen_desirable_1=number_format(($desirable_1*100)/$num_row,2);
		$percen_desirable_0=number_format(($desirable_0*100)/$num_row,2);

		$percen_average_3=number_format(($average_3*100)/$num_row,2);
		$percen_average_2=number_format(($average_2*100)/$num_row,2);
		$percen_average_1=number_format(($average_1*100)/$num_row,2);
		$percen_average_0=number_format(($average_0*100)/$num_row,2);

		$eva_ok_pass=$num_row-$eva_not_pass;
		$percen_eva_not_pass=number_format(($eva_not_pass*100)/$num_row,2);
		$percen_eva_ok_pass=number_format(($eva_ok_pass*100)/$num_row,2);
		if ($count_dev_course==0) {
			$eva_not_pass='-';
			$eva_ok_pass='-';
			$percen_eva_not_pass='-';
			$percen_eva_ok_pass='-';
		}
		$data_response='
				<table cellspacing="0"  style=" text-align: center; font-size: 16px;width:100%;margin-top: 20px;">
						          <thead>
						            <tr class="text-middle">
						              <th colspan="12" class="rotate" style="width: 3%;height: 0px;text-align: center;">
						                <div >สรุปการประเมินผลการเรียน</div>
						              </th>
						            </tr> 
						            <tr class="text-middle">
						              <th style="width: 16%;height: 0px;text-align: center;">
						                ผลการเรียน (GPA)
						              </th>
						              <th style="width: 8%;height: 0px;text-align: center;">
						                3.51-4.00
						              </th>
						              <th style="width: 8%;height: 0px;text-align: center;">
						                3.01-3.50
						              </th>
						              <th style="width: 8%;height: 0px;text-align: center;">
						                2.51-3.00
						              </th>
						              <th style="width: 8%;height: 0px;text-align: center;">
						                2.01-2.50
						              </th>
						              <th style="width: 8%;height: 0px;text-align: center;">
						                1.51-2.00
						              </th>
						              <th style="width: 8%;height: 0px;text-align: center;">
						                1.01-1.50
						              </th>
						              <th style="width: 8%;height: 0px;text-align: center;">
						                0.00-1.00
						              </th>
						              <th style="width: 7%;height: 0px;text-align: center;">
						                รวม
						              </th>
						              <th style="width: 7%;height: 0px;text-align: center;">
						                ผ
						              </th>
						              <th style="width: 7%;height: 0px;text-align: center;">
						                มผ
						              </th>
						              <th style="width: 7%;height: 0px;text-align: center;">
						                รวม
						              </th>
						            </tr> 
						          </thead>
						          <tbody >
						           <tr class="text-middle">
						              <td style="width: 16%;height: 0px;text-align: center;">
						                จำนวน
						              </td>
						              <td style="width: 8%;height: 0px;text-align: center;">
						                '.$data_351_400.'
						              </td>
						              <td style="width: 8%;height: 0px;text-align: center;">
						                '.$data_301_350.'
						              </td>
						              <td style="width: 8%;height: 0px;text-align: center;">
						                '.$data_251_300.'
						              </td>
						              <td style="width: 8%;height: 0px;text-align: center;">
						                '.$data_201_250.'
						              </td>
						              <td style="width: 8%;height: 0px;text-align: center;">
						                '.$data_151_200.'
						              </td>
						              <td style="width: 8%;height: 0px;text-align: center;">
						                '.$data_101_150.'
						              </td>
						              <td style="width: 8%;height: 0px;text-align: center;">
						                '.$data_000_100.'
						              </td>
						              <td style="width: 7%;height: 0px;text-align: center;">
						               	22
						              </td>
						              <td style="width: 7%;height: 0px;text-align: center;">
						                '.$eva_ok_pass.'
						              </td>
						              <td style="width: 7%;height: 0px;text-align: center;">
						                '.$eva_not_pass.'
						              </td>
						              <td style="width: 7%;height: 0px;text-align: center;">
						               	'.$num_row.'
						              </td>
						            </tr> 
						            
						            <tr class="text-middle">
						              <td style="width: 16%;height: 0px;text-align: center;">
						                ร้อยละ
						              </td>
						              <td style="width: 8%;height: 0px;text-align: center;">
						                '.$percen_351_400.'
						              </td>
						              <td style="width: 8%;height: 0px;text-align: center;">
						                '.$percen_301_350.'
						              </td>
						              <td style="width: 8%;height: 0px;text-align: center;">
						                '.$percen_251_300.'
						              </td>
						              <td style="width: 8%;height: 0px;text-align: center;">
						                '.$percen_201_250.'
						              </td>
						              <td style="width: 8%;height: 0px;text-align: center;">
						                '.$percen_151_200.'
						              </td>
						              <td style="width: 8%;height: 0px;text-align: center;">
						                '.$percen_101_150.'
						              </td>
						              <td style="width: 8%;height: 0px;text-align: center;">
						                '.$percen_000_100.'
						              </td>
						              <td style="width: 7%;height: 0px;text-align: center;">
						               	100
						              </td>
						              <td style="width: 7%;height: 0px;text-align: center;">
						                '.$percen_eva_ok_pass.'
						              </td>
						              <td style="width: 7%;height: 0px;text-align: center;">
						                '.$percen_eva_not_pass.'
						              </td>
						              <td style="width: 7%;height: 0px;text-align: center;">
						                100.00
						              </td>
						            </tr> 
						          </tbody>
						        </table>
						        <table cellspacing="0"  style=" text-align: center; font-size: 16px;width:100%;">
						          <thead style="border-top: none;">
						            <tr class="text-middle" style="border-top:none;">
						              <th colspan="6" class="rotate" style="height: 0px;text-align: center;border-top:none;">
						                <div >คุณลักษณะอันพึงประสงค์</div>
						              </th>
						              <th colspan="5" class="rotate" style="height: 0px;text-align: center;border-top:none;">
						                <div >อ่าน เขียน คิดวิเคราะห์</div>
						              </th>
						            </tr> 
						            <tr class="text-middle;">
						              <th style="width: 12.8%;height: 0px;text-align: center;">
						                ผลการประเมิน
						              </th>
						              <th style="width: 6.5%;height: 0px;text-align: center;">
						                3
						              </th>
						              <th style="width: 6.5%;height: 0px;text-align: center;">
						                2
						              </th>
						              <th style="width: 6.5%;height: 0px;text-align: center;">
						                1
						              </th>
						              <th style="width: 6.5%;height: 0px;text-align: center;">
						                0
						              </th>
						              <th style="width: 6.6%;height: 0px;text-align: center;">
						                รวม
						              </th>
						              <th style="width: 7%;height: 0px;text-align: center;">
						                3
						              </th>
						              <th style="width: 7%;height: 0px;text-align: center;">
						                2
						              </th>
						              <th style="width: 7%;height: 0px;text-align: center;">
						                1
						              </th>
						              <th style="width: 7%;height: 0px;text-align: center;">
						                0
						              </th>
						              <th style="width: 7%;height: 0px;text-align: center;">
						                รวม
						              </th>
						           
						            </tr> 

						          </thead>
						          <tbody >
						           <tr class="text-middle">
						              <td >
						                จำนวน
						              </td>
						              <td >
						                '.$desirable_3.'
						              </td>
						              <td >
						                '.$desirable_2.'
						              </td>
						              <td >
						                '.$desirable_1.'
						              </td>
						              <td >
						                '.$desirable_0.'
						              </td>
						              <td >
						                '.$num_row.'
						              </td>
						              <td >
						                '.$average_3.'
						              </td>
						              <td >
						                '.$average_2.'
						              </td>
						              <td >
						              	'.$average_1.'
						              </td>
						              <td >
						              	'.$average_0.'
						              </td>
						              <td >
						                '.$num_row.'
						              </td>
						              
						            </tr> 
						            <tr class="text-middle">
						              <td >
						                ร้อยละ
						              </td>
						              <td >
						                '.$percen_desirable_3.'
						              </td>
						              <td >
						                '.$percen_desirable_2.'
						              </td>
						              <td >
						                '.$percen_desirable_1.'
						              </td>
						              <td >
						                '.$percen_desirable_0.'
						              </td>
						              <td >
						                100.00
						              </td>
						              <td >
						                '.$percen_average_3.'
						              </td>
						              <td >
						                '.$percen_average_2.'
						              </td>
						              <td >
						                '.$percen_average_1.'
						              </td>
						              <td >
						                '.$percen_average_0.'
						              </td>
						              
						              <td >
						                100.00
						              </td>
						            </tr> 
						          </tbody>
						        </table>
		';
		
		return $data_response;
	}
	public function get_course_list($pp6_id,$i,$year_data,$term,$room,$class_level_data,$std_ID){
		$data_response = array();	
		$this->sql ="SELECT *
						FROM tbl_sub_pp6
						WHERE pp6_ID=$pp6_id
						ORDER BY sub_ID ASC

							";
		$this->select();
		$this->setRows();
		
		$score_by_unit_row=0;
		$unit_count=0;
		$score_desirable_count=0;
		$score_rtw_count=0;
		$count_all=0;
		$status=0;
		foreach($this->rows as $key => $value) {
			$DataID=  $value['DataID'];
			$score_total=  $value['score_total'];
			$unit= $value['unit'];
			$status_course= $value['status'];
			$score_attend= $value['score_attend'];
			$score_desirable =  number_format($value['score_desirable'],0);
			$score_rtw =  number_format($value['score_rtw'],0);
			if ($status_course==1) {
				if($score_total==-1){
					$grade_set='ร';
					$status++;
				}else{
					$grade_set=$this->get_grade($score_total);
					$score_by_unit_row=$score_by_unit_row+($grade_set*$unit);
					$score_desirable_count=$score_desirable_count+$score_desirable;
					$score_rtw_count=$score_rtw_count+$score_rtw;
				}
					
				if ($i==1) {
					$data_response['row_list'].='
							<td style="width: 1%;">'.$grade_set.'</td>
				';
				}elseif($i>1){
					$data_response['row_list'].='
							<td style="width: 2.5%;">'.$grade_set.'</td>
				';
				}elseif($i==-1){
					$data_response['row_list'].='
							<td>'.$grade_set.'</td>
				';
				}
				$unit_count=$unit_count+$unit;
			}elseif($status_course==2){
				if ($score_attend==1) {
					$grade_set='ผ';
				}else{
					$grade_set='มผ';
					$attend_not_pass_count++;
				}

				if ($i==1) {
					$data_response['row_list'].='
							<td style="width: 1%;">'.$grade_set.'</td>
				';
				}elseif($i>1){
					$data_response['row_list'].='
							<td style="width: 2.5%;">'.$grade_set.'</td>
				';
				}elseif($i==-1){
					$data_response['row_list'].='
							<td>'.$grade_set.'</td>
				';
				}
				$score_desirable_count=$score_desirable_count+$score_desirable;
				$score_rtw_count=$score_rtw_count+$score_rtw;
			}
			$count_all++;
		}
		$find_desirable_average=number_format($score_desirable_count/$count_all,0);
		$find_rtw_average=number_format($score_rtw_count/$count_all,0);
		$find_percentage=number_format($score_by_unit_row/$unit_count,2);
		
		$find_position=$this->find_position($year_data,$term,$class_level_data,$room);
		arsort($find_position);
		$arrayValuePosition=$this->arrayValuePositionNew($find_position,$std_ID);

		if ($i==1) {
			$data_response['row_list'].='
						<td style="width: 1%;">'.$find_desirable_average.'</td>
						<td style="width: 1%;">'.$find_rtw_average.'</td>
						<td style="width: 1%;">'.$find_percentage.'</td>
						<td style="width: 1%;">'.$arrayValuePosition.'</td>
			';
		}elseif($i>1){
				$data_response['row_list'].='
						<td style="width: 2%;">'.$find_desirable_average.'</td>
						<td style="width: 2%;">'.$find_rtw_average.'</td>
						<td style="width: 2%;">'.$find_percentage.'</td>
						<td style="width: 2%;">'.$arrayValuePosition.'</td>
			';
		}elseif($i==-1){
				$data_response['row_list'].='
						<td>'.$find_desirable_average.'</td>
						<td>'.$find_rtw_average.'</td>
						<td>'.$find_percentage.'</td>
						<td>'.$arrayValuePosition.'</td>
			';
		}
		
		$data_response['grade']=$find_percentage;
		$data_response['status']=$status;
		$data_response['ddd']=2;

		return $data_response;
	}
	public function find_position($year_data,$term,$class_level_data,$room){
		$data_response = array();	
		$this->sql ="SELECT distinct(tbl_pp6.std_ID) as std_pp6_id,tbl_pp6.DataID as pp6_id
					FROM tbl_pp6,tbl_sub_pp6
					WHERE tbl_pp6.DataID=tbl_sub_pp6.pp6_ID
					AND tbl_pp6.year='$year_data'
					AND tbl_pp6.term='$term'
					AND tbl_pp6.room='$room'
					AND tbl_pp6.class_level='$class_level_data'
					AND tbl_sub_pp6.status=1
		";
		$this->select();
		$this->setRows();
		$find_gpa_sum=0;	
		$score_final_count=0;
		foreach($this->rows as $key => $value) {
			 $std_pp6_id=$value['std_pp6_id'];
			 $pp6_id=$value['pp6_id'];
			 $data_big_std= $this->get_data_big_std($std_pp6_id,$pp6_id);
			 $test[$std_pp6_id] = $data_big_std;
		}

		return $test;
	}
	
	public function get_data_big_std($std_pp6_id,$pp6_id){
		$this->sql ="SELECT unit,score_total
					FROM tbl_pp6,tbl_sub_pp6
					WHERE tbl_pp6.DataID=tbl_sub_pp6.pp6_ID
					AND tbl_sub_pp6.pp6_ID=$pp6_id
					AND score_total!=-1
		";
		$this->select();
		$this->setRows();
		$find_row_sum=0;
		foreach($this->rows as $key => $value) {
			 $unit=$value['unit'];
			 $score_total=$value['score_total'];
			 $grade= $this->get_grade($score_total);
			 $find_row_sum=$find_row_sum+($unit*$grade);
		}
		$this->sql ="SELECT SUM(unit) as unit_sum
					FROM tbl_pp6,tbl_sub_pp6
					WHERE tbl_pp6.DataID=tbl_sub_pp6.pp6_ID
					AND tbl_sub_pp6.pp6_ID=$pp6_id
					AND tbl_sub_pp6.status=1
		";
		$this->select();
		$this->setRows();
		$unit_sum=$this->rows[0]['unit_sum'];
		return $find_row_sum/$unit_sum;
	}
	public function arrayValuePositionNew($find_position,$std_ID){	
		$result = array();
		$pos = $real_pos = 0;
		$prev_score = -1;
		foreach ($find_position as $exam_n => $score) {
			$real_pos += 1;// Natural position.
			$pos = ($prev_score != $score) ? $real_pos : $pos;// If I have same score, I have same position in ranking, otherwise, natural position.
			$result[$exam_n] = array(
							 "score" => $score, 
							 "position" => $pos, 
							 "exam_no" => $exam_n
							 );
			$prev_score = $score;// update last score.
		}

		return $result[$std_ID]["position"];
}
	public function get_grade($total){
		if ($total<50) {
			$grade='0.0';
		}elseif($total<55){
			$grade='1.0';
		}elseif($total<60){
			$grade='1.5';
		}elseif($total<65){
			$grade='2.0';
		}elseif($total<70){
			$grade='2.5';
		}elseif($total<75){
			$grade='3.0';
		}elseif($total<80){
			$grade='3.5';
		}elseif($total>=80){
			$grade='4.0';
		}
		return $grade;
	}
	public function get_count_std($class_level,$room,$year,$term){
		$this->sql ="SELECT COUNT(*) AS num_row
						FROM tbl_pp6
						WHERE class_level='$class_level'
						AND room='$room'
						AND term='$term'
						AND year='$year'
						
							";
			$this->select();
			$this->setRows();
			return $this->rows[0]['num_row'];
	}
	public function get_final_data_m($class_level,$room,$year,$term,$image_logo,$footer_text_detail,$footer_text_cen){
		$conclusion=$this->get_conclusion($class_level,$room,$year,$term,$image_logo,$footer_text_detail,$footer_text_cen);
		$mid_head=$this->get_head($class_level,$room,$year,$term);

		$count_std=$this->get_count_std($class_level,$room,$year,$term);
		if ($count_std<=30) {
			$set_loop_html=2;
		}else{
			$set_loop_html=3;
		}
		
		if ($set_loop_html==1) {
			$loop_data=$this->get_loop_data($class_level,$room,$year,$term);
			$data_response['std_list'].='
						<div style="page-break-after:always;">
					      <page >
					        <div style="text-align: center;line-height: 0.6;font-weight: bold;padding-top: 10px;font-size:18px">
					          <img class="logo-print-size" src="'.$image_logo.'">
					          <p >แบบประกาศผลการเรียนแยกตามระดับชั้น</p>
					          <p >โรงเรียนเทศบาลวัดสระทอง สังกัดเทศบาลเมืองร้อยเอ็ด อ.เมือง จ.ร้อยเอ็ด</p>
					          <p>
					            <span style="margin-right: 20px;">ระดับชั้น 
					              <span style="font-weight: normal;">มัธยมศึกษาปีที่ '.substr($class_level,1).'</span>
					            </span> 
					            <span style="margin-right: 20px;">ห้อง 
					              <span style="font-weight: normal;">'.$room.'</span>
					            </span> 
					            <span style="margin-right: 20px;">ภาคเรียนที่ 
						              <span style="font-weight: normal;">'.$term.'</span>
						            </span> 
					            <span>ปีการศึกษา <span style="font-weight: normal;">'.$year.'</span> </span>
					          </p>
					          <p style="margin-top: 20px;">
					            <span style="margin-right: 40px;">ครูประจำชั้น 
					              <span style="font-weight: normal;">.........................................................................................</span>
					            </span>
					            <span>ครูประจำชั้น 
					              <span style="font-weight: normal;">.........................................................................................</span>
					            </span>

					          </p>
					        </div>
					        <table cellspacing="0"  style=" text-align: center; font-size: 16px;width:100%;margin-top: 20px;">
					          <thead>
					            <tr class="text-middle">
					              <th class="rotate" style="width: 3%;height: 0px;text-align: center;">
					                <div >เลขที่</div>
					              </th>
					              <th class="rotate" style="width: 5%;height: 0px;text-align: center;">
					                <div >รหัส</div>
					              </th>
					              <th style="width: 30%;vertical-align: middle;text-align: center;">ชื่อ-สกุล</th>
					               '.$mid_head['head_list'].'
					            </tr> 
					          </thead>
					          <tbody >
					            '.$loop_data['loop_all'].'
					          </tbody>
					        </table>
					      </page>
					    </div>
					    <div style="page-break-after:always;">
					      <page >
					      	'.$footer_text_detail.'
					      </page>
					     </div>
			';
		}else{
				if ($set_loop_html==2) {
					for ($i=1; $i <=$set_loop_html ; $i++) {
					$loop_data=$this->get_loop_data($class_level,$room,$year,$term,$i,$set_loop_html);
					if ($i==1) {
						$data_response['std_list'].='
							<div style="page-break-after:always;">
						      <page >
						        <div style="text-align: center;line-height: 0.6;font-weight: bold;padding-top: 20px;font-size:18px">
						          <img class="logo-print-size" src="'.$image_logo.'">
						          <p >แบบประกาศผลการเรียนแยกตามระดับชั้น</p>
						          <p >โรงเรียนเทศบาลวัดสระทอง สังกัดเทศบาลเมืองร้อยเอ็ด อ.เมือง จ.ร้อยเอ็ด</p>
						          <p>
						            <span style="margin-right: 20px;">ระดับชั้น 
						              <span style="font-weight: normal;">มัธยมศึกษาปีที่ '.substr($class_level,1).'</span>
						            </span> 
						            <span style="margin-right: 20px;">ห้อง 
						              <span style="font-weight: normal;">'.$room.'</span>
						            </span>  
						            <span style="margin-right: 20px;">ภาคเรียนที่ 
						              <span style="font-weight: normal;">'.$term.'</span>
						            </span> 
						            <span>ปีการศึกษา <span style="font-weight: normal;">'.$year.'</span> </span>
						          </p>
						          <p style="margin-top: 20px;">
						            <span style="margin-right: 40px;">ครูประจำชั้น 
						              <span style="font-weight: normal;">.........................................................................................</span>
						            </span>
						            <span>ครูประจำชั้น 
						              <span style="font-weight: normal;">.........................................................................................</span>
						            </span>

						          </p>
						        </div>
						        <table cellspacing="0"  style=" text-align: center; font-size: 16px;width:100%;margin-top: 20px;">
						          <thead>
						            <tr class="text-middle">
						              <th class="rotate" style="width: 3%;height: 0px;text-align: center;">
						                <div >เลขที่</div>
						              </th>
						              <th class="rotate" style="width: 5%;height: 0px;text-align: center;">
						                <div >รหัส</div>
						              </th>
						              <th style="width: 30%;vertical-align: middle;text-align: center;">ชื่อ-สกุล</th>
						               '.$mid_head['head_list'].'
						            </tr> 
						            

						          </thead>
						          <tbody >
						            '.$loop_data['loop_all'].'
						          </tbody>
						        </table>
						      </page>
						    </div>
						   
				';
					}else{
						$data_response['std_list'].='
							 <div style="page-break-after:always;">
						      <page >
						      	<table cellspacing="0"  style=" text-align: center; font-size: 16px;width:100%;margin-top: 20px;">
						      	 <tbody >
						            '.$loop_data['loop_all'].'
						          </tbody>
						          </table>
						          	'.$footer_text_detail.'
						          '.$conclusion.'
						          '.$footer_text_cen.'
						      </page>
						     </div>

						';
					}
					
				}
			}else{
				for ($i=1; $i <=$set_loop_html ; $i++) {
					$loop_data=$this->get_loop_data($class_level,$room,$year,$term,$i,$set_loop_html);
					if ($i==1) {
						$data_response['std_list'].='
							<div style="page-break-after:always;">
						      <page >
						        <div style="text-align: center;line-height: 0.6;font-weight: bold;padding-top: 20px;font-size:18px">
						          <img class="logo-print-size" src="'.$image_logo.'">
						          <p >แบบประกาศผลการเรียนแยกตามระดับชั้น</p>
						          <p >โรงเรียนเทศบาลวัดสระทอง สังกัดเทศบาลเมืองร้อยเอ็ด อ.เมือง จ.ร้อยเอ็ด</p>
						         <p>
						            <span style="margin-right: 20px;">ระดับชั้น 
						              <span style="font-weight: normal;">มัธยมศึกษาปีที่ '.substr($class_level,1).'</span>
						            </span> 
						            <span style="margin-right: 20px;">ห้อง 
						              <span style="font-weight: normal;">'.$room.'</span>
						            </span>  
						            <span style="margin-right: 20px;">ภาคเรียนที่ 
						              <span style="font-weight: normal;">'.$term.'</span>
						            </span> 
						            <span>ปีการศึกษา <span style="font-weight: normal;">'.$year.'</span> </span>
						          </p>
						          <p style="margin-top: 20px;">
						            <span style="margin-right: 40px;">ครูประจำชั้น 
						              <span style="font-weight: normal;">.........................................................................................</span>
						            </span>
						            <span>ครูประจำชั้น 
						              <span style="font-weight: normal;">.........................................................................................</span>
						            </span>

						          </p>
						        </div>
						        <table cellspacing="0"  style=" text-align: center; font-size: 16px;width:100%;margin-top: 20px;">
						          <thead>
						            <tr class="text-middle">
						              <th class="rotate" style="width: 3%;height: 0px;text-align: center;">
						                <div >เลขที่</div>
						              </th>
						              <th class="rotate" style="width: 5%;height: 0px;text-align: center;">
						                <div >รหัส</div>
						              </th>
						              <th style="width: 30%;vertical-align: middle;text-align: center;">ชื่อ-สกุล</th>
						               '.$mid_head['head_list'].'
						            </tr> 
						            

						          </thead>
						          <tbody >
						            '.$loop_data['loop_all'].'
						          </tbody>
						        </table>
						        '.$footer_text_detail.'
						          '.$conclusion.'
						          '.$footer_text_cen.'
						      </page>
						    </div>
						   
				';
					}elseif($i==2){
						$data_response['std_list'].='
							 <div style="page-break-after:always;">
						      <page >
						      	<table cellspacing="0"  style=" text-align: center; font-size: 16px;width:100%;margin-top: 20px;">
						      	 <tbody >
						            '.$loop_data['loop_all'].'
						          </tbody>
						          </table>  
						          '.$footer_text_detail.'
						          '.$conclusion.'
						          '.$footer_text_cen.' 
						      </page>
						     </div>

						';
					}elseif($i==3){
						
						$data_response['std_list'].='
							 <div style="page-break-after:always;">
						      <page >
						      	<table cellspacing="0"  style=" text-align: center; font-size: 16px;width:100%;margin-top: 20px;">
						      	 <tbody >
						            '.$loop_data['loop_all'].'
						          </tbody>
						          </table>   
						          '.$footer_text_detail.'
						          '.$conclusion.'
						          '.$footer_text_cen.'
						      </page>
						     </div>

						';
					}
					
				}
			}

		}
		
		return $data_response;
	}
	public function get_loop_data($class_level,$room,$year,$term,$i,$set_loop_html){
		$data_response = array();	
		if ($i!='') {
			if ($set_loop_html<3) {
				if ($i==1) {
					$find_start=0;
					$find_end=20;
				}elseif($i==2){
					$find_start=20;
					$find_end=20;
				}
			}else{
				if ($i==1) {
					$find_start=0;
					$find_end=18;
				}elseif($i==2){
					$find_start=18;
					$find_end=25;
				}else{
					$find_start=43;
					$find_end=25;
				}
			}
			$this->sql ="SELECT *
						FROM tbl_pp6
						WHERE class_level='$class_level'
						AND room='$room'
						AND term='$term'
						AND year='$year'
						ORDER BY room ASC,
						CASE
							WHEN name_title LIKE '%dekchai%' THEN 0
					        WHEN name_title LIKE '%nai%' THEN 1
					        WHEN name_title LIKE '%dekying%' THEN 2
					        WHEN name_title LIKE '%nangsaw%'THEN 3
					        WHEN std_ID THEN 4      
					    END
					    LIMIT $find_start,$find_end
							";
			$this->select();
			$this->setRows();
			$number=$find_start+1;
			
			foreach($this->rows as $key => $value) {
				$DataID=  $value['DataID'];	
				$std_ID=  $value['std_ID'];	
				$name_title_set=  $value['name_title'];	
				$name_title=$this->get_name_title($name_title_set);
				$fname=$value['fname'];	
				$lname=$value['lname'];	
				$class_level=$value['class_level'];	
				
				$name=$name_title.$fname.' '.$lname;
				$course_list=$this->get_course_list($DataID,$i,$year,$term,$room,$class_level,$std_ID);
				$data_response['loop_all'].='
								<tr>
					              <td style="width: 3%;">'.$number.'</td>
					              <td style="width: 5%;">'.$std_ID.'</td>
					              <td style="text-align:left;padding-left:10px;width: 28%;">'.$name.'</td>
					              '.$course_list['row_list'].'
					            </tr>
				';
				$number++;
			}
		}else{
			$this->sql ="SELECT *
						FROM tbl_pp6
						WHERE class_level='$class_level'
						AND room='$room'
						AND term='$term'
						AND year='$year'
						ORDER BY room ASC,
						CASE
							WHEN name_title LIKE '%dekchai%' THEN 0
					        WHEN name_title LIKE '%nai%' THEN 1
					        WHEN name_title LIKE '%dekying%' THEN 2
					        WHEN name_title LIKE '%nangsaw%'THEN 3
					        WHEN std_ID THEN 4      
					    END
							";
			$this->select();
			$this->setRows();
			$number=1;
			
			foreach($this->rows as $key => $value) {
				$DataID=  $value['DataID'];	
				$std_ID=  $value['std_ID'];	
				$name_title_set=  $value['name_title'];	
				$name_title=$this->get_name_title($name_title_set);
				$fname=$value['fname'];	
				$lname=$value['lname'];	
				$class_level=$value['class_level'];	
				$name=$name_title.$fname.' '.$lname;
				$course_list=$this->get_course_list($DataID,-1,$year,$term,$room,$class_level,$std_ID);
				$data_response['loop_all'].='
								<tr>
					              <td>'.$number.'</td>
					              <td>'.$std_ID.'</td>
					              <td style="text-align:left;padding-left:10px;">'.$name.'</td>
					              '.$course_list['row_list'].'
					            </tr>
				';
				$number++;
			}
		}
		
			
			return $data_response;
	}
	
	public function get_data_list($class_level,$room_data,$term_data,$year_data){
		if ($term_data=='mid') {
			$this->sql ="SELECT DISTINCT(room) as room,class_level,year
						FROM tbl_pp6
						WHERE class_level='$class_level'
						AND room='$room_data'
							";
			$this->select();
			$this->setRows();
			foreach($this->rows as $key => $value) {
				$room=  $value['room'];	
				$class_level=  $value['class_level'];
				$class_label=$this->get_class_level($class_level);
				$term=  'กลางปี';	
				$year=  $value['year'];		
				$data_response.='
						 <tr class="text-table-center">
							
							<td>'.$class_label.'</td>
							<td>'.$room.'</td>
							<td>'.$term.'</td>
							<td>'.$year.'</td>
							<td>
								<a target="_blank" 
									href="modules/conclusion/form/learning_result.php?class_level='.$class_level.'&room='.$room.'&term=mid&year='.$year.'" style="color: #ac68cc;">
			                  		<span class="glyphicon glyphicon-print" aria-hidden="true"></span>
			                  	</a>
							</td>
						</tr>
				';
			}
		}else{
			$this->sql ="SELECT DISTINCT(room) as room,class_level,term,year
						FROM tbl_pp6
						WHERE class_level='$class_level'
						AND room='$room_data'
							";
			$this->select();
			$this->setRows();
			foreach($this->rows as $key => $value) {
				$room=  $value['room'];	
				$class_level=  $value['class_level'];
				$class_label=$this->get_class_level($class_level);
				if ($class_level=='p1' || $class_level=='p2' || $class_level=='p3' || $class_level=='p4' || $class_level=='p5' || $class_level=='p6') {
						$term='ปลายปี';
				}else{
					$term=  $value['term'];
				}
				$year=  $value['year'];		
				$data_response.='
						 <tr class="text-table-center">
							<td><input id="checkbox_all" type="checkbox"></td>
							<td>'.$class_label.'</td>
							<td>'.$room.'</td>
							<td>'.$term.'</td>
							<td>'.$year.'</td>
							<td>
								<a target="_blank" href="modules/conclusion/form/learning_result_final.php?class_level='.$class_level.'&room='.$room.'&term=mid&year='.$year.'" style="color: #ac68cc;">
			                  		<span class="glyphicon glyphicon-print" aria-hidden="true"></span>
			                  	</a>
							</td>
						</tr>
				';
			}
		}
		
		return json_encode($data_response);
	}
	public function get_year(){
		$this->sql ="SELECT  distinct(year) as year
					FROM tbl_registed_course
					ORDER BY year DESC
							";
		$this->select();
		$this->setRows();
		foreach($this->rows as $key => $value) {
			$year=  $value['year'];	
			$data_response.='
					 <option value="'.$year.'">'.$year.'</option>
			';
		}
		return json_encode($data_response);
	}
	public function get_name_title($name_title_data){
		if ($name_title_data=="dekchai") {
			$name_title="เด็กชาย";
		}elseif($name_title_data=="dekying"){
			$name_title="เด็กหญิง";
		}elseif($name_title_data=="nai"){
			$name_title="นาย";
		}else{
			$name_title="นางสาว";
		}
		return $name_title;
	}
	public function get_class_level($class_level_data){
		if ($class_level_data=="p1") {
			$class_level="ป.1";
		}elseif($class_level_data=="p2"){
			$class_level="ป.2";	
		}elseif($class_level_data=="p3"){
			$class_level="ป.3";	
		}elseif($class_level_data=="p4"){
			$class_level="ป.4";	
		}elseif($class_level_data=="p5"){
			$class_level="ป.5";	
		}elseif($class_level_data=="p6"){
			$class_level="ป.6";	
		}elseif($class_level_data=="m1"){
			$class_level="ม.1";	
		}elseif($class_level_data=="m2"){
			$class_level="ม.2";	
		}elseif($class_level_data=="m3"){
			$class_level="ม.3";	
		}elseif($class_level_data=="m4"){
			$class_level="ม.4";	
		}elseif($class_level_data=="m5"){
			$class_level="ม.5";	
		}elseif($class_level_data=="m6"){
			$class_level="ม.6";	
		}
		return $class_level;
	}
}<file_sep>/modules/summary/process.php
<?php
@ob_start();
@session_start();

require_once('../../init.php');
include('../../src/class.pagination.php');
include('../../src/class.inputfilter.php');
$InputFilter = new InputFilter();

##CLASS_DB_CONNECT##
include('class_modules.php');
$class_data = new ClassData();
##CLASS_DB_CONNECT##
if(isset($_POST['acc_action']) and $_POST['acc_action'] == "export_data_mid"){	
	$data_val = $_POST['data_val'];
	$data_term_set = $_POST['data_term_set'];
	echo $class_data->export_data_mid($data_val,$data_term_set);
}
if(isset($_POST['acc_action']) and $_POST['acc_action'] == "export_data"){	
	$data_val = $_POST['data_val'];
	$data_term_set = $_POST['data_term_set'];
	echo $class_data->export_data($data_val,$data_term_set);
}

if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_year_text"){	
	echo $class_data->get_year_text();
}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_dev_summary"){	
	$coures_id_list_val=$_GET['coures_id_list_val'];
	$room_search=$_GET['room_search'];
	$term_data=$_GET['term_data'];
	$year_data=$_GET['year_data'];
	echo $class_data->get_dev_summary($coures_id_list_val,$room_search,$term_data,$year_data);
}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_grade_summary"){	
	$coures_id_list_val=$_GET['coures_id_list_val'];
	$room_search=$_GET['room_search'];
	$term_data=$_GET['term_data'];
	$year_data=$_GET['year_data'];
	echo $class_data->get_grade_summary($coures_id_list_val,$room_search,$term_data,$year_data);
}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "search_course_detail"){	
	$coures_id_list=$_GET['coures_id_list'];
	$room_search=$_GET['room_search'];
	echo $class_data->search_course_detail($coures_id_list,$room_search);
}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_class_level"){	
	$coures_id_list_val=$_GET['coures_id_list_val'];
	echo $class_data->get_class_level($coures_id_list_val);
}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_mid"){	
	echo $class_data->get_mid();
}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_coures_id_list"){	
	$ss_status=$_SESSION['ss_status'];
	if ($ss_status==2) {
		$data_term_search=$_GET['data_term_search'];
		$data_year_search=$_GET['data_year_search'];
		echo $class_data->get_coures_id_list_admin($data_term_search,$data_year_search);
	}else{
		echo $class_data->get_coures_id_list();
	}
	
}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_coures_id_list_added"){	
	echo $class_data->get_coures_id_list_added();
}

if(isset($_GET['acc_action']) and $_GET['acc_action'] == "un_export"){	
	$data_id=$_GET['data_id'];
	$data_term=$_GET['data_term'];
	$data_year=$_GET['data_year'];
	$data_room=$_GET['data_room'];
	$data_class=$_GET['data_class'];
	
	
	echo $class_data->un_export($data_id,$data_term,$data_year,$data_room,$data_class);
}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_coures_id_list_edit"){	
	$data_term_search=$_GET['data_term_search'];
	$data_year_search=$_GET['data_year_search'];
	echo $class_data->get_coures_id_list_edit($data_term_search,$data_year_search);
}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_year"){	
	echo $class_data->get_year();
}<file_sep>/modules/add_delete_course/class_modules.php
<?php 

class ClassData extends Databases {
	public function get_department($department_data){	
		if ($department_data=="1") {
			$department='dep_1';		
		}elseif($department_data=="2"){
			$department='dep_2';			
		}elseif($department_data=="3"){
			$department='dep_3';			
		}elseif($department_data=="31"){
			$department='dep_31';			
		}elseif($department_data=="4"){
			$department='dep_4';			
		}elseif($department_data=="41"){
			$department='dep_41';			
		}elseif($department_data=="42"){
			$department='dep_42';			
		}elseif($department_data=="43"){
			$department='dep_43';			
		}elseif($department_data=="5"){
			$department='dep_5';			
		}elseif($department_data=="6"){
			$department='dep_6';			
		}elseif($department_data=="7"){
			$department='dep_7';			
		}elseif($department_data=="71"){
			$department='dep_71';			
		}elseif($department_data=="8"){
			$department='dep_8';			
		}elseif($department_data=="9"){
			$department='dep_9';			
		}elseif($department_data=="10"){
			$department='dep_10';			
		}elseif($department_data=="11"){
			$department='dep_11';			
		}elseif($department_data=="12"){
			$department='dep_12';			
		}
		return $department;
	}
	public function get_unit($unit_data){	
		if ($unit_data=="0.5") {
			$unit='05';
		}elseif($unit_data=="1.0"){
			$unit='10';
		}elseif($unit_data=="1.5"){
			$unit='15';
		}elseif($unit_data=="2.0"){
			$unit='20';
		}elseif($unit_data=="2.5"){
			$unit='25';
		}elseif($unit_data=="3.0"){
			$unit='30';
		}elseif($unit_data=="3.5"){
			$unit='35';
		}elseif($unit_data=="4.0"){
			$unit='40';
		}elseif($unit_data=="4.5"){
			$unit='45';
		}elseif($unit_data=="5.0"){
			$unit='50';
		}elseif($unit_data=="5.5"){
			$unit='55';
		}elseif($unit_data=="6.0"){
			$unit='60';
		}
		return $unit;
	}
	public function getdata_edit($data_id){	
		$data_response = array();
		$sql = "SELECT * 
				FROM tbl_add_delete_course
				WHERE DataID=$data_id
				";
		$this->sql = $sql;
		$this->select();
		$this->setRows();
		$data_response['data_id_course']=$this->rows[0]['DataID'];
		$data_response['courseID']=$this->rows[0]['courseID'];
		$data_response['name']=$this->rows[0]['name'];
		$data_response['class_level']=$this->rows[0]['class_level'];
		$unit_data=$this->rows[0]['unit'];
		$data_response['unit']=$this->get_unit($unit_data);
		$department_data=$this->rows[0]['department'];
		$data_response['department']=$this->get_department($department_data);
		$data_response['hr_learn']=$this->rows[0]['hr_learn'];
		$data_response['status']=$this->rows[0]['status'];
		$data_response['status_form']=$this->rows[0]['status_form'];
		return json_encode($data_response);

	}
	public function update_data($update,$data_id_course){
		$this->sql = "UPDATE tbl_add_delete_course 
					SET ".implode(",",$update)." 
					WHERE DataID='".$data_id_course."'";
		$this->query();
	}
	public function get_data_delete($data_val){
		$arr_id = explode(",", $data_val);
		$num=0;
		for ($i=0; $i < count($arr_id) ; $i++) { 
            $this->sql ="DELETE FROM tbl_add_delete_course WHERE DataID = {$arr_id[$i]}";
	        $this->query();

           $num=$num+$i;
		}
		return $num;
	}
	public function get_class_level($class_level_data){
		if ($class_level_data=="p1") {
			$class_level="ป.1";
		}elseif($class_level_data=="p2"){
			$class_level="ป.2";	
		}elseif($class_level_data=="p3"){
			$class_level="ป.3";	
		}elseif($class_level_data=="p4"){
			$class_level="ป.4";	
		}elseif($class_level_data=="p5"){
			$class_level="ป.5";	
		}elseif($class_level_data=="p6"){
			$class_level="ป.6";	
		}elseif($class_level_data=="m1"){
			$class_level="ม.1";	
		}elseif($class_level_data=="m2"){
			$class_level="ม.2";	
		}elseif($class_level_data=="m3"){
			$class_level="ม.3";	
		}elseif($class_level_data=="m4"){
			$class_level="ม.4";	
		}elseif($class_level_data=="m5"){
			$class_level="ม.5";	
		}elseif($class_level_data=="m6"){
			$class_level="ม.6";	
		}
		return $class_level;
	}
	public function get_data($arr_search_val){
		$data_response = array();
		$sql_condition = " DataID > 0 ";
		$status = $arr_search_val['status'];
		$courseID_search = $arr_search_val['courseID_search'];
		$department_search = $arr_search_val['department_search'];
		$class_level_search = $arr_search_val['class_level_search'];

		if ($status!=1) {
			if (isset($courseID_search) && $courseID_search != "") {
				$sql_condition .= " AND ( courseID LIKE '%{$courseID_search}%')  ";
			}
			if (isset($department_search) && $department_search != "") {
				$sql_condition .= " AND ( department = '$department_search')  ";
			}
			if (isset($class_level_search) && $class_level_search != "") {
				$sql_condition .= " AND ( class_level = '$class_level_search')  ";
			}
		}else{
			if (isset($courseID_search) && $courseID_search != "") {
				$sql_condition .= " AND ( courseID LIKE '%{$courseID_search}%')  ";
			}
		}
		
		$sql = "SELECT count(*) as num_row_count
				FROM tbl_add_delete_course
				WHERE $sql_condition
				ORDER BY DataID DESC
				";
		$this->sql = $sql;
		$this->select();
		$this->setRows();		
		$num_row_count=$this->rows[0]['num_row_count'];

		$sql = "SELECT * 
				FROM tbl_add_delete_course
				WHERE $sql_condition
				ORDER BY DataID DESC
				";
		$this->sql = $sql;
		$this->select();
		$this->setRows();
		if ($num_row_count!=0) {
		foreach($this->rows as $key => $value) {
			$DataID= $value['DataID'];	
			$courseID= $value['courseID'];	
			$name= $value['name'];	
			$class_level_data= $value['class_level'];
			$class_level=$this->get_class_level($class_level_data);
			$unit= $value['unit'];	
			if ($unit==0.0 || $unit==9.9 ) {
				$unit="-";
			}else{
				$unit=$unit;
			}
			$hr_learn= $value['hr_learn'];	

			$data_response['table_list'].='
							<tr>
                                  <td style="text-align:center;">      
                                    <input class="checkbox_data" type="checkbox" value="'.$DataID.'" name="checkbox_delete[]" id="checkbox'.$DataID.'">             
                                  </td>
                                  <td style="text-align:left;padding-left:7%;">'.$courseID.'</td>
                                  <td style="text-align:left;padding-left:7%;">'.$name.'</td>
                                  <td style="text-align:center;">'.$unit.'</td>
                                  <td style="text-align:center;">'.$hr_learn.'</td>
                                  <td style="text-align:center;">'.$class_level.'</td>
                                  <td style="text-align:center;">
                                   <span data-id="'.$DataID.'" class="glyphicon glyphicon glyphicon-edit edit-icon-table btn_getdata_edit" aria-hidden="true" data-toggle="modal" data-target="#modalEdit"></span>
                                  </td>
                                </tr>
			';

			}
		}else{
			$data_response['table_list'].='';
		}
		return json_encode($data_response);
	}
	public function insert_data($insert){
		$this->sql = "INSERT INTO tbl_add_delete_course(".implode(",",array_keys($insert)).") VALUES (".implode(",",array_values($insert)).")";
		$this->query();
		$new_id = $this->insertID();
		
	}

}<file_sep>/modules/maneger_student/index.js
var opPage = 'maneger_student';
$(document).ready(function() {
	btn_data_year_search_student();
}); 
$(document).delegate('#btn_name_id_search', 'click', function(event) {
	get_data();
});
$(document).delegate('#btn_data_year_search_student', 'click', function(event) {
	btn_data_year_search_student();
});
function btn_data_year_search_student() {
	var formData = $( "#frm_data_search_student" ).serializeArray();
	formData.push({ "name": "acc_action", "value": "data_year_search_student" }); 
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {

		$("#table_list").html(data.table_list);
	});
}
function get_data() {
	var formData = $( "#frm_search" ).serializeArray();
	formData.push({ "name": "acc_action", "value": "get_data" }); 
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {
		$("#table_list").html(data.table_list);
	});
}
$('input').on('keydown', function(event) {
   var x = event.which;
   if (x === 13) {
   	get_data();
    event.preventDefault();
   }
});
 $(document).delegate('.bt_delete', 'click', function(event) {
 	var data_id = $(this).attr('data-id');
 	 $(document).delegate('#btn_to_delete', 'click', function(event) {
 		$.post('modules/' + opPage + '/process.php', {
			'acc_action' : 'data_remove',
			'data_val' : data_id
		}, function(response) {
			data_id='';
			$(".modal").modal("hide");
			get_data() ;

		});
 	});
 });

 <file_sep>/modules/conclusion/class_modules/learning_result_department.php
<?php 
class ClassData extends Databases {
	public function get_class_room_list($courseID,$class_level,$class_set,$department_set,$year,$term,$room){
		$this->sql ="SELECT *
						FROM tbl_sub_pp6
						WHERE status=1
						AND department=$department_set
						AND courseID='$courseID'
						AND pp6_ID in(
							SELECT DataID
							FROM tbl_pp6
							WHERE class_level='$class_level$class_set'
							AND term='$term'
							AND year='$year'
							AND room='$room'
							
						)
							";
			$this->select();
			$this->setRows();
			$data_l=0;
			$data_ms=0;
			$data_00=0;
			$data_10=0;
			$data_15=0;
			$data_20=0;
			$data_25=0;
			$data_30=0;
			$data_35=0;
			$data_40=0;

			$data_desirable_nopass=0;
			$data_desirable_pass=0;
			$data_desirable_good=0;
			$data_desirable_verygood=0;

			$data_rtw_nopass=0;
			$data_rtw_pass=0;
			$data_rtw_good=0;
			$data_rtw_verygood=0;

			$std_amount=0;
			foreach($this->rows as $key => $value) {
				$score_total=$value['score_total'];
				$score_attend=$value['score_attend'];
				$score_desirable=$value['score_desirable'];
				$score_rtw=$value['score_rtw'];
				if ($score_total!=-1) {
					$grade=$this->get_grade($score_total);
					if ($grade=='0.0') {
						$data_00++;
					}elseif($grade=='1.0'){
						$data_10++;
					}elseif($grade=='1.5'){
						$data_15++;
					}elseif($grade=='2.0'){
						$data_20++;
					}elseif($grade=='2.5'){
						$data_25++;
					}elseif($grade=='3.0'){
						$data_30++;
					}elseif($grade=='3.5'){
						$data_35++;
					}elseif($grade=='4.0'){
						$data_40++;
					}
				}elseif($score_total==-1){
					$data_l++;
				}
				if ($score_attend==-1) {
					$data_ms++;
				}
				if ($score_desirable<1) {
					$data_desirable_nopass++;
				}elseif($score_desirable<1.5){
					$data_desirable_pass++;
				}elseif($score_desirable<2.5){
					$data_desirable_good++;
				}elseif($score_desirable>=2.5){
					$data_desirable_verygood++;
				}
				if ($score_rtw<1) {
					$data_rtw_nopass++;
				}elseif($score_rtw<1.5){
					$data_rtw_pass++;
				}elseif($score_rtw<2.5){
					$data_rtw_good++;
				}elseif($score_rtw>=2.5){
					$data_rtw_verygood++;
				}
				$std_amount++;
			}
			
			$data_response['data_l']=$data_l;
			$data_response['data_ms']=$data_ms;
			$data_response['data_00']=$data_00;
			$data_response['data_10']=$data_10;
			$data_response['data_15']=$data_15;
			$data_response['data_20']=$data_20;
			$data_response['data_25']=$data_25;
			$data_response['data_30']=$data_30;
			$data_response['data_35']=$data_35;
			$data_response['data_40']=$data_40;

			$data_response['data_desirable_nopass']=$data_desirable_nopass;
			$data_response['data_desirable_pass']=$data_desirable_pass;
			$data_response['data_desirable_good']=$data_desirable_good;
			$data_response['data_desirable_verygood']=$data_desirable_verygood;

			$data_response['data_rtw_nopass']=$data_rtw_nopass;
			$data_response['data_rtw_pass']=$data_rtw_pass;
			$data_response['data_rtw_good']=$data_rtw_good;
			$data_response['data_rtw_verygood']=$data_rtw_verygood;

			$data_response['std_amount']=$std_amount;

			return $data_response;
	}
	public function get_loop_data($class_level,$year,$term,$department,$i,$class_set){

		$class_level_text=$class_level=='p'?'ป.':'ม.';
		$this->sql ="	
						SELECT DISTINCT(tbl_sub_pp6.courseID),room
                        FROM tbl_sub_pp6,tbl_pp6
                        WHERE tbl_sub_pp6.pp6_ID=tbl_pp6.DataID
                        AND tbl_sub_pp6.status=1
                        AND tbl_sub_pp6.department='$department'
                        AND tbl_pp6.class_level='$class_level$class_set'
                        AND tbl_pp6.term='$term'
						AND tbl_pp6.year='$year'
							";
			$this->select();
			$this->setRows();
			$amount_data_40=0;
			$amount_data_35=0;
			$amount_data_30=0;
			$amount_data_25=0;
			$amount_data_20=0;
			$amount_data_15=0;
			$amount_data_10=0;
			$amount_data_00=0;
			$amount_data_l=0;
			$amount_data_ms=0;

			$amount_desirable_verygood=0;
			$amount_desirable_good=0;
			$amount_desirable_pass=0;
			$amount_desirable_nopass=0;

			$amount_rtw_verygood=0;
			$amount_rtw_good=0;
			$amount_rtw_pass=0;
			$amount_rtw_nopass=0;
		
			$all_std_amount=0;
			$order=1;
			foreach($this->rows as $key => $value) {
				$courseID=$value['courseID'];
				$room=$value['room'];
				$class_room_list=$this->get_class_room_list($courseID,$class_level,$class_set,$department,$year,$term,$room);
				$data_response.='
				
					<tr>
					            	<td>'.$order.'</td>
					            	<td>'.$class_level_text.$class_set.'/'.$room.'</td>
					            	<td style="text-align:left;padding-left:10px;">'.$courseID.'</td>
					            	<td>'.$class_room_list['data_40'].'</td>
					            	<td>'.$class_room_list['data_35'].'</td>
					            	<td>'.$class_room_list['data_30'].'</td>
					            	<td>'.$class_room_list['data_25'].'</td>
					            	<td>'.$class_room_list['data_20'].'</td>
					            	<td>'.$class_room_list['data_15'].'</td>
					            	<td>'.$class_room_list['data_10'].'</td>
					            	<td>'.$class_room_list['data_00'].'</td>
					            	<td>'.$class_room_list['data_l'].'</td>
					            	<td>'.$class_room_list['data_ms'].'</td>
					            	
					            	<td>'.$class_room_list['data_desirable_verygood'].'</td>
					            	<td>'.$class_room_list['data_desirable_good'].'</td>
					            	<td>'.$class_room_list['data_desirable_pass'].'</td>
					            	<td>'.$class_room_list['data_desirable_nopass'].'</td>


					            	<td>'.$class_room_list['data_rtw_verygood'].'</td>
					            	<td>'.$class_room_list['data_rtw_good'].'</td>
					            	<td>'.$class_room_list['data_rtw_pass'].'</td>
					            	<td>'.$class_room_list['data_rtw_nopass'].'</td>
					            	<td>'.$class_room_list['std_amount'].'</td>
					            </tr>
					            
		            
			';
				$amount_data_40=$amount_data_40+$class_room_list['data_40'];
				$amount_data_35=$amount_data_35+$class_room_list['data_35'];
				$amount_data_30=$amount_data_30+$class_room_list['data_30'];
				$amount_data_25=$amount_data_25+$class_room_list['data_25'];
				$amount_data_20=$amount_data_20+$class_room_list['data_20'];
				$amount_data_15=$amount_data_15+$class_room_list['data_15'];
				$amount_data_10=$amount_data_10+$class_room_list['data_10'];
				$amount_data_00=$amount_data_00+$class_room_list['data_00'];
				$amount_data_l=$amount_data_l+$class_room_list['data_l'];
				$amount_data_ms=$amount_data_ms+$class_room_list['data_ms'];

				$amount_desirable_verygood=$amount_desirable_verygood+$class_room_list['data_desirable_verygood'];
				$amount_desirable_good=$amount_desirable_good+$class_room_list['data_desirable_good'];
				$amount_desirable_pass=$amount_desirable_pass+$class_room_list['data_desirable_pass'];
				$amount_desirable_nopass=$amount_desirable_nopass+$class_room_list['data_desirable_nopass'];

				$amount_rtw_verygood=$amount_rtw_verygood+$class_room_list['data_rtw_verygood'];
				$amount_rtw_good=$amount_rtw_good+$class_room_list['data_rtw_good'];
				$amount_rtw_pass=$amount_rtw_pass+$class_room_list['data_rtw_pass'];
				$amount_rtw_nopass=$amount_rtw_nopass+$class_room_list['data_rtw_nopass'];
				$all_std_amount=$all_std_amount+$class_room_list['std_amount'];
				$order++;
			}
			$data_response.='
				<tr>
	            	<td colspan="3">รวม</td>
	            	<td>'.$amount_data_40.'</td>
	            	<td>'.$amount_data_35.'</td>
	            	<td>'.$amount_data_30.'</td>
	            	<td>'.$amount_data_25.'</td>
	            	<td>'.$amount_data_20.'</td>
	            	<td>'.$amount_data_15.'</td>
	            	<td>'.$amount_data_10.'</td>
	            	<td>'.$amount_data_00.'</td>
	            	<td>'.$amount_data_l.'</td>
	            	<td>'.$amount_data_ms.'</td>
	            	<td>'.$amount_desirable_verygood.'</td>
	            	<td>'.$amount_desirable_good.'</td>
	            	<td>'.$amount_desirable_pass.'</td>
	            	<td>'.$amount_desirable_nopass.'</td>
	            	<td>'.$amount_rtw_verygood.'</td>
	            	<td>'.$amount_rtw_good.'</td>
	            	<td>'.$amount_rtw_pass.'</td>
	            	<td>'.$amount_rtw_nopass.'</td>
	            	<td>'.$all_std_amount.'</td>
	            </tr>
	            <tr>
	            	<td colspan="3">ร้อยละ</td>
	            	<td>'.number_format(($amount_data_40*100)/$all_std_amount,2).'</td>
	            	<td>'.number_format(($amount_data_35*100)/$all_std_amount,2).'</td>
	            	<td>'.number_format(($amount_data_30*100)/$all_std_amount,2).'</td>
	            	<td>'.number_format(($amount_data_25*100)/$all_std_amount,2).'</td>
	            	<td>'.number_format(($amount_data_20*100)/$all_std_amount,2).'</td>
	            	<td>'.number_format(($amount_data_15*100)/$all_std_amount,2).'</td>
	            	<td>'.number_format(($amount_data_10*100)/$all_std_amount,2).'</td>
	            	<td>'.number_format(($amount_data_00*100)/$all_std_amount,2).'</td>
	            	<td>'.number_format(($amount_data_l*100)/$all_std_amount,2).'</td>
	            	<td>'.number_format(($amount_data_ms*100)/$all_std_amount,2).'</td>
	            	<td>'.number_format(($amount_desirable_verygood*100)/$all_std_amount,2).'</td>
	            	<td>'.number_format(($amount_desirable_good*100)/$all_std_amount,2).'</td>
	            	<td>'.number_format(($amount_desirable_pass*100)/$all_std_amount,2).'</td>
	            	<td>'.number_format(($amount_desirable_nopass*100)/$all_std_amount,2).'</td>
	            	<td>'.number_format(($amount_rtw_verygood*100)/$all_std_amount,2).'</td>
	            	<td>'.number_format(($amount_rtw_good*100)/$all_std_amount,2).'</td>
	            	<td>'.number_format(($amount_rtw_pass*100)/$all_std_amount,2).'</td>
	            	<td>'.number_format(($amount_rtw_nopass*100)/$all_std_amount,2).'</td>
	            	<td>100.0</td>
	            </tr>
			';
		return $data_response;
	}
	public function get_rtw($department_set,$class_level,$year,$term){
		$this->sql ="SELECT *
						FROM tbl_sub_pp6
						WHERE status=1
						AND department=$department_set
						AND pp6_ID in(
							SELECT DataID
							FROM tbl_pp6
							WHERE class_level='$class_level'
							AND term='$term'
							AND year='$year'
							
						)
							";
			$this->select();
			$this->setRows();
			$data_rtw_nopass=0;
			$data_rtw_pass=0;
			$data_rtw_good=0;
			$data_rtw_verygood=0;
			foreach($this->rows as $key => $value) {
				$score_rtw=$value['score_rtw'];
				if ($score_rtw<1) {
					$data_rtw_nopass++;
				}elseif($score_rtw<1.5){
					$data_rtw_pass++;
				}elseif($score_rtw<2.5){
					$data_rtw_good++;
				}elseif($score_rtw>=2.5){
					$data_rtw_verygood++;
				}

			}
			$data_response['data_rtw_nopass']=$data_rtw_nopass;
			$data_response['data_rtw_pass']=$data_rtw_pass;
			$data_response['data_rtw_good']=$data_rtw_good;
			$data_response['data_rtw_verygood']=$data_rtw_verygood;
	
			return $data_response;
		}
		public function get_amount_std($department_set,$class_level,$year,$term){
		$this->sql ="SELECT COUNT(*) as num_row
						FROM tbl_sub_pp6
						WHERE status=1
						AND department=$department_set
						AND pp6_ID in(
							SELECT DataID
							FROM tbl_pp6
							WHERE class_level='$class_level'
							AND term='$term'
							AND year='$year'
							
						)
							";
			$this->select();
			$this->setRows();
			return $this->rows[0]['num_row'];
		}
	public function get_department_data($class_level,$year,$term,$image_logo,$footer_text_cen_normal,$header_table,$department){
		if ($class_level=='p1' || $class_level=='p2' || $class_level=='p3' || $class_level=='p4' || $class_level=='p5' || $class_level=='p6') {
				$class_front_text='ประถมศึกษาปีที่';
			}else{
				$class_front_text='มัธยมศึกษาปีที่';
			}
		$department_text=$this->get_department($department);
		$class_set=1;
		for ($i=1; $i <=3; $i++) { 
			$table_list='';
			if ($i==1) {

				for ($j=1; $j <=2 ; $j++) { 
					$loop_data=$this->get_loop_data($class_level,$year,$term,$department,$i,$class_set);
					$table_list.='
				        <table cellspacing="0"  style=" text-align: center; font-size: 14px;width:100%;margin-top: 20px;">
					          '.$header_table.'
					          <tbody >
					            '.$loop_data.'
					          </tbody>
					        </table>
					';
					$class_set++;
				}
				$data_response['std_list'].='
						<div style="page-break-after:always;">
					      <page >
					        <div style="text-align: center;line-height: 0.6;font-weight: bold;padding-top: 20px;font-size:16px">
					          <img class="logo-print-size-level" src="'.$image_logo.'">
					          <p >รายงานการประเมินผลการเรียนกลุ่มสาระการเรียนรู้ '.$department_text.'</p>
					          <p >โรงเรียนเทศบาลวัดสระทอง สังกัดเทศบาลเมืองร้อยเอ็ด อ.เมือง จ.ร้อยเอ็ด</p>
					          <p>
					            <span style="margin-right: 20px;">ภาคเรียนที่ 
						              <span style="font-weight: normal;">'.$term.'</span>
						            </span> 
					            <span>ปีการศึกษา <span style="font-weight: normal;">'.$year.'</span> </span>
					          </p>
					         
					        </div>
					        '.$table_list.'
					      </page>
					    </div>
					   
			';
			}else{
				$footer='';
				if ($i==3) {
					$footer=$footer_text_cen_normal;
				}
				for ($j=1; $j <=2 ; $j++) { 
					$loop_data=$this->get_loop_data($class_level,$year,$term,$department,$i,$class_set);
					$table_list.='
				        <table cellspacing="0"  style=" text-align: center; font-size: 14px;width:100%;margin-top: 20px;">
					          '.$header_table.'
					          <tbody >
					            '.$loop_data.'
					          </tbody>
					        </table>
					';
					$class_set++;
				}
				$data_response['std_list'].='
						<div style="page-break-after:always;">
					      <page >
					        
					        '.$table_list.'
					       	<div style="margin-top:40px;">
					        	'.$footer.'
					        </div>
					      </page>
					    </div>
					   
			';
		}
		}
		
		return $data_response;
	}
	
	public function get_year(){
		$this->sql ="SELECT  distinct(year) as year
					FROM tbl_registed_course
					ORDER BY year DESC
							";
		$this->select();
		$this->setRows();
		foreach($this->rows as $key => $value) {
			$year=  $value['year'];	
			$data_response.='
					 <option value="'.$year.'">'.$year.'</option>
			';
		}
		return json_encode($data_response);
	}
	public function get_name_title($name_title_data){
		if ($name_title_data=="dekchai") {
			$name_title="เด็กชาย";
		}elseif($name_title_data=="dekying"){
			$name_title="เด็กหญิง";
		}elseif($name_title_data=="nai"){
			$name_title="นาย";
		}else{
			$name_title="นางสาว";
		}
		return $name_title;
	}
	public function get_class_level($class_level_data){
		if ($class_level_data=="p1") {
			$class_level="ป.1";
		}elseif($class_level_data=="p2"){
			$class_level="ป.2";	
		}elseif($class_level_data=="p3"){
			$class_level="ป.3";	
		}elseif($class_level_data=="p4"){
			$class_level="ป.4";	
		}elseif($class_level_data=="p5"){
			$class_level="ป.5";	
		}elseif($class_level_data=="p6"){
			$class_level="ป.6";	
		}elseif($class_level_data=="m1"){
			$class_level="ม.1";	
		}elseif($class_level_data=="m2"){
			$class_level="ม.2";	
		}elseif($class_level_data=="m3"){
			$class_level="ม.3";	
		}elseif($class_level_data=="m4"){
			$class_level="ม.4";	
		}elseif($class_level_data=="m5"){
			$class_level="ม.5";	
		}elseif($class_level_data=="m6"){
			$class_level="ม.6";	
		}
		return $class_level;
	}
	public function get_department($data){
		
		switch ($data) {
		    case 1:
		       	$department='ภาษาไทย';
		        break;
		    case 2:
		        $department='คณิตศาสตร์';
		        break;
		    case 3:
		        $department='วิทยาศาสตร์';
		        break;
		    case 31:
		        $department='วิทยาศาสตร์และเทคโนโลยี';
		        break;    
		    case 4:
		        $department='สังคมศึกษา ศาสนาและวัฒนธรรม';
		        break;
		    case 41:
		        $department='สังคมศึกษา';
		        break;
		    case 42:
		        $department='ภูมิศาสตร์';
		        break;
		    case 43:
		        $department='ประวัติศาสตร์';
		        break;
		    case 5:
		        $department='สุขศึกษาและพลศึกษา';
		        break;
		    case 6:
		        $department='ศิลปะ';
		        break;
		    case 7:
		        $department='การงานอาชีพฯ';
		        break; 
		    case 71:
		        $department='การงานอาชีพ';
		        break; 
		    case 8:
		        $department='ภาษาต่างประเทศ';
		        break;  
		    case 9:
		        $department='หน้าที่พลเมือง';
		        break;     
		    case 10:
		        $department='ศิลปะพื้นบ้าน';
		        break;     
		    case 11:
		        $department='ศักยภาพ';
		        break;     
		    case 12:
		        $department='ภาษาจีน';
		        break;        
		    default:
		     	$department='';
		}
		return $department;
	}
	public function get_grade($total){
		if ($total<50) {
			$grade='0.0';
		}elseif($total<55){
			$grade='1.0';
		}elseif($total<60){
			$grade='1.5';
		}elseif($total<65){
			$grade='2.0';
		}elseif($total<70){
			$grade='2.5';
		}elseif($total<75){
			$grade='3.0';
		}elseif($total<80){
			$grade='3.5';
		}elseif($total>=80){
			$grade='4.0';
		}
		return $grade;
	}
}<file_sep>/modules/conclusion/index.js
var opPage = 'conclusion';
$(document).ready(function() {
	get_year();
});
function get_year(){
	var formData = new Array();
	formData.push({ "name": "acc_action", "value": "get_year" });
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {
		$(".year_data").html(data);
		get_data_list_learning();
		get_data_list_level();
		get_data_list_desirable();
		get_data_list_rtw();
		get_data_list_department();
	})
}
function get_data_list_learning(){
	var formData = $( "#frm_search_learning_result" ).serializeArray();
	formData.push({ "name": "acc_action", "value": "get_data_list_learning" }); 
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {
		$("#table_learning_result_list").html(data);
	})
}
function get_data_list_level(){
	var formData = $( "#frm_search_level_result" ).serializeArray();
	formData.push({ "name": "acc_action", "value": "get_data_list_level" }); 
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {

		$("#table_level_result_list").html(data);
	})
}
function get_data_list_desirable(){
	var formData = $( "#frm_search_desirable_result" ).serializeArray();
	formData.push({ "name": "acc_action", "value": "get_data_list_desirable" }); 
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {

		$("#table_desirable_result_list").html(data);
	})
}
function get_data_list_rtw(){
	var formData = $( "#frm_search_rtw_result" ).serializeArray();
	formData.push({ "name": "acc_action", "value": "get_data_list_rtw" }); 
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {
		
		$("#table_rtw_result_list").html(data);
	})
}
function get_data_list_department(){
	var formData = $( "#frm_search_department_result" ).serializeArray();
	formData.push({ "name": "acc_action", "value": "get_data_list_department" }); 
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {
		$("#table_department_result_list").html(data);
	})
}
$(document).delegate('#btn_department_result', 'click', function(event) {
	get_data_list_department();
})
$(document).delegate('#btn_rtw_result', 'click', function(event) {
	get_data_list_rtw();
})

$(document).delegate('#btn_desirable_result', 'click', function(event) {
	get_data_list_desirable();
})
$(document).delegate('#btn_level_result', 'click', function(event) {
	get_data_list_level();
})
$(document).delegate('#btn_learning_result', 'click', function(event) {
	get_data_list_learning();
})<file_sep>/modules/graduate/process.php
<?php
@ob_start();
@session_start();

require_once('../../init.php');
include('../../src/class.pagination.php');
include('../../src/class.inputfilter.php');
$InputFilter = new InputFilter();

##CLASS_DB_CONNECT##
include('class_modules.php');
$class_data = new ClassData();
##CLASS_DB_CONNECT##

if(isset($_GET['acc_action']) and $_GET['acc_action'] == "edit_status"){
	$class_room_modal_id=$_GET['class_room_modal_id'];	
	$status_val=$_GET['status_val'];	
	echo $class_data->edit_status($class_room_modal_id,$status_val);
}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "getdata_edit"){
	$data_id=$_GET['data_id'];	
	echo $class_data->getdata_edit($data_id);
}
if(isset($_POST['acc_action']) and $_POST['acc_action'] == "data_add"){
	$data_val = $_POST['data_val'];
	echo $class_data->data_add($data_val);
}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_std_list"){
	$class_level=$_GET['class_level'];	
	$room=$_GET['room'];
	$year=$_GET['year'];
	echo $class_data->get_std_list($class_level,$room,$year);
}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_year"){	
	echo $class_data->get_year();
}

?><file_sep>/modules/report/sara_form.php
<link href="../../assets/css/bootstrap.css" rel="stylesheet" type="text/css">
<link href="../../assets/css/custom.css" rel="stylesheet" type="text/css">
<link href="../../assets/css/margin-padding.css" rel="stylesheet" type="text/css">
<link href="../../assets/css/responsive.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
 table {
    border-collapse: collapse;
}

td, th {
    border: 1px solid black;
    padding: 5px;
}
-->
</style>
<?php
 @session_start();
    include('logo.php');
    require_once('../../init.php');
    include('class_modules.php');
    $class_data = new ClassData();
  ?>
<page orientation="portrait">
    <img style="margin :10px 0px 10px 335px;display:block;width: 80px;height: 80px;"src="<?php echo $image_logo ?>">
   	<br>
   	<div class="col-sm-12 text-center " style="font-size: 22px;margin-top: -5px;">
      <p class="text-bold " style="margin-top: -8px;">รายงานสรุปการพัฒนาคุณภาพผู้เรียนตามรายกลุ่มสาระ</p>
      <p class="text-bold " style="margin-top: -8px;">โรงเรียนเทศบาลวัดสระทอง</p>
      <p style="margin-top: -8px;"> <span class="text-bold">ระดับชั้น </span> มัธยมศึกษาปีที่ 1  <span class="text-bold">ภาคเรียนที่</span> 1 <span class="text-bold">ปีการศึกษา </span>2560</p>
    
    </div>
     <table cellspacing="0" style="width: 94%; text-align: center; font-size: 11pt;margin-left: 25px;border: 1px solid black;margin-top: 20px;">
              <thead >
                <tr class="text-middle" style="background-color: #e0e0e0;">
                  <td rowspan="2"  style="  vertical-align: middle;width: 6px;font-weight: bold;">ที่</td>
                  <td rowspan="2"  style="  vertical-align: middle;width: 10%;font-weight: bold;">รหัสวิชา</td>
                  <td rowspan="2"  style="  vertical-align: middle;width: 19%;font-weight: bold;">สาระการเรียนรู้</td>
                  <td rowspan="2"  style="  vertical-align: middle;width: 8%;height: 60px;font-weight: bold;"><div style="rotate:90;margin-left: -4px;margin-top: -30px">จำนวน นักเรียน</div></td>

                  <td colspan="8" style="width: 40%;padding: 5px;font-weight: bold;">ระดับผลการเรียน</td>    
                  <td colspan="2" style="width: 12%;padding: 5px;font-weight: bold;">เกรด 3.0 ขึ้นไป</td>  
                  <td rowspan="2"  style="vertical-align: middle;width: 8%;"><div style="rotate:90;margin-left: -8px;font-weight: bold;">หมายเหตุ</div></td> 
                </tr>
                <tr style="background-color: #e0e0e0;">
                  
                  <td style="width: 3%;border-left: none;">4.0</td>
                  <td style="width: 3%;">3.5</td>
                  <td style="width: 3%;">3.0</td>
                  <td style="width: 3%;">2.5</td>
                  <td style="width: 3%;">2.0</td>
                  <td style="width: 3%;">1.5</td>
                  <td style="width: 3%;">1.0</td>
                  <td style="width: 3%;">0,ร</td>
                  <td style="width: 3%;"><div style="rotate:90;margin-top: -28px">รวม</div></td>
                  <td style="width: 3%;"><div style="rotate:90;margin-top: -22px;margin-left: -10px;">ร้อยละ</div></td>
                </tr>
              </thead>
              <tbody>
                <tr>
                  <td >1</td>
                  <td >ท11001</td>
                  <td >ภาษาไทย</td>
                  <td >162</td>
                  <td >47</td>
                  <td >34 </td>
                  <td >11</td>
                  <td >0</td>
                  <td >2 </td>
                  <td >0</td>
                  <td >0</td>
                  <td >5</td>
                  <td >149</td>
                  <td >91.98</td>
                  <td ></td>
                </tr>
                <tr>
                  <td >1</td>
                  <td >ท11001</td>
                  <td >ภาษาไทย</td>
                  <td >162</td>
                  <td >47</td>
                  <td >34 </td>
                  <td >11</td>
                  <td >0</td>
                  <td >2 </td>
                  <td >0</td>
                  <td >0</td>
                  <td >5</td>
                  <td >149</td>
                  <td >91.98</td>
                  <td ></td>
                </tr>
                <tr>
                  <td >1</td>
                  <td >ท11001</td>
                  <td >ภาษาไทย</td>
                  <td >162</td>
                  <td >47</td>
                  <td >34 </td>
                  <td >11</td>
                  <td >0</td>
                  <td >2 </td>
                  <td >0</td>
                  <td >0</td>
                  <td >5</td>
                  <td >149</td>
                  <td >91.98</td>
                  <td ></td>
                </tr>
                <tr>
                  <td >1</td>
                  <td >ท11001</td>
                  <td >ภาษาไทย</td>
                  <td >162</td>
                  <td >47</td>
                  <td >34 </td>
                  <td >11</td>
                  <td >0</td>
                  <td >2 </td>
                  <td >0</td>
                  <td >0</td>
                  <td >5</td>
                  <td >149</td>
                  <td >91.98</td>
                  <td ></td>
                </tr>
                <tr>
                  <td colspan="3" class="text-bold">รวม</td>
                  <td >11</td>
                  <td >11</td>
                  <td >162</td>
                  <td >47</td>
                  <td >34 </td>
                  <td >11</td>
                  <td >0</td>
                  <td >2 </td>
                  <td >0</td>
                  <td >0</td>
                  <td >5</td>
                  <td ></td>
                  
                </tr>
                <tr>
                  <td colspan="3" class="text-bold">ร้อยละ</td>
                  <td >11</td>
                  <td >11</td>
                  <td >162</td>
                  <td >47</td>
                  <td >34 </td>
                  <td >11</td>
                  <td >0</td>
                  <td >2 </td>
                  <td >0</td>
                  <td ></td>
                  <td ></td>
                  <td ></td>
                  
                </tr>
                <tr>
                  <td colspan="4" class="text-bold">ระดับผลการเรียน 3.0 ขึ้นไป คิดเป็นร้อยละ</td>
                  <td colspan="3">56.11 </td>
                  <td colspan="5">43.89</td>
                  <td ></td>
                  <td ></td>
                  <td ></td>      
                </tr>
              </tbody>
    </table> 
    <div style="margin-left: 100px;margin-top: 60px;">
      <p>.................................................................หัวหน้างานวัดผล </p>
     
      <p style="margin-left: 2px;">(</p> <p style="margin-top: -24px;margin-left:140px;"> )</p>

      <p style="margin-left: 12px;">................/................/...................</p>
    </div>
    <div style="margin-left: 410px;margin-top: -64px;">
      <p>.................................................................ผู้อำนวยการ </p>
     
      <p style="margin-left: 2px;">(</p> <p style="margin-top: -24px;margin-left:140px;"> )</p>

      <p style="margin-left: 12px;">................/................/...................</p>
    </div>
</page><file_sep>/modules/report_std_personal/process.php
<?php 
@session_start();

require_once('../../init.php');
include('../../src/class.pagination.php');
include('../../src/class.inputfilter.php');
$InputFilter = new InputFilter();

##CLASS_DB_CONNECT##
include('class_modules.php');
$class_data = new ClassData();
##CLASS_DB_CONNECT##

if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_year"){	
	echo $class_data->get_year();
}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_std_list"){	
	$class_search=$_GET['class_data'];
	$room_search=$_GET['room_data'];
	$term_data=$_GET['term_data'];
	$year_data=$_GET['year_data'];
	
	$name_id_search=$_GET['name_id_search'];
	$search_status=$_GET['search_status'];
	
	echo $class_data->get_std_list($class_search,$room_search,$name_id_search,$search_status,$term_data,$year_data);
}
?><file_sep>/modules/regis_teacher/process.php
<?php
@ob_start();
@session_start();

require_once('../../init.php');
include('../../src/class.pagination.php');
include('../../src/class.inputfilter.php');


$InputFilter = new InputFilter();

##CLASS_DB_CONNECT##
include('class_modules.php');
$class_data = new ClassData();
##CLASS_DB_CONNECT##


if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_data_edit"){
	$data_id=$_GET['data_id'];
	echo $class_data->get_data_edit($data_id);
}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_teacher"){
	$status=$_GET['status'];
	$data_search=$_GET['data_search'];
	echo $class_data->get_teacher($status,$data_search);
}
if(isset($_POST['acc_action']) and $_POST['acc_action'] == "change_pass"){
	$data_val = $_POST['data_val'];
	echo $class_data->change_pass($data_val);
}
if(isset($_POST['acc_action']) and $_POST['acc_action'] == "data_remove"){
	$data_val = $_POST['data_val'];
	echo $class_data->get_data_delete($data_val);
}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_years"){
	echo $class_data->get_years();
}

if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_day_edit"){
	$mouth=$_GET['mouth'];
	echo $class_data->get_day_edit($mouth);
}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_day"){
	$mouth=$_GET['mouth'];
	echo $class_data->get_day($mouth);
}
if(isset($_POST['acc_action']) and $_POST['acc_action'] == "edit_teacher"){

		$user_id=$_POST['data_id'];
		$day=$_POST['day'];
		$month=$_POST['mouth'];
		$years=$_POST['years']-543;
		$birthday=$years.'-'.$month.'-'.$day;
		$arr_sql[]="positionID='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['positionID'])))."'";
		$arr_sql[]="fname_th='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['fname_th'])))."'";
		$arr_sql[]="lname_th='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['lname_th'])))."'";
		$arr_sql[]="fname_en='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['fname_en'])))."'";
		$arr_sql[]="lname_en='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['lname_en'])))."'";

		$arr_sql[]="birthday='".chkhtmlspecialchars($InputFilter->clean_script(trim($birthday)))."'";

		$arr_sql[]="study_history='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['study_history'])))."'";
		$arr_sql[]="gender='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['gender'])))."'";
		$arr_sql[]="blood_group='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['blood_group'])))."'";
		$arr_sql[]="address='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['address'])))."'";
		$arr_sql[]="position_name='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['position_name'])))."'";
		$arr_sql[]="department='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['department'])))."'";
		$arr_sql[]="work='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['work'])))."'";	
		$arr_sql[]="more_detail='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['more_detail'])))."'";	
		$arr_sql[]="tell='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['tell'])))."'";	
		$arr_sql[]="email='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['email'])))."'";	
		$arr_sql[]="status_alive='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['status_alive'])))."'";

		$class_data->update_data($arr_sql,$user_id);
	}
if(isset($_POST['acc_action']) and $_POST['acc_action'] == "save_data"){
	$arr_sql = array();
		$day=$_POST['day'];
		$mouth=$_POST['mouth'];
		$years=$_POST['years']-543;
		$user_l=substr($_POST['lname_en'], 0, 1);
		$username=$_POST['fname_en'].'.'.$user_l;
		$password=$<PASSWORD>'.$<PASSWORD>.$_POST['years'];
		$birthday=$years.'-'.$mouth.'-'.$day;
			$arr_sql["positionID"]="'".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['positionID'])))."'";	
			$arr_sql["username"]="'".chkhtmlspecialchars($InputFilter->clean_script(trim($username)))."'";		
			$arr_sql["password"]= "'".MD5($password)."'";

			$arr_sql["position_name"]="'".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['position_name'])))."'";
			$arr_sql["fname_th"]="'".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['fname_th'])))."'";
			
			$arr_sql["lname_th"]="'".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['lname_th'])))."'";	
			$arr_sql["fname_en"]="'".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['fname_en'])))."'";
			$arr_sql["lname_en"]="'".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['lname_en'])))."'";
			$arr_sql["birthday"]="'".chkhtmlspecialchars($InputFilter->clean_script(trim($birthday)))."'";
			$arr_sql["blood_group"]="'".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['blood_group'])))."'";
			$arr_sql["gender"]="'".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['gender'])))."'";
			$arr_sql["tell"]="'".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['tell'])))."'";
			$arr_sql["email"]="'".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['email'])))."'";
			$arr_sql["address"]="'".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['address'])))."'";	
			$arr_sql["status_alive"]="'".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['status_alive'])))."'";		

			$arr_sql["cdate"]="now()"; 		
			$arr_sql["status"]=1; 
		if ($class_data->insert_data($arr_sql)) {
			echo "Y";
		}else{
			echo "N";
		}
}<file_sep>/modules/conclusion/index.php
<div class="container set-content-pad-20" >
  <div class="bg-whte" style="position: relative;padding-bottom: 60px">
    <div class="circle-bg-violet">
      <img class="head-img-circle" src="assets/images/report.png">
    </div>
    <div class="text-head-title">
      <p>รายงานสรุปผล</p>
    </div>
    <div class="row pd-50 pt-100 stage-set" >
      <div class="col-sm-12 mb-20 ">
        <ul class="nav nav-tabs" role="tablist">                  
          <li role="presentation" class="active">
            <a class="text-black fs-13 text-bold" href="#learning_result_tab" aria-controls="learning_result_tab" role="tab" data-toggle="tab">ผลการเรียน</a>
          </li>
          <li role="presentation" >
            <a class="text-black fs-13 text-bold" href="#dev_result_tab" aria-controls="dev_result_tab" role="tab" data-toggle="tab">ผลการพัฒนาคุณภาพผู้เรียน</a>
          </li>
          <li role="presentation" >
            <a class="text-black fs-13 text-bold" href="#desirable_result_tab" aria-controls="desirable_result_tab" role="tab" data-toggle="tab">ผลการพัฒนาคุณลักษณะฯ</a>
          </li>
          <li role="presentation">
            <a class="text-black fs-13 text-bold" href="#rtw_re_tab" aria-controls="rtw_re_tab" role="tab" data-toggle="tab">ผลการพัฒนาทักษะการอ่านฯ</a>
          </li>
          <li role="presentation" >
            <a class="text-black fs-13 text-bold" href="#department_result_tab" aria-controls="department_result_tab" role="tab" data-toggle="tab">ผลการเรียนตามกลุ่มสาระฯ</a>
          </li>
        </ul>
      </div>
      <div class="tab-content">
        <?php include "include/learning_result_tab.php"?>
        <?php include "include/dev_result_tab.php"?>
        <?php include "include/desirable_result_tab.php"?>
        <?php include "include/rtw_re_tab.php"?>
        <?php include "include/department_result_tab.php"?>
      </div>  
    </div>
  </div>
</div> 



<file_sep>/modules/home/index.php
﻿<div class="container set-content" >    
  <?php
    if ($view_user_ath == 4) {//สายชั้น
  ?>  
   <div class="col-sm-6 col-md-4 mt-25">
    <div class="card-menu card-border">
      <img src="assets/images/1.png">
      <p class="text-card-title">ลงทะเบียนรายวิชา</p>
      <div class="line-incard"></div>
      <div class="btn-select-main">
        <p><a class="text-violet" href="index.php?op=regis_course-index">เลือก</a></p>
      </div>
    </div>
  </div>
  <div class="col-sm-6 col-md-4 mt-25">
    <div class="card-menu card-border">
      <img src="assets/images/report.png">
      <p class="text-card-title">รายงานสรุปผล</p>
      <div class="line-incard"></div>
      <div class="btn-select-main">
        <p><a class="text-violet" href="index.php?op=conclusion-index">เลือก</a></p>
      </div>
    </div>
  </div>
<?php } ?>
  <?php
    if ($view_user_ath == 2) {
  ?>     
  <div class="col-sm-6 col-md-4 mt-25">
    <div class="card-menu card-border">
      <img src="assets/images/2.png">
      <p class="text-card-title">เพิ่ม/ลบ/แก้ไขรายวิชา</p>
      <div class="line-incard"></div>
      <div class="btn-select-main">
        <p><a class="text-violet" href="index.php?op=add_delete_course-index">เลือก</a></p>
      </div>
    </div>
  </div>
  <div class="col-sm-6 col-md-4 mt-25">
    <div class="card-menu card-border">
      <img src="assets/images/1.png">
      <p class="text-card-title">ลงทะเบียนรายวิชา</p>
      <div class="line-incard"></div>
      <div class="btn-select-main">
        <p><a class="text-violet" href="index.php?op=regis_course-index">เลือก</a></p>
      </div>
    </div>
  </div>
  <div class="col-sm-6 col-md-4 mt-25">
    <div class="card-menu card-border">
      <img src="assets/images/3.png">
      <p class="text-card-title">จัดการข้อมูลครู</p>
      <div class="line-incard"></div>
      <div class="btn-select-main">
        <p><a  class="text-violet" href="index.php?op=regis_teacher-index">เลือก</a></p>
      </div>
    </div>
  </div>


  <div class="col-sm-6 col-md-4 mt-25 ">
    <div class="card-menu card-border">
      <img src="assets/images/4.png">
      <p class="text-card-title">ลงทะเบียนนักเรียน</p>
      <div class="line-incard"></div>
      <div class="btn-select-main">
        <p><a class="text-violet" href="index.php?op=regis_student-index">เลือก</a></p>
      </div>
    </div>
  </div>
  <div class="col-sm-6 col-md-4 mt-25">
    <div class="card-menu card-border">
      <img src="assets/images/5.png">
      <p class="text-card-title">แก้ไข/ลบข้อมูลนักเรียน</p>
      <div class="line-incard"></div>
      <div class="btn-select-main">
        <p><a class="text-violet" href="index.php?op=maneger_student-index">เลือก</a></p>
      </div>
    </div>
  </div>
 

  <div class="col-sm-6 col-md-4 mt-25">
    <div class="card-menu card-border">
      <img src="assets/images/9.png">
      <p class="text-card-title">บันทึกการเข้าเรียน</p>
      <div class="line-incard"></div>
      <div class="btn-select-main">
        <p><a class="text-violet" href="index.php?op=attend_class-index">เลือก</a></p>
      </div>
    </div>
  </div>
  <div class="col-sm-6 col-md-4 mt-25">
    <div class="card-menu card-border">
      <img src="assets/images/8.png">
      <p class="text-card-title">บันทึกคะแนน</p>
      <div class="line-incard"></div>
      <div class="btn-select-main">
        <p><a class="text-violet" href="index.php?op=save_score-index">เลือก</a></p>
      </div>
    </div>
  </div>
  <div class="col-sm-6 col-md-4 mt-25">
    <div class="card-menu card-border">
      <img src="assets/images/gra.png" >
      <p class="text-card-title">สำเร็จการศึกษา</p>
      <div class="line-incard"></div>
      <div class="btn-select-main">
        <p><a class="text-violet" href="index.php?op=graduate-index">เลือก</a></p>
      </div>
    </div>
  </div>
  <div class="col-sm-6 col-md-4 mt-25">
    <div class="card-menu card-border">
      <img src="assets/images/class.png">
      <p class="text-card-title">เลื่อนชั้น</p>
      <div class="line-incard"></div>
      <div class="btn-select-main">
        <p><a class="text-violet" href="index.php?op=up_class-index">เลือก</a></p>
      </div>
    </div>
  </div>
  
  
  <div class="col-sm-6 col-md-4 mt-25">
    <div class="card-menu card-border">
      <img src="assets/images/report.png">
      <p class="text-card-title">รายงานสรุปผล</p>
      <div class="line-incard"></div>
      <div class="btn-select-main">
        <p><a class="text-violet" href="index.php?op=conclusion-index">เลือก</a></p>
      </div>
    </div>
  </div>
  <?php  } ?>
  <?php
   if ($view_user_ath == 1) {
  ?>
   <div class="col-sm-6 col-md-4 mt-25">
    <div class="card-menu card-border">
      <img src="assets/images/7.png">
      <p class="text-card-title">จัดการรายวิชา</p>
      <div class="line-incard"></div>
      <div class="btn-select-main">
        <p><a class="text-violet" href="index.php?op=regis_course_teaching-index">เลือก</a></p>
      </div>
    </div>
  </div>
  <div class="col-sm-6 col-md-4 mt-25">
    <div class="card-menu card-border">
      <img src="assets/images/9.png">
      <p class="text-card-title">บันทึกการเข้าเรียน</p>
      <div class="line-incard"></div>
      <div class="btn-select-main">
        <p><a class="text-violet" href="index.php?op=attend_class-index">เลือก</a></p>
      </div>
    </div>
  </div>
  <div class="col-sm-6 col-md-4 mt-25">
    <div class="card-menu card-border">
      <img src="assets/images/8.png">
      <p class="text-card-title">บันทึกคะแนน</p>
      <div class="line-incard"></div>
      <div class="btn-select-main">
        <p><a class="text-violet" href="index.php?op=save_score-index">เลือก</a></p>
      </div>
    </div>
  </div>
  
<?php  } ?>
 <?php
   if ($view_user_ath == 3) {
  ?>
    <div class="col-sm-6 col-md-4 mt-25">
    <div class="card-menu card-border">
      <img src="assets/images/6.png">
      <p class="newactivi-text">ประกาศข่าว/กิจกรรม <br>Mobile Application</p>                       
      <div class="line-incard"></div>
      <div class="btn-select-main">
        <p><a class="text-violet" href="index.php?op=news-index">เลือก</a></p>
      </div>
    </div>
  </div>
  
<?php  } ?>
</div>

<file_sep>/modules/chk_grade/class_modules.php
<?php 
class ClassData extends Databases {
	public function get_course_detail($courseID,$term_data,$year){
		$data_response = array();	
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 
					WHERE DataID=41
					AND DataID in(
						SELECT courseID
						FROM tbl_registed_course
						WHERE term='$term_data'
						AND year='$year'
					)
					";
		$this->select();
		$this->setRows();	
		$data_response['courseID']=$this->rows[0]['courseID'];
		$data_response['name']=$this->rows[0]['name'];
		$data_response['hr_learn']=$this->rows[0]['hr_learn'];
		return $data_response;
	}
	public function get_course_id($term_data,$year,$user_id,$pp6_ID){	
		 $this->sql =" SELECT class_level
                     FROM tbl_pp6
                     WHERE DataID = $pp6_ID
                ";
        $this->select();
        $this->setRows();	
        $class_level=$this->rows[0]['class_level'];

		$this->sql ="
					SELECT *
					FROM tbl_sub_pp6
					WHERE pp6_ID = $pp6_ID
					ORDER BY status ASC
					";
		$this->select();
		$this->setRows();	
		$sum_course_score=0;
		$sum_cproportion_score=0;
		$find_gpa_sum=0;
		$find_unit_sum=0;

		$grade_sum=0;
		$count_loop=0;
		foreach($this->rows as $key => $value) {
			$coures_id_list_val=$value['sub_ID'];
			$courseID=$value['courseID'];
			$name=$value['name'];
			$unit=$value['unit'];

			$status=$value['status'];
			if ($status==1) {	
				if($class_level=='p1' || $class_level=='p2' || $class_level=='p3' || $class_level=='p4' || $class_level=='p5' || $class_level=='p6'){
                    $name=$this-> get_department($value['department']);
                }else{
					$name=$name;
				}
				$score_total=$value['score_total'];
				if($score_total==-1){
                    $score_total=$value['score_mid']+$value['score_final'];
                    $grade='ร';
                }else{
                    $grade=$this->get_grade_text($score_total);
                }
				$std_list.='
							 <tr>
				                  <td>'.$courseID.'</td>
				                  <td>'.$name.'</td>
				                  <td>'.$score_total.'</td>
				                  <td>'.$unit.'</td>
				                  <td>'.$grade.'</td>			                  
				            </tr>
				';
				
			}else{

                $score_attend=$value['score_attend'];
                if($score_attend==-1){
                    $grade='ไม่ผ่าน';
                }else{
                    $grade='ผ่าน';
                }
				$std_list.='
							 <tr>
				                  <td>'.$courseID.'</td>
				                  <td>'.$name.'</td>
				                  <td style="font-weight:bold">-</td>
				                  <td style="font-weight:bold">-</td>
				                  <td>'.$grade.'</td>			                  
				            </tr>
				';
			}
		}

		$data_response['std_list']=$std_list;

		return $data_response;
	}
	public function get_score_attend_class($std_ID,$coures_id_list_val,$term_data,$year){
		$registed_courseID=$this->get_registed_courseID($coures_id_list_val,$term_data,$year);
		$this->sql ="SELECT COUNT(course_teaching_std_id) as sum_no_come
					FROM tbl_attend_class_std 
					WHERE course_teaching_std_id IN(
						SELECT DataID
						FROM tbl_course_teaching_std
						WHERE registed_courseID=$registed_courseID
						AND stdID=$std_ID
					)	
					AND set_attend_day_id IN(
						SELECT DataID
						FROM tbl_set_attend_day
						WHERE registed_course_teachingID IN(
							SELECT DataID
							FROM tbl_registed_course_teaching
							WHERE registed_courseID=$registed_courseID
						)
					)
					";
		$this->select();
		$this->setRows();	
		$sum_no_come=$this->rows[0]['sum_no_come'];
		
		$registed_course_teaching_id=$this->get_registed_course_id($coures_id_list_val,$term_data,$year);
		$this->sql ="SELECT  COUNT(*) as num_day
					FROM tbl_set_attend_day 	
					WHERE registed_course_teachingID=$registed_course_teaching_id
					";
		$this->select();
		$this->setRows();
		$num_day=$this->rows[0]['num_day'];	
		$class_level_status=$this->get_class_level_status($coures_id_list_val);
		if ($class_level_status['class_data']=='p' || $class_level_status['status']==2) {
			$week_all=40;
		}else{
			$week_all=20;
		}
		$total_day=$num_day*$week_all;
		$total_attend_per=round((($total_day-$sum_no_come)*100)/$total_day);

		if ($total_attend_per>=80) {
			$find_80_per='pass';
		}else{
			$find_80_per='nopass';
		}
		
		return $find_80_per;
	}
	public function get_class_level_status($coures_id_list_val){
		$data_response = array();	
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 	
					WHERE DataID=$coures_id_list_val
					";
		$this->select();
		$this->setRows();		
		$class_level=$this->rows[0]['class_level'];	
		$data_response['status']=$this->rows[0]['status'];	
		if ($class_level=='p1' || $class_level=='p2' || $class_level=='p3' || $class_level=='p4' || $class_level=='p5' || $class_level=='p6') {
			$data_response['class_data']='p';
		}else{
			$data_response['class_data']='m';
		}
		return $data_response;
	}
	public function get_registed_course_id($coures_id_list,$term_data,$year){
		

		$this->sql ="SELECT  *
					FROM tbl_registed_course_teaching 	
					WHERE registed_courseID in(
						SELECT DataID
						FROM tbl_registed_course 
						WHERE term='$term_data'
						AND year='$year'
						AND courseID=$coures_id_list
					)
					";
		$this->select();
		$this->setRows();
		return $this->rows[0]['DataID'];	
	}
	public function get_proportion_title($coures_id_list_val){
			$this->sql ="SELECT * 
					FROM tbl_proportion 
					WHERE courseID=$coures_id_list_val
					";
		$this->select();
		$this->setRows();	
		$comulative=$this->rows[0]['comulative'];
		$mid_exam=$this->rows[0]['mid_exam'];
		$final_exam=$this->rows[0]['final_exam'];
		return $comulative+$mid_exam+$final_exam;
	}
	public function get_grade_text($score_exam,$score_pick){
		$total=$score_exam+$score_pick;
		if ($total<50) {
			$grade='0.0';
		}elseif($total<55){
			$grade='1.0';
		}elseif($total<60){
			$grade='1.5';
		}elseif($total<65){
			$grade='2.0';
		}elseif($total<70){
			$grade='2.5';
		}elseif($total<75){
			$grade='3.0';
		}elseif($total<80){
			$grade='3.5';
		}elseif($total>=80){
			$grade='4.0';
		}
		return $grade;
	}
	public function get_registed_courseID($coures_id_list_val,$term_data,$year){
		
		$this->sql ="SELECT  *
					FROM tbl_registed_course 	
					WHERE courseID=$coures_id_list_val
					AND term='$term_data'
					AND year='$year'

					";
		$this->select();
		$this->setRows();		
		return $this->rows[0]['DataID'];	
	}
	public function get_score_pick($std_ID,$coures_id_list_val,$term_data,$year){
		$registed_courseID=$this->get_registed_courseID($coures_id_list_val,$term_data,$year);
		$num_of_i=0;
		$this->sql ="SELECT  COUNT(score) as num_of_i
					FROM tbl_objective_score_std 	
					WHERE staID='$std_ID'
					AND registed_courseID=$registed_courseID
					AND score=-1
					";
		$this->select();
		$this->setRows();
		$num_of_i=$this->rows[0]['num_of_i'];			
		$this->sql ="SELECT  SUM(score) as score_total
					FROM tbl_objective_score_std 	
					WHERE staID='$std_ID'
					AND registed_courseID=$registed_courseID
					";
		$this->select();
		$this->setRows();	
		$score_total_data=$this->rows[0]['score_total'];
		if ($num_of_i>0) {
			$total='i';
		}else{
			$total=$score_total_data;
		}
			return $total;
	}
	public function get_score_exam($std_ID,$coures_id_list_val,$term_set,$year_set){	
	$this->sql ="SELECT  *
					FROM tbl_set_term_year 			
							";
		$this->select();
		$this->setRows();
		/*$term_set=$this->rows[0]['term'];
		$year_set=$this->rows[0]['year'];*/
		$data_response = array();	
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 	
					WHERE DataID=$coures_id_list_val
					
					";
		$this->select();
		$this->setRows();		
		$class_level_data=$this->rows[0]['class_level'];	
		$data_response['class_level']=$this->get_class_level_new($class_level_data);
		if ($class_level_data=='p1' || $class_level_data=='p2' || $class_level_data=='p3' || $class_level_data=='p4' || $class_level_data=='p5' || $class_level_data=='p6' ) {
			$term_set='1,2';
		}	
		$mid_status=0;
		$final_status=0;
		$this->sql ="SELECT  COUNT(score) as num_of_i_mid
					FROM tbl_mid_exam_score
					WHERE stdID='$std_ID' 
					AND score=-1
					AND course_teachingID in(
						SELECT DataID
						FROM tbl_registed_course_teaching
						WHERE registed_courseID in(
							SELECT DataID
							FROM tbl_registed_course
							WHERE courseID=$coures_id_list_val
							AND term='$term_set'
							AND year='$year_set'
						)
					)
					";
		$this->select();
		$this->setRows();	
		$num_of_i_mid=$this->rows[0]['num_of_i_mid'];
		if ($num_of_i_mid>0) {
			$mid_status=-1;
		}
		$this->sql ="SELECT  *
					FROM tbl_mid_exam_score
					WHERE stdID='$std_ID'
					AND course_teachingID in(
						SELECT DataID
						FROM tbl_registed_course_teaching
						WHERE registed_courseID in(
							SELECT DataID
							FROM tbl_registed_course
							WHERE courseID=$coures_id_list_val
							AND term='$term_set'
							AND year='$year_set'
						)
					)
					";
		$this->select();
		$this->setRows();	
		$mid_exam_score=$this->rows[0]['score'];
		$this->sql ="SELECT  COUNT(score) as num_of_i_final
					FROM tbl_final_exam_score
					WHERE stdID='$std_ID'
					AND score=-1
					AND course_teachingID in(
						SELECT DataID
						FROM tbl_registed_course_teaching
						WHERE registed_courseID in(
							SELECT DataID
							FROM tbl_registed_course
							WHERE courseID=$coures_id_list_val
							AND term='$term_set'
							AND year='$year_set'
						)
					)
					";
		$this->select();
		$this->setRows();	
		$num_of_i_final=$this->rows[0]['num_of_i_final'];

		if ($num_of_i_final>0) {
			$final_status=-1;
		}
		$this->sql ="SELECT  *
					FROM tbl_final_exam_score 
					WHERE stdID='$std_ID'
					AND course_teachingID in(
						SELECT DataID
						FROM tbl_registed_course_teaching
						WHERE registed_courseID in(
							SELECT DataID
							FROM tbl_registed_course
							WHERE courseID=$coures_id_list_val
							AND term='$term_set'
							AND year='$year_set'
						)
					)
					";
		$this->select();
		$this->setRows();	
		$final_exam_score=$this->rows[0]['score'];
		if ($mid_status==-1 || $final_status==-1) {
			$total='i';
		}else{
			$total=$mid_exam_score+$final_exam_score;
		}
		return $total;
	}
	public function get_class_level_new($class_level_data){
		if ($class_level_data=="p1") {
			$class_level="ป.1";
		}elseif($class_level_data=="p2"){
			$class_level="ป.2";	
		}elseif($class_level_data=="p3"){
			$class_level="ป.3";	
		}elseif($class_level_data=="p4"){
			$class_level="ป.4";	
		}elseif($class_level_data=="p5"){
			$class_level="ป.5";	
		}elseif($class_level_data=="p6"){
			$class_level="ป.6";	
		}elseif($class_level_data=="m1"){
			$class_level="ม.1";	
		}elseif($class_level_data=="m2"){
			$class_level="ม.2";	
		}elseif($class_level_data=="m3"){
			$class_level="ม.3";	
		}elseif($class_level_data=="m4"){
			$class_level="ม.4";	
		}elseif($class_level_data=="m5"){
			$class_level="ม.5";	
		}elseif($class_level_data=="m6"){
			$class_level="ม.6";	
		}
		return $class_level;
	}
	
	
	public function get_pick_poi($registed_courseID,$stdID,$term_data,$year){
		$this->sql ="SELECT SUM(score) as sum_score
					FROM tbl_objective_score_std
					WHERE registed_courseID=$registed_courseID
					AND staID='$stdID'
					AND objectiveID in(
						SELECT DataID
						FROM tbl_objective_conclude

					)

		";
		$this->select();
		$this->setRows();
		return $this->rows[0]['sum_score'];
	}
	public function get_unit($registed_courseID){
		$data_response = array();	
		$this->sql ="SELECT *
					FROM tbl_add_delete_course
					WHERE DataID in(
						SELECT courseID
						FROM tbl_registed_course
						WHERE DataID=$registed_courseID
					)

		";
		$this->select();
		$this->setRows();	
		return $this->rows[0]['unit'];
	}
	public function get_final_poi($registed_courseID,$stdID,$term_data,$year){
		$this->sql ="SELECT *
					FROM tbl_final_exam_score
					WHERE stdID='$stdID'
					AND course_teachingID in(
						SELECT DataID
						FROM tbl_registed_course_teaching
						WHERE registed_courseID in(
							SELECT DataID
							FROM tbl_registed_course
							WHERE DataID=$registed_courseID
							AND term='$term_data'
							AND year=$year
						)
					)
					";
			$this->select();
			$this->setRows();	
			return $this->rows[0]['score'];
	}
	public function get_mid_poi($registed_courseID,$stdID,$term_data,$year){
		$this->sql ="SELECT *
					FROM tbl_mid_exam_score
					WHERE stdID='$stdID'
					AND course_teachingID in(
						SELECT DataID
						FROM tbl_registed_course_teaching
						WHERE registed_courseID in(
							SELECT DataID
							FROM tbl_registed_course
							WHERE DataID=$registed_courseID
							AND term='$term_data'
							AND year=$year
						)
					)
					";
			$this->select();
			$this->setRows();	
			return $this->rows[0]['score'];
	}
	public function get_data_big_std($stdID,$term_data,$year){
		$this->sql ="SELECT *
					FROM tbl_course_teaching_std
					WHERE stdID='$stdID'
					AND registed_courseID IN(
						SELECT DataID
						FROM tbl_registed_course
						WHERE term='$term_data'
						AND year=$year
					)

		";
		$this->select();
		$this->setRows();
		$find_gpa_sum=0;
		$find_unit_sum=0;
		$find_score_no_cal=0;
		foreach($this->rows as $key => $value) {
			$registed_courseID=$value['registed_courseID'];
			$final_poi= $this->get_final_poi($registed_courseID,$stdID,$term_data,$year);
			$mid_poi= $this->get_mid_poi($registed_courseID,$stdID,$term_data,$year);
			$score_exam=$final_poi+$mid_poi;
			$pick_poi= $this->get_pick_poi($registed_courseID,$stdID,$term_data,$year);
			$grade_text=$this->get_grade_text($score_exam,$pick_poi);
			$unit=$this->get_unit($registed_courseID);	
			//$total=$final_poi+$mid_poi+$pick_poi;
			$find_gpa=$grade_text*$unit;
			$find_gpa_sum=$find_gpa_sum+$find_gpa;
			$find_unit_sum=$find_unit_sum+$unit;
			$total_score_no_cal=$final_poi+$mid_poi+$pick_poi;

			$find_score_no_cal=$find_score_no_cal+$total_score_no_cal;
		}
		$gpa=$find_gpa_sum/$find_unit_sum;
		return $find_score_no_cal;
	}
	public function find_position($year_data,$class_level_data,$room){
		$data_response = array();	
		$this->sql ="SELECT distinct(tbl_pp6.std_ID) as std_pp6_id,tbl_pp6.DataID as pp6_id
					FROM tbl_pp6,tbl_sub_pp6
					WHERE tbl_pp6.DataID=tbl_sub_pp6.pp6_ID
					AND tbl_pp6.year='$year_data'
					AND tbl_pp6.room='$room'
					AND tbl_pp6.class_level='$class_level_data'
					AND tbl_sub_pp6.status=1
		";
		$this->select();
		$this->setRows();
		$find_gpa_sum=0;	
		$score_final_count=0;
		foreach($this->rows as $key => $value) {
			 $std_pp6_id=$value['std_pp6_id'];
			 $pp6_id=$value['pp6_id'];
			 if($class_level_data=='p1' || $class_level_data=='p2' || $class_level_data=='p3' || $class_level_data=='p4' || $class_level_data=='p5' || $class_level_data=='p6'){
				$data_big_std= $this->get_data_big_std_p($std_pp6_id,$pp6_id);
			}else{
				$data_big_std= $this->get_data_big_std_m($std_pp6_id,$pp6_id);
			}
			
			 $test[$std_pp6_id] = $data_big_std;
			
		}
		return $test;
	}
	public function getMax($position){	
	   for ($i=0; $i <count($position) ; $i++) { 
	   		$data.=$position[$i];
	   }
	}
	public function arrayValuePositionNew($find_position,$std_ID){	
		$result = array();
		$pos = $real_pos = 0;
		$prev_score = -1;
		foreach ($find_position as $exam_n => $score) {
			$real_pos += 1;// Natural position.
			$pos = ($prev_score != $score) ? $real_pos : $pos;// If I have same score, I have same position in ranking, otherwise, natural position.
			$result[$exam_n] = array(
							 "score" => $score, 
							 "position" => $pos, 
							 "exam_no" => $exam_n
							 );
			$prev_score = $score;// update last score.
		}

		return $result[$std_ID]["position"];
}
	public function arrayValuePosition($value, $array)
		{
		    return array_search($value, array_keys($array));
		}
		public function get_data_big_std_p($std_pp6_id,$pp6_id){
		$this->sql ="SELECT sum(score_total) as sumed
					FROM tbl_pp6,tbl_sub_pp6
					WHERE tbl_pp6.DataID=tbl_sub_pp6.pp6_ID
					AND tbl_sub_pp6.pp6_ID=$pp6_id
					AND score_total!=-1
		";
		$this->select();
		$this->setRows();
		return $this->rows[0]['sumed'];
	}
	public function get_data_big_std_m($std_pp6_id,$pp6_id){
		$this->sql ="SELECT unit,score_total
					FROM tbl_pp6,tbl_sub_pp6
					WHERE tbl_pp6.DataID=tbl_sub_pp6.pp6_ID
					AND tbl_sub_pp6.pp6_ID=$pp6_id
					AND score_total!=-1
		";
		$this->select();
		$this->setRows();
		$find_row_sum=0;
		foreach($this->rows as $key => $value) {
			 $unit=$value['unit'];
			 $score_total=$value['score_total'];
			 $grade= $this->get_grade_val($score_total);
			 $find_row_sum=$find_row_sum+($unit*$grade);
		}
		$this->sql ="SELECT SUM(unit) as unit_sum
					FROM tbl_pp6,tbl_sub_pp6
					WHERE tbl_pp6.DataID=tbl_sub_pp6.pp6_ID
					AND tbl_sub_pp6.pp6_ID=$pp6_id
					AND tbl_sub_pp6.status=1
		";
		$this->select();
		$this->setRows();
		$unit_sum=$this->rows[0]['unit_sum'];
		return $find_row_sum/$unit_sum;
	}
	public function get_grade_val($total){
		if ($total<50) {
			$grade='0.0';
		}elseif($total<55){
			$grade='1.0';
		}elseif($total<60){
			$grade='1.5';
		}elseif($total<65){
			$grade='2.0';
		}elseif($total<70){
			$grade='2.5';
		}elseif($total<75){
			$grade='3.0';
		}elseif($total<80){
			$grade='3.5';
		}elseif($total>=80){
			$grade='4.0';
		}
		return $grade;
	}
	public function get_name_title($name_title_data){
		if ($name_title_data=="dekchai") {
			$name_title="เด็กชาย";
		}elseif($name_title_data=="dekying"){
			$name_title="เด็กหญิง";
		}elseif($name_title_data=="nai"){
			$name_title="นาย";
		}elseif($name_title_data=="nangsaw"){
			$name_title="นางสาว";
		}
		return $name_title;
	}
	public function get_data_room($year,$std_ID){
		$this->sql ="SELECT room
					FROM tbl_std_class_room
					WHERE std_ID='$std_ID'
					AND year='$year'
					";
			$this->select();
			$this->setRows();	
			return $this->rows[0]['room'];
	}
	public function get_grade(){
		$data_response = array();	
		$user_id=$_SESSION['ss_user_id'] ;

		$this->sql ="SELECT tbl_student.name_title,tbl_student.fname,tbl_student.lname,tbl_std_class_room.class_level,tbl_std_class_room.room
					FROM tbl_student , tbl_std_class_room
					WHERE tbl_student.std_ID=tbl_std_class_room.std_ID 
					AND tbl_student.std_ID='$user_id'
					AND tbl_std_class_room.status=1 
					OR tbl_std_class_room.status=2

					";
		$this->select();
		$this->setRows();

		$name_title_data=$this->rows[0]['name_title'];
		$fname=$this->rows[0]['fname'];
		$lname=$this->rows[0]['lname'];
		$class_level_data=$this->rows[0]['class_level'];
		$room=$this->rows[0]['room'];
		$name_title=$this->get_name_title($name_title_data);

		$data_response['std_ID']=$user_id;
		$data_response['full_name']=$name_title.$fname.' '.$lname;
		$data_response['class_level']=$this->get_class_level_new($class_level_data);		
		$data_response['room']=$room;

		
		$this->sql ="
					SELECT DISTINCT(term) as term_data,year,class_level,room,DataID as pp6_ID
					FROM tbl_pp6 
					WHERE std_ID='$user_id'
					ORDER BY year ASC,term ASC
					";
		$this->select();
		$this->setRows();	
		$data_response['menu_year_list']='<td width="80px">ปีการศึกษา</td>';
		$twst=0;
		$find_gpa_set=0;
		$find_unit_sum_set=0;
		
		foreach($this->rows as $key => $value) {
			$pp6_ID=$value['pp6_ID'];
			$term_data=$value['term_data'];	
			$year=$value['year'];
			$class_level=$value['class_level'];
			$room=$value['room'];
			$find_position=$this->find_position($year,$class_level,$room);
			arsort($find_position);
			$arrayValuePosition=$this->arrayValuePositionNew($find_position,$user_id);
			//$arrayValuePosition=$this->arrayValuePosition($user_id,$find_position);
			//$new_position=$arrayValuePosition+1;
			//	$searchForId=$this->searchForId('56010516077',$position);
			$get_course_id=	$this->get_course_id($term_data,$year,$user_id,$pp6_ID);

			//$course_detail=$this->get_course_detail($courseID,$term_data,$year);
			if($class_level=='p1' || $class_level=='p2' || $class_level=='p3' || $class_level=='p4' || $class_level=='p5' || $class_level=='p6'){
				$class_level_status_gpa='เฉลี่ย';
				$class_level_status_gpx='';
				$resaultGpa=$this->get_resaultGpaP($user_id,$term_data,$year);
			}else{
				$class_level_status_gpa='GPA';
				$class_level_status_gpx='GPAX';
				$resaultGpa=$this->get_resaultGpaM($user_id,$term_data,$year);
				$resaultGpax=$this->get_resaultGpax($user_id,$term_data,$year);
			}
			$resaultSum=$this->get_resaultSum($user_id,$term_data,$year);
			$data_response['table_list'].='
				<div id="'.$term_data.$year.'" class=" ml-50 mr-50 mb-50" >                      
			      <div class="row">
			        <div class="col-md-12">
			          <div style="font-family: thsarabun;font-size:20px;">
			            <table class="table border-set-violet" style="text-align: center;">
			              <thead class="header-table">                             
			                <tr>                                 
			                  <td colspan="5">ภาคการศึกษาที่ '.$term_data.'/'.$year.'</td> 
			                                                 
			                </tr>                               
			                <tr class="table-bg-white-sum">
			                  <td width="24%">รหัสวิชา</td>
			                  <td width="34%">รายวิชา</td>
			                  <td width="14%">คะแนน</td>
			                  <td width="14%">หน่วยกิต</td>
			                  <td width="14%">เกรด</td>
			                </tr>
			              </thead>
			              <tbody  >
			               	'.$get_course_id['std_list'].'

			              </tbody>
			            </table> 
			            <table class="table border-set-violet" style="text-align: center;margin-top: -20px;">
			              <thead class="header-table" >                             
			                <tr>
			                 <td rowspan="2" width="72%" style="padding-top: 22px">รวม</td>
			                 <td width="7%">คะแนน</td>
			                 <td width="7%">'.$resaultSum.'</td>
			                 <td width="7%">'.$class_level_status_gpa.'</td>
			                 <td width="7%">'.number_format($resaultGpa,2).'</td>

			               </tr>
			               <tr>
			                 <td>อันดับที่</td>
			                 <td>'.$arrayValuePosition.'</td>
			                 <td>'.$class_level_status_gpx.'</td>
			                 <td>'.$resaultGpax.'</td>
			                 
			               </tr>

			              </tbody>
			            </table> 
			            
			          </div>
			        </div>                                     
			      </div>                        
			    </div>
			';
			 

			$data_response['menu_year_list'].='<td width="80px"><a href="#'.$term_data.$year.'" class="text-black">'.$term_data.'/'.$year.' </a> |</td>';
		
		}

		echo json_encode($data_response);
	}
	public function get_resaultSum($user_id,$term,$year){
		$this->sql ="SELECT SUM(score_total) as score_total
					FROM tbl_sub_pp6 
					WHERE score_total!=-1
					AND pp6_ID in(
						SELECT DataID
						FROM tbl_pp6
						WHERE std_ID=$user_id
						AND year='$year'
                        AND term='$term'
					)
					";
		$this->select();
		$this->setRows();
		$score_total=$this->rows[0]['score_total'];
		if($score_total=='' || $score_total==NULL){
			$score_total=0;
		}
		return $score_total;
	}
	public function get_resaultGpax($user_id,$term,$year){
		$this->sql ="SELECT score_total,unit
					FROM tbl_sub_pp6 
					WHERE status=1
					AND pp6_ID in(
						SELECT DataID
						FROM tbl_pp6
						WHERE std_ID=$user_id
						AND year<=$year
						AND term<=$term
					)
					";
		$this->select();
		$this->setRows();
		$score_row_sum=0;
		$unit_count=0;
		foreach($this->rows as $key => $value) {
			$score_total=$value['score_total'];
			$unit=$value['unit'];
			if($score_total!=-1){
				$grade=$this->get_grade_text($score_total);
				$score_row=$grade*$unit;
				$score_row_sum=$score_row_sum+$score_row;
			}
			
			$unit_count=$unit_count+$unit;
		}
		return number_format($score_row_sum/$unit_count,2);

}
	public function get_resaultGpaM($user_id,$term,$year){
			$this->sql ="SELECT score_total,unit
						FROM tbl_sub_pp6 
						WHERE status=1
						AND pp6_ID in(
							SELECT DataID
							FROM tbl_pp6
							WHERE std_ID=$user_id
							AND year='$year'
							AND term='$term'
						)
						";
			$this->select();
			$this->setRows();
			$score_row_sum=0;
			$unit_count=0;
			foreach($this->rows as $key => $value) {
				$score_total=$value['score_total'];
				$unit=$value['unit'];
				if($score_total!=-1){
					$grade=$this->get_grade_text($score_total);
					$score_row=$grade*$unit;
				}
				$score_row_sum=$score_row_sum+$score_row;
				$unit_count=$unit_count+$unit;
			}
			return number_format($score_row_sum/$unit_count,2);

	}
	public function get_resaultGpaP($user_id,$term,$year){
		$this->sql ="SELECT SUM(score_total) as score_total
					FROM tbl_sub_pp6 
					WHERE score_total!=-1
					AND status=1
					AND pp6_ID in(
						SELECT DataID
						FROM tbl_pp6
						WHERE std_ID=$user_id
						AND year='$year'
                        AND term='$term'
					)
					";
		$this->select();
		$this->setRows();
		$score_total=$this->rows[0]['score_total'];

		$this->sql ="SELECT COUNT(*) as num_row
					FROM tbl_sub_pp6 
					WHERE status=1
					AND pp6_ID in(
						SELECT DataID
						FROM tbl_pp6
						WHERE std_ID=$user_id
						AND year='$year'
                        AND term='$term'
					)
					";
		$this->select();
		$this->setRows();
		$num_row=$this->rows[0]['num_row'];
		$resaultGpaFind=$score_total/$num_row;
		return $resaultGpaFind;
	}
	 public function get_department($data){
		
		switch ($data) {
		    case 1:
		       	$department='ภาษาไทย';
		        break;
		    case 2:
		        $department='คณิตศาสตร์';
		        break;
		    case 3:
		        $department='วิทยาศาสตร์';
		        break;
		    case 31:
		        $department='วิทยาศาสตร์และเทคโนโลยี';
		        break;    
		    case 4:
		        $department='สังคมศึกษา ศาสนาและวัฒนธรรม';
		        break;
		    case 41:
		        $department='สังคมศึกษา';
		        break;
		    case 42:
		        $department='ภูมิศาสตร์';
		        break;
		    case 43:
		        $department='ประวัติศาสตร์';
		        break;
		    case 5:
		        $department='สุขศึกษาและพลศึกษา';
		        break;
		    case 6:
		        $department='ศิลปะ';
		        break;
		    case 7:
		        $department='การงานอาชีพและเทคโนโลยี';
		        break; 
		    case 71:
		        $department='การงานอาชีพ';
		        break; 
		    case 8:
		        $department='ภาษาต่างประเทศ';
		        break;     
		    default:
		     	$department='';
		}
		return $department;
	}
}

?><file_sep>/modules/mobile_api/host/getYearResault.php
<?php	
	@session_start();

	require_once('config.php');
	require_once('src/database.php');
	include('class_modules.php');
	$class_data = new ClassData();
	##CLASS_DB_CONNECT##
	$condition = false;
	$num=  $class_data->rows[0]['num'];		
	$json = json_decode(file_get_contents('php://input'), true);
	$stdId=$json['stdId'];

    if ($stdId) {
		echo $class_data->get_header_box($stdId);
	}


 ?><file_sep>/modules/regis_course_teaching/index.js
var opPage = 'regis_course_teaching';
$(document).ready(function() {
	get_registed_course_teaching();
	get_term_year_now();

}); 

function dis_object(value) {

	if (value==2 || value==4) {
		$(".exam_chk_dis").attr("disabled","disabled");
	}else{
		$(".exam_chk_dis").removeAttr("disabled");
	}
}
function get_term_year_now() {
	var year_search=document.getElementById("year_search");	
	var term_search=document.getElementById("term_search");	
	term_search.innerHTML='';
	year_search.innerHTML='';
	var formData = new Array();
	formData.push({ "name": "acc_action", "value": "get_term_year_now" }); 
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {
		var term=data.term;
		var class_level_search=$('#class_level_search').val();
		var department_search=$('#department_search').val();

		if (class_level_search=='p1' || class_level_search=='p2' || class_level_search=='p3' || class_level_search=='p4' || class_level_search=='p5' || class_level_search=='p6' ) {
			term_search.innerHTML = '<option id="term_search_id_12" selected="selected" value="1,2">ภาคเรียนที่ 1,2</option>';	
			
		}else{
			term_search.innerHTML='';
			if (term=='1') {
				term_search.innerHTML += '<option id="term_search_id_1" selected="selected" value="1">ภาคเรียนที่ 1</option>';
				term_search.innerHTML += '<option id="term_search_id_2" value="2">ภาคเรียนที่ 2</option>';
			}else{
				term_search.innerHTML += '<option id="term_search_id_1" value="1">ภาคเรียนที่ 1</option>';
				term_search.innerHTML += '<option id="term_search_id_2" selected="selected" value="2">ภาคเรียนที่ 2</option>';
			}		
		}
		var year=data.year;
		var year_last=year-5;;
			
		for (var i = year; i >=year_last; i--) {
			if (i==year_search) {
				year_search.innerHTML += '<option selected="selected" value="'+i+'"> ปีการศึกษา'+i+'</option>';
			}else{
				year_search.innerHTML += '<option value="'+i+'">ปีการศึกษา '+i+'</option>';
			}			
		}


	})
}
function add_data_proportion() {
	var course_id=$('#dropdown_course_id_list').val();
	var formData = $( "#frm_data_teaching" ).serializeArray();
	formData.push({ "name": "acc_action", "value": "add_data_proportion" }); 
	formData.push({ "name": "course_id", "value": course_id }); 
	$.post('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {
		$(".modal").modal("hide");
	})
}
function update_objective_conclude_pass() {
	var course_id=$('#dropdown_course_id_list').val();
	var objective_data_all_id=$('#objective_data_all_id').val();
	var formData = $( "#frm_data_objective" ).serializeArray();
	formData.push({ "name": "acc_action", "value": "update_objective_conclude" }); 
	formData.push({ "name": "course_id", "value": course_id }); 
	formData.push({ "name": "objective_data_all_id", "value": objective_data_all_id }); 
	$.post('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {
		$(".modal").modal("hide");
	})
}
function chk_objective_conclude() {
	var course_id=$('#dropdown_course_id_list').val();
	var cumulative_before_mid=$('#cumulative_before_mid').val();
	var cumulative_after_mid=$('#cumulative_after_mid').val();

	var inputs = document.getElementsByClassName( 'score_data' ),
    score_data  = [].map.call(inputs, function( input ) {
        return input.value;
    }).join( '-' );

    var inputs = document.getElementsByClassName( 'object_list_data' ),
    object_list_data  = [].map.call(inputs, function( input ) {
        return input.value;
    }).join( '-' );

	var formData = $( "#frm_data_objective_plus" ).serializeArray();
	formData.push({ "name": "acc_action", "value": "chk_cumulative_over" }); 
	formData.push({ "name": "course_id", "value": course_id });
	formData.push({ "name": "cumulative_before_mid", "value": cumulative_before_mid }); 
	formData.push({ "name": "cumulative_after_mid", "value": cumulative_after_mid }); 

	formData.push({ "name": "score_data", "value": score_data }); 
	formData.push({ "name": "object_list_data", "value": object_list_data }); 
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {
	
		if (data.score_before=="nopass" || data.score_after=="nopass") {
			get_objective_place_plus();
			
			if (data.score_before=="nopass" && data.score_after=="pass") {
				$("#alert_cumulative_over_before").show();
				$("#alert_cumulative_over_after").hide();
			}
			if(data.score_after=="nopass" && data.score_before=="pass") {
				$("#alert_cumulative_over_before").hide();
				$("#alert_cumulative_over_after").show();
			}
			if(data.score_after=="nopass" && data.score_before=="nopass"){
				$("#alert_cumulative_over_before").show();
				$("#alert_cumulative_over_after").show();
			}

		}else if(data.score_before=="pass" && data.score_after=="pass"){
			$("#alert_cumulative_over_before").hide();
			$("#alert_cumulative_over_after").hide();
			update_objective_conclude_pass();
			add_objective_conclude_pass();
		}
	})	

}
function get_objective_place_plus() {
	var formData = new Array();
	formData.push({ "name": "acc_action", "value": "get_objective_place_plus" }); 
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {
	
		$("#data_objective_place_plus").html(data);
	})
}
function add_objective_conclude_pass() {
	var course_id=$('#dropdown_course_id_list').val();
	var formData = $( "#frm_data_objective_plus" ).serializeArray();
	formData.push({ "name": "acc_action", "value": "add_objective_conclude" }); 
	formData.push({ "name": "course_id", "value": course_id }); 
	$.post('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {
		get_propotion_objective(course_id);
		get_objective_place_plus();

	})
}
$(document).delegate('#btn_add_teaching', 'click', function(event) {
	add_data_proportion();
	chk_objective_conclude();
	var course_id=$('#dropdown_course_id_list').val();
	var term_search=$('#term_search').val();
	var year_search=$('#year_search').val();
	var formData = new Array();
	formData.push({ "name": "acc_action", "value": "add_teaching" }); 
	formData.push({ "name": "course_id", "value": course_id }); 
	formData.push({ "name": "term_search", "value": term_search }); 
	formData.push({ "name": "year_search", "value": year_search }); 
	$.post('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {
		$(".modal").modal("hide");
		get_exam_object(course_id);
		get_registed_course_teaching() ;
	})
})
 $(document).delegate('.btn_delete_objective_first', 'click', function(event) {
 	var course_id=$('#dropdown_course_id_list').val();
 	var data_id_objective = $(this).attr('data-id');
 	 $(document).delegate('#btn_delete_objective_sec', 'click', function(event) {
 		$.post('modules/' + opPage + '/process.php', {
			'acc_action' : 'data_remove_objective',
			'data_val' : data_id_objective
		}, function(response) {
			data_id='';
			$(".modal").modal("hide");
			get_propotion_objective(course_id);
		});
 	});
 });
 $(document).delegate('.bt_delete', 'click', function(event) {
 	var course_id=$('#dropdown_course_id_list').val();
 	var data_id = $(this).attr('data-id');
 	//alert(data_id)
 	 $(document).delegate('#btn_to_delete', 'click', function(event) {
 		$.post('modules/' + opPage + '/process.php', {
			'acc_action' : 'data_remove',
			'data_val' : data_id
		}, function(response) {
			data_id='';
			$(".modal").modal("hide");
			get_registed_course_teaching() ;
			get_name_to_add_std(course_id) ;
		});
 	});
 });
 function plus_objective() {
	var formData = $( "#frm_data_objective_plus" ).serializeArray();
	formData.push({ "name": "acc_action", "value": "plus_objective" }); 
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {
		$('#data_objective_place_plus').html(data);
	})
 }
 $(document).delegate('#btn_plus_objective', 'click', function(event) {
	plus_objective();
})
function get_registed_course_teaching() {
	var formData = new Array();
	formData.push({ "name": "acc_action", "value": "get_registed_course_teaching" }); 	
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {

		$('#data_table_regis_course_teaching').html(data);
		
	})
}
$(document).delegate('#btn__conf_add_std', 'click', function(event) {
	var tempValue=$("input[name='checkbox_delete[]']:checked").map(function(n){ if(this.checked){return  this.value;}; }).get().join(',');
	var term_search=$('#term_search').val();
	var year_search=$('#year_search').val();
	var course_id=$('#dropdown_course_id_list').val();
	var formData = new Array();
	formData.push({ "name": "acc_action", "value": "data_add_std" }); 
	formData.push({ "name": "data_val", "value": tempValue});
	formData.push({ "name": "course_id", "value": course_id});  
	formData.push({ "name": "term_search", "value": term_search});  
	formData.push({ "name": "year_search", "value": year_search});  
	$.post('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {
		get_registed_course_teaching();
		get_std_list_new();
		$('.modal').modal('hide');
	})

});
 $(document).delegate('#checkbox_all', 'click', function(event) {
	if(this.checked) { // check select status
        $('.checkbox_data').each(function() { //loop through each checkbox
            this.checked = true;  //select all checkboxes with class "checkbox1"               
        });
    }else{
        $('.checkbox_data').each(function() { //loop through each checkbox
            this.checked = false; //deselect all checkboxes with class "checkbox1"                       
        });         
    }
});


$(document).delegate('#btn_modal_std_search', 'click', function(event) {
	get_std_list_new();
})

function get_std_list_new() {

	var course_id=$('#dropdown_course_id_list').val();
	var term_search=$('#term_search').val();
	var year_search=$('#year_search').val();
	var formData = $( "#frm_data_search_modal" ).serializeArray();
	formData.push({ "name": "acc_action", "value": "get_std_list_new" }); 
	formData.push({ "name": "course_id", "value": course_id }); 	
	formData.push({ "name": "term_search", "value": term_search }); 	
	formData.push({ "name": "year_search", "value": year_search }); 	
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {

		$("#std_list").html(data.std_list);

		
	})
}

function update_exam_mid_object(data_id_first,objective_conclude_id) {
	var formData = $( "#frm_data_objective" ).serializeArray();
	formData.push({ "name": "acc_action", "value": "update_exam_mid_object" }); 
	formData.push({ "name": "data_id_first", "value": data_id_first }); 
	formData.push({ "name": "objective_conclude_id", "value": objective_conclude_id }); 		
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {		
	
	})
}
function update_exam_final_object(data_id_first,objective_conclude_id) {
	var formData = $( "#frm_data_objective" ).serializeArray();
	formData.push({ "name": "acc_action", "value": "update_exam_final_object" }); 
	formData.push({ "name": "data_id_first", "value": data_id_first }); 
	formData.push({ "name": "objective_conclude_id", "value": objective_conclude_id }); 		
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {		
	
	})
}

function get_exam_object(data_id_first) {

	var formData = $( "#frm_data_objective" ).serializeArray();
	formData.push({ "name": "acc_action", "value": "get_exam_object" }); 
	formData.push({ "name": "data_id_first", "value": data_id_first }); 	
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {		
		
		if (data.status==2) {
			$("#object_desc_status").hide();
		}else{
			$("#object_desc_status").show();
		}
		$("#object_list_mid").html(data.object_list_mid);
		$("#object_list_final").html(data.object_list_final);
	})
}
function get_propotion_objective(data_id_first) {
	var formData = new Array();
	formData.push({ "name": "acc_action", "value": "get_propotion_objective" }); 
	formData.push({ "name": "data_id_first", "value": data_id_first }); 	
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {
		var cumulative_sum=parseInt(data.mid_exam)+parseInt(data.final_exam)+parseInt(data.cumulative_before_mid)+parseInt(data.cumulative_after_mid);
		$("#cumulative_sum").html(cumulative_sum);
		$("#cumulative_before_mid").val(data.cumulative_before_mid);
		$("#cumulative_after_mid").val(data.cumulative_after_mid);

		$("#cumulative_before_mid_sum").html(data.cumulative_before_mid);
		$("#cumulative_after_mid_sum").html(data.cumulative_after_mid);
		
		$("#mid_exam").val(data.mid_exam);
		$("#final_exam").val(data.final_exam);
		$("#data_objective_place").html(data.objective_list);
		$("#objective_data_all_id").val(data.objective_data_all_id);
		$("#score_sum_before").html(data.score_sum_before);
		$("#score_sum_after").html(data.score_sum_after);

	})
}
function remove_alert(argument) {
	$("#alert_cumulative_over_before").hide();
	$("#alert_cumulative_over_after").hide();
}
function get_name_to_add_std(data_id_first,registed_course_id) {
	get_exam_object(data_id_first);
	var formData = new Array();
	var term_search=$('#term_search').val();
	var year_search=$('#year_search').val();
	formData.push({ "name": "acc_action", "value": "get_name_to_add_std" }); 
	formData.push({ "name": "data_id_first", "value": data_id_first }); 
	formData.push({ "name": "registed_course_id", "value": registed_course_id }); 
	formData.push({ "name": "term_search", "value": term_search }); 
	formData.push({ "name": "year_search", "value": year_search }); 
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {

		if (data.num_row!=0) {
			//$("#course_name_from_search").html(data.name+" (ลงทะเบียนแล้ว)");
			//$("#chk_to_show_btn_add_std").hide();
			$("#course_name_from_search").html(data.name+'(ลงทะเบียนแล้ว)');
			get_propotion_objective(data_id_first);
			get_std_list_new();

		}else{
			$("#course_name_from_search").html(data.name);
			$("#chk_to_show_btn_add_std").show();
			get_propotion_objective(data_id_first);
			get_std_list_new();
		}
		if (data.status==2) {
			$("#rate_score_box").css("display","none");
			$("#target_conclude").css("display","none");
			$("#cumulative_text_chk").css("display","none");
			
			$("#regis_course_hide").removeClass("btn-group-set-save-regis-course");			
		}else{
			$("#rate_score_box").css("display","block");
			$("#target_conclude").css("display","block");
			$("#cumulative_text_chk").css("display","block");
			$("#regis_course_hide").addClass("btn-group-set-save-regis-course");

			if (data.class_level_status=='p') {
				$("#set-text-desc-1").html('ก่อนวัดผลกลางปี');
				$("#set-text-desc-2").html('กลางปี');
				$("#set-text-desc-3").html('หลังวัดผลกลางปี');
				$("#set-text-desc-4").html('ปลายปี');
				
				$("#op_drop_space_1").html('ก่อนวัดผลกลางปี');
				$("#op_drop_space_2").html('หลังวัดผลกลางปี');
				
				$("#text_exam_objective_mid").html('สอบกลางปี');
				$("#text_exam_objective_final").html('สอบปลายปี');
				
			}else{
				$("#set-text-desc-1").html('ก่อนกลางภาค');
				$("#set-text-desc-2").html('สอบกลางภาค');
				$("#set-text-desc-3").html('หลังกลางภาค');
				$("#set-text-desc-4").html('สอบปลายภาค');

				$("#op_drop_space_1").html('ก่อนกลางภาค');
				$("#op_drop_space_2").html('หลังกลางภาค');

				

				$("#text_exam_objective_mid").html('สอบกลางภาค');
				$("#text_exam_objective_final").html('สอบปลายภาค');
			}
		}
		
	})
}
function form_reset(form_se) {
	$("#"+form_se)[0].reset();
}

function hide_class_std(data_id_first) {
	var formData = new Array();

	formData.push({ "name": "acc_action", "value": "hide_class_std" }); 
	formData.push({ "name": "data_id_first", "value": data_id_first }); 
	
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {

		$("#search_class_modal").html(data);
	})
}
function search_course_class() {

	form_reset("frm_data_teaching");
	var formData = $( "#frm_data" ).serializeArray();
	formData.push({ "name": "acc_action", "value": "search_course_class" }); 
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {
		var data_id_first=data.data_id_first;

		var registed_course_id=data.registed_course_id;
		hide_class_std(data_id_first);
		$("#dropdown_course_id_list").html(data.dropdown_list);
		$("#course_name_from_search").html(data.course_name);
		get_propotion_objective(0);
		get_exam_object(data_id_first);
		if (data_id_first!="" && data_id_first!="undefined") {
			$("#chk_to_show_btn_add_std").show();
			get_name_to_add_std(data_id_first,registed_course_id);
		}else{
			$("#chk_to_show_btn_add_std").hide();
		}
	})
}
$(document).delegate('#btn_search_course_class', 'click', function(event) {
	search_course_class();
})

// This dialog will not break other dialogs or modals
var oldJqTrigger = jQuery.fn.trigger;
jQuery.fn.trigger = function()
{
    if ( arguments && arguments.length > 0) {
        if (typeof arguments[0] == "object") {
            if (typeof arguments[0].type == "string") {
                if (arguments[0].type == "show.bs.modal") {
                    var ret = oldJqTrigger.apply(this, arguments);
                    if ($('.modal:visible').length) {
                        $('.modal-backdrop.in').first().css('z-index', parseInt($('.modal:visible').last().css('z-index')) + 10);
                        $(this).css('z-index', parseInt($('.modal-backdrop.in').first().css('z-index')) + 10);
                    }
                    return ret;
                }
            }
        }
        else if (typeof arguments[0] == "string") {
            if (arguments[0] == "hidden.bs.modal") {
                if ($('.modal:visible').length) {
                    $('.modal-backdrop').first().css('z-index', parseInt($('.modal:visible').last().css('z-index')) - 10);
                    $('body').addClass('modal-open');
                }
            }
        }
    }
    return oldJqTrigger.apply(this, arguments);
};<file_sep>/modules/profile/upload.php
<?php

@ob_start();
@session_start();

require_once('../../init.php');
include('../../src/class.pagination.php');
include('../../src/class.inputfilter.php');
$InputFilter = new InputFilter();

##CLASS_DB_CONNECT##
include('class_modules.php');
$class_data = new ClassData();
##CLASS_DB_CONNECT##
$user_id=$_SESSION['ss_user_id'];

if(is_array($_FILES)) {
	if(is_uploaded_file($_FILES['userImage']['tmp_name'])) {
		$ext=pathinfo(basename($_FILES['userImage']['name']),PATHINFO_EXTENSION);
		$new_file='file_'.uniqid().".".$ext;
		$oldFileName=$_FILES['userImage']['name'];

		$sourcePath = $_FILES['userImage']['tmp_name'];
		$targetPath = "../../file_managers/profile/".$new_file;
		$upload=move_uploaded_file($sourcePath,$targetPath);
		crop_img($targetPath);
		if ($upload==false) {		
			echo "no";
			exit();
		}
		$class_data->sql="SELECT * FROM tbl_regis_teacher_gallery WHERE regis_teacher_id=$user_id";
	    $class_data->select();  
	    $class_data->setRows(); 
	    $FileName=$class_data->rows[0]['FileName'];
		@unlink("../../file_managers/profile/".$FileName);	

		$class_data->sql="DELETE FROM tbl_regis_teacher_gallery WHERE regis_teacher_id = $user_id";
		$class_data->query();

	 	$class_data->sql="INSERT INTO tbl_regis_teacher_gallery (regis_teacher_id,FileName) VALUES($user_id,'$new_file')";
	    $class_data->query();
		echo json_encode("ok");  
	}
}


 function crop_img($imgSrc){
 	$new = imagecreatefromjpeg($imgSrc);

    $crop_width = imagesx($new);
    $crop_height = imagesy($new);
                
            $size = min($crop_width, $crop_height);
            
            
            if($crop_width >= $crop_height) {
            	$newx= ($crop_width-$crop_height)/2;
            
            	$im2 = imagecrop($new, ['x' => $newx, 'y' => 0, 'width' => $size, 'height' => $size]);
            }
            else {
                $newy= ($crop_height-$crop_width)/2;
            
                $im2 = imagecrop($new, ['x' => 0, 'y' => $newy, 'width' => $size, 'height' => $size]);
                }
            
                
    imagejpeg($im2,$imgSrc,90);
   /* //getting the image dimensions
    list($width, $height) = getimagesize($imgSrc);

    //saving the image into memory (for manipulation with GD Library)
    $myImage = imagecreatefromjpeg($imgSrc);

    // calculating the part of the image to use for thumbnail
    if ($width > $height) {
        $y = 0;
        $x = ($width - $height) / 2;
        $smallestSide = $height;
    } else {
        $x = 0;
        $y = ($height - $width) / 2;
        $smallestSide = $width;
    }

    // copying the part into thumbnail
    $thumbSize = min($width,$height);
    $thumb = imagecreatetruecolor($thumbSize, $thumbSize);
    imagecopyresampled($thumb, $myImage, 0, 0, $x, $y, $thumbSize, $thumbSize, $smallestSide, $smallestSide);

    unlink($imgSrc);
    imagejpeg($thumb,$imgSrc);
    @imagedestroy($myImage);
    @imagedestroy($thumb);*/
}
?><file_sep>/modules/profile/index.js
var opPage = 'profile';
$(document).ready(function() {
	get_data();
	get_img();
}); 
function get_data() {
	var formData = new Array();
	formData.push({ "name": "acc_action", "value": "get_data" }); 
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {
		$("#positionID").html(data.positionID);

		$("#full_name_th_s").html(data.full_name_th);
		$("#full_name_th_pro").html(data.full_name_th);
		
		$("#full_name_en").html(data.full_name_en);
		$("#study_history").html(data.study_history);
		$("#gender").html(data.gender);
		$("#blood_group").html(data.blood_group);
		$("#address").html(data.address);
		$("#position_name").html(data.position_name);
		$("#department").html(data.department);
		$("#department_pro").html(data.department);
		$("#birthday").html(data.birthday);
		
		$("#work").html(data.work);
		$("#more_detail").html(data.more_detail);
		$("#tell").html(data.tell);
		$("#email").html(data.email);
	});
}
function get_img(){
	var formData = new Array();
	formData.push({ "name": "acc_action", "value": "get_img" }); 
	formData.push({ "name": "status_get", "value": "index" }); 
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus) {
	// console.log(data);
		$("#get_profile_img").html(data.get_profile_img);

	});
}<file_sep>/modules/menu/process.php
<?php
@ob_start();
@session_start();

require_once('../../init.php');
include('../../src/class.pagination.php');
include('../../src/class.inputfilter.php');
$InputFilter = new InputFilter();

/////// CLASS ROLE MANAGEMENT /////
require_once('../../src/class_role.php');
$role = new ClassRole();
$user_role_id = (int)$_SESSION['ss_user_id'];

##CLASS_DB_CONNECT##
include('class_modules.php');
$class_data = new ClassData();
##CLASS_DB_CONNECT##
$targetfile =  '../../../file_managers/menu/';

if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_data_list"){
	$sort_column = $_GET['sort_column'];
	$sort_by = $_GET['sort_by'];
	$pages_current = $_GET['pages_current'];
	$arr_search_val = array();
	$arr_search_val['data_name'] = $_GET['data_name'];
	$arr_search_val['s_status'] = $_GET['s_status'];
	echo $class_data->get_data_list($arr_search_val,$pages_current,$sort_column,$sort_by);
}

if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_data_from"){
	$data_id = $_GET['data_id'];
	echo $class_data->get_data_from($data_id);
}

if(isset($_POST['acc_action']) and $_POST['acc_action'] == "save_data"){
	 $DataID = (int)$_POST['data_id'];

	 if ($DataID > 0) {
		$arr_sql = array();
		$arr_sql[]="DataID='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['DataID'])))."'";
		
		$arr_sql[]="boxI_name='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['boxI_name'])))."'";
		$arr_sql[]="boxI_nameEn='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['boxI_nameEn'])))."'";
		$arr_sql[]="boxI_desc='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['boxI_desc'])))."'";
		$arr_sql[]="boxI_descEn='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['boxI_descEn'])))."'";
		
		$arr_sql[]="boxII_name='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['boxII_name'])))."'";
		$arr_sql[]="boxII_nameEn='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['boxII_nameEn'])))."'";
		$arr_sql[]="boxII_desc='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['boxII_desc'])))."'";
		$arr_sql[]="boxII_descEn='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['boxII_descEn'])))."'";

		$arr_sql[]="boxIII_name='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['boxIII_name'])))."'";
		$arr_sql[]="boxIII_nameEn='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['boxIII_nameEn'])))."'";
		$arr_sql[]="boxIII_desc='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['boxIII_desc'])))."'";
		$arr_sql[]="boxIII_descEn='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['boxIII_descEn'])))."'";

		$arr_sql[]="boxIV_name='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['boxIV_name'])))."'";
		$arr_sql[]="boxIV_nameEn='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['boxIV_nameEn'])))."'";
		$arr_sql[]="boxIV_desc='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['boxIV_desc'])))."'";
		$arr_sql[]="boxIV_descEn='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['boxIV_descEn'])))."'";

				
		$arr_sql[]="status='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['status'])))."'";
		$arr_sql[]="tag_title='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['tag_title'])))."'";
		$arr_sql[]="tag_keyword='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['tag_keyword'])))."'";
		$arr_sql[]="tag_description='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['tag_description'])))."'";
		$arr_sql[]="update_time=now()"; 
		$arr_sql[]="update_ip='".ipCheck()."'"; 
		pre($arr_sql);

		echo $class_data->update_data($arr_sql,$DataID,$user_role_id);

		// if ($class_data->update_data($arr_sql,$DataID,$user_role_id) == "") {
		// 	echo "Y";
		// }else{
		// 	echo "N";
		// }
		
	}else{

		$arr_sql = array();
			$arr_sql["DataID"]="'".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['menu_id'])))."'";

			$arr_sql["boxI_name"]="'".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['boxI_name'])))."'";
			$arr_sql["boxI_nameEn"]="'".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['boxI_nameEn'])))."'";
			$arr_sql["boxI_desc"]="'".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['boxI_desc'])))."'";
			$arr_sql["boxI_descEn"]="'".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['boxI_descEn'])))."'";
		
			$arr_sql["boxII_name"]="'".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['boxII_name'])))."'";
			$arr_sql["boxII_nameEn"]="'".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['boxII_nameEn'])))."'";
			$arr_sql["boxII_desc"]="'".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['boxII_desc'])))."'";
			$arr_sql["boxII_descEn"]="'".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['boxII_descEn'])))."'";
	
			$arr_sql["boxIII_name"]="'".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['boxIII_name'])))."'";
			$arr_sql["boxIII_nameEn"]="'".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['boxIII_nameEn'])))."'";
			$arr_sql["boxIII_desc"]="'".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['boxIII_desc'])))."'";
			$arr_sql["boxIII_descEn"]="'".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['boxIII_descEn'])))."'";
	
			$arr_sql["boxIV_name"]="'".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['boxIV_name'])))."'";
			$arr_sql["boxIV_nameEn"]="'".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['boxIV_nameEn'])))."'";
			$arr_sql["boxIV_desc"]="'".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['boxIV_desc'])))."'";
			$arr_sql["boxIV_descEn"]="'".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['boxIV_descEn'])))."'";
	
			$arr_sql["status"]="'".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['status'])))."'";
			$arr_sql["tag_title"]="'".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['tag_title'])))."'";
			$arr_sql["tag_keyword"]="'".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['tag_keyword'])))."'";
			$arr_sql["tag_description"]="'".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['tag_description'])))."'";
			$arr_sql["create_time"]="now()"; 
			$arr_sql["create_ip"]="'".$ip."'";
			$arr_sql["update_time"]="now()"; 
			$arr_sql["update_ip"]="'".$ip."'";
		if ($class_data->insert_data($arr_sql,$user_role_id) == "") {
			echo "Y";
		}else{
			echo "N";
		}
	}
}

if(isset($_POST['acc_action']) and $_POST['acc_action'] == "sequence_data"){
		$data_id = $_POST['data_id'];
		$sequence_old = $_POST['sequence_old'];
		$sequence = $_POST['sequence'];
		$res = $class_data->ex_sequence_data($data_id,$sequence_old,$sequence,$user_role_id);
		//echo "{$res}";
}

if(isset($_POST['acc_action']) and $_POST['acc_action'] == "data_remove"){
	$data_val = $_POST['data_val'];
	echo $class_data->get_data_delete($data_val,$user_role_id);
}


if(isset($_POST['acc_action']) and $_POST['acc_action'] == "upload_thumb"){
		// $targetfile = $targetfile."project/";
		if (!empty($_FILES)) {
			$size = getimagesize($_FILES['file']['tmp_name']);
            $chk_height = $size[1];

          if($chk_height<271){
              echo $chk_height;
          }else{

			$new_file_name	=	date('Ymdhis');
			ini_set ( "memory_limit", "80M");
			$StatusSave	= 0;//[0]=Problems [1]=Successfully
			$file_name = ""; // File name in Database

			# Check Type Files 
			$typeaccept 	= array(".jpg",".gif",".jpeg",".png"); 
			// $typeaccept_doc = array(".pdf",".doc",".docx",".ppt",".pptx",".xls",".xlsx"); 
			$fileExt    	= "." . strtolower(end(explode('.', $_FILES['file']['name'])));
			$file_ok		= (in_array($fileExt, $typeaccept)) ? true : false;
			// $document_ok	= (in_array($fileExt, $typeaccept_doc)) ? true : false;
			list($width_n, $height_n, $type_n, $w_n) = getimagesize($_FILES['file']['tmp_name']);
			if($file_ok==true || $document_ok==true)
			{ 
				include ('../../src/class.upload.php');
				// $thumbnail = new Upload($_FILES['file']);
				// if ($thumbnail->uploaded) {   
				// 		$thumbnail->image_convert = 'jpg';
				// 		$thumbnail->jpeg_quality = 100;
				// 		$thumbnail->image_resize  = true;
				// 		$thumbnail->image_ratio_crop = true;
				// 		$thumbnail->image_x = 100; //4:3 Aspect Ratio 
				// 		$thumbnail->image_y = 100; //4:3 Aspect Ratio 
				// 		$thumbnail->file_new_name_body	= $new_file_name;
				// 		$thumbnail->process($targetfile.'thumbnail/'); 
				// 	if ($thumbnail->processed) {   // UPLOAD THUMBNAIL PROCESS END 
				// 		//$thumbnail->clean(); 
				// 		$statussave	=	1;
				// 	}
				// }

				$main_photo = new Upload($_FILES['file']);
				if ($main_photo->uploaded) {   
						$main_photo->image_convert = 'jpg';
						$main_photo->jpeg_quality = 100;
						$main_photo->image_resize  = true;
						$main_photo->image_ratio_crop = true;
						$main_photo->image_x =  $size[0]; //4:3 Aspect Ratio 
						$main_photo->image_y = 350; //4:3 Aspect Ratio 
						$main_photo->file_new_name_body	= $new_file_name;
						$main_photo->process($targetfile.'thumbnails/'); 
					if ($main_photo->processed) {   // UPLOAD MAIN PHOTO PROCESS END 
						//$main_photo->clean(); 
						$statussave	=	1;
					}
				}
				$file_name 	= $new_file_name.".jpg";//.$fileExt;
				$filetype	= $fileExt;
			}
			
			# Check Upload Processed Successfully
			if($statussave==1){ 	
				$menuID	=	((int)$_POST['data_id'] == 0) ? 0 : (int)$_POST['data_id']; 
			    $arr_sql["menuID"]= "'{$menuID}'";
			    $arr_sql["FileName"]= "'{$file_name}'"; 
			    $arr_sql["Type"]= "'0'";
			    $arr_sql["sequence"]= "'0'"; 
			    $arr_sql["status"]= "'{$menuID}'"; 
				$arr_sql["create_time"]= "now()";
				$arr_sql["create_ip"]= "'".$ip."'";
				$arr_sql["update_time"]= "now()";
				$arr_sql["update_ip"]= "'".$ip."'";
				$new_par_id = $class_data->ex_add_thumb($arr_sql);
				// echo $menuID;
				echo "successfully";
			}else{
				echo "Problems";
			}
		  }
		}

	}	

	if(isset($_POST['acc_action']) and $_POST['acc_action'] == "get_thumb"){
		$data_id = $_POST['data_id'];
		echo $class_data->get_thumb($data_id);
	}	
	if(isset($_POST['acc_action']) and $_POST['acc_action'] == "remove_thumb"){
		$data_id = $_POST['data_id'];
		echo $class_data->remove_thumb($data_id);
	}



	if(isset($_POST['acc_action']) and $_POST['acc_action'] == "upload_award"){
		if (!empty($_FILES)) {
			$size = getimagesize($_FILES['file']['tmp_name']);
            $chk_height = $size[1];

          if($chk_height<500){
              echo $chk_height;
          }else{

			$new_file_name	=	date('Ymdhis');
			ini_set ( "memory_limit", "80M");
			$StatusSave	= 0;//[0]=Problems [1]=Successfully
			$file_name = ""; // File name in Database

			# Check Type Files 
			$typeaccept 	= array(".jpg",".gif",".jpeg",".png"); 
			$typeaccept_doc = array(".pdf",".doc",".docx",".ppt",".pptx",".xls",".xlsx"); 
			$fileExt    	= "." . strtolower(end(explode('.', $_FILES['file']['name'])));
			$file_ok		= (in_array($fileExt, $typeaccept)) ? true : false;
			$document_ok	= (in_array($fileExt, $typeaccept_doc)) ? true : false;
			list($width_n, $height_n, $type_n, $w_n) = getimagesize($_FILES['file']['tmp_name']);

			$size_height = 500;
			$size_width=($width_n*$size_height)/$height_n; 

			if($file_ok==true || $document_ok==true)
			{ 
				include ('../../src/class.upload.php');

				$main_photo = new Upload($_FILES['file']);
				if ($main_photo->uploaded) {   
						$main_photo->image_convert = 'jpg';
						$main_photo->jpeg_quality = 100;
						$main_photo->image_resize  = true;
						$main_photo->image_ratio_crop = true;
						$main_photo->image_x = $size_width; //4:3 Aspect Ratio 
						$main_photo->image_y = $size_height; //4:3 Aspect Ratio 
						$main_photo->file_new_name_body	= $new_file_name;
						$main_photo->process($targetfile.'photo/'); 
					if ($main_photo->processed) {   // UPLOAD MAIN PHOTO PROCESS END 
						//$main_photo->clean(); 
						$statussave	=	1;
					}
				}
						
				$file_name 	= $new_file_name.'.jpg';//.$fileExt;
				$filetype	= '.jpg';
				 
			}
			
			# Check Upload Processed Successfully
			if($statussave==1){ 	
				$menuID	=	((int)$_POST['data_id'] == 0) ? 0 : (int)$_POST['data_id']; 
			    $arr_sql["menuID"]= "'{$menuID}'";
			    $arr_sql["FileName"]= "'{$file_name}'"; 
			    $arr_sql["Type"]= "'1'"; 
			    $arr_sql["sequence"]= "'0'"; 
			    $arr_sql["status"]= "'{$menuID}'"; 
				$arr_sql["create_time"]= "now()";
				$arr_sql["create_ip"]= "'".$ip."'";
				$arr_sql["update_time"]= "now()";
				$arr_sql["update_ip"]= "'".$ip."'";
				$new_par_id = $class_data->ex_add_award($arr_sql);
				// echo $FacilityName;
				echo "successfully";
			}else{
				echo "Problems";
			}
		  }
		}

	}	
	if(isset($_POST['acc_action']) and $_POST['acc_action'] == "get_award"){
		$data_id = $_POST['data_id'];
		echo $class_data->get_photo_award($data_id);
	}	
	if(isset($_POST['acc_action']) and $_POST['acc_action'] == "remove_file_award"){
		$data_id = $_POST['data_id'];
		echo $class_data->remove_file_award($data_id);
	}	
 

?><file_sep>/sratong_eva_after_18072561.sql
-- phpMyAdmin SQL Dump
-- version 4.7.0
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Jul 23, 2018 at 07:10 PM
-- Server version: 10.1.25-MariaDB
-- PHP Version: 5.6.31

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET AUTOCOMMIT = 0;
START TRANSACTION;
SET time_zone = "+00:00";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;

--
-- Database: `sratong_eva_after_18072561`
--

-- --------------------------------------------------------

--
-- Table structure for table `ath_role_reletion_tasks`
--

CREATE TABLE `ath_role_reletion_tasks` (
  `rel_id` int(11) UNSIGNED NOT NULL,
  `task_id` int(11) DEFAULT '0',
  `role_id` int(11) DEFAULT '0'
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `ath_role_reletion_tasks`
--

INSERT INTO `ath_role_reletion_tasks` (`rel_id`, `task_id`, `role_id`) VALUES
(1, 1, 1),
(2, 2, 1),
(3, 3, 1),
(4, 4, 1),
(5, 5, 1),
(6, 6, 1),
(7, 7, 1),
(8, 8, 1),
(9, 9, 1),
(10, 10, 1),
(11, 11, 1),
(12, 12, 1),
(13, 13, 1),
(14, 14, 1),
(15, 15, 1),
(16, 16, 1),
(17, 17, 1),
(18, 5, 2),
(19, 7, 2),
(20, 9, 2),
(21, 11, 2),
(22, 12, 2),
(23, 13, 2),
(24, 14, 2),
(25, 15, 2),
(26, 17, 5),
(27, 16, 5),
(28, 15, 5),
(29, 14, 5);

-- --------------------------------------------------------

--
-- Table structure for table `ath_tasks`
--

CREATE TABLE `ath_tasks` (
  `task_id` int(11) UNSIGNED NOT NULL,
  `fun_id` int(11) DEFAULT '0',
  `task_key` varchar(250) COLLATE utf8_unicode_ci DEFAULT NULL,
  `task_title` varchar(250) COLLATE utf8_unicode_ci DEFAULT NULL,
  `task_description` varchar(250) COLLATE utf8_unicode_ci DEFAULT '',
  `sequence` int(11) DEFAULT '0',
  `status` int(2) DEFAULT '0' COMMENT '0=n 1=y',
  `cdate` datetime DEFAULT NULL,
  `mdate` datetime DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `ath_tasks`
--

INSERT INTO `ath_tasks` (`task_id`, `fun_id`, `task_key`, `task_title`, `task_description`, `sequence`, `status`, `cdate`, `mdate`) VALUES
(1, 1, 'create_user_ath', 'Create User Authentication ', 'สามารถเพิ่ม User Authentication ได้', 1, 1, NULL, NULL),
(2, 1, 'edit_user_ath', 'Edit User Authentication', 'สามารถแก้ไข  User Authentication ได้', 2, 1, NULL, NULL),
(3, 1, 'del_user_ath', 'Delete User Authentication', 'สามารถลบ User Authentication ได้', 3, 1, NULL, NULL),
(4, 1, 'view_user_ath', 'View Menu User Authentication', 'สามารถเข้าใช้งาน เมนู User Authentication ได้', 4, 1, NULL, NULL);

-- --------------------------------------------------------

--
-- Table structure for table `ath_users`
--

CREATE TABLE `ath_users` (
  `user_id` int(11) UNSIGNED NOT NULL,
  `role_id` int(11) DEFAULT '0',
  `username` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `password` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'md5',
  `prefix_name` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `first_name` varchar(250) COLLATE utf8_unicode_ci DEFAULT NULL,
  `last_name` varchar(250) COLLATE utf8_unicode_ci DEFAULT NULL,
  `email` varchar(150) COLLATE utf8_unicode_ci DEFAULT NULL,
  `phone_number` varchar(15) COLLATE utf8_unicode_ci DEFAULT NULL,
  `status` int(2) DEFAULT '0' COMMENT '0=n 1=y',
  `status_pass` int(2) DEFAULT '0' COMMENT '0 = default , 1 = change pass',
  `cdate` datetime DEFAULT NULL,
  `mdate` datetime DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Dumping data for table `ath_users`
--

INSERT INTO `ath_users` (`user_id`, `role_id`, `username`, `password`, `prefix_name`, `first_name`, `last_name`, `email`, `phone_number`, `status`, `status_pass`, `cdate`, `mdate`) VALUES
(1, 1, 'admin', '21232f297a57a5a743894a0e4a801fc3', 'Mr.', 'Watcharapon', 'Kestarchon', '-', '-', 1, 0, NULL, '2016-03-18 12:51:44'),
(6, 2, 'capsule', '2716373f1a0b85c7d8fb074fb4fc61c7', NULL, 'Tanapat', 'Sirisurt', NULL, NULL, 1, 0, '2017-01-24 11:18:35', '2017-01-24 12:02:25'),
(7, 1, 'chanut', '73ca9be08aecbe3e156320d17209cd5a', NULL, 'chanut', 'chumjan', NULL, NULL, 1, 0, '2017-02-24 16:27:49', '2017-02-24 16:29:19');

-- --------------------------------------------------------

--
-- Table structure for table `tbl_add_delete_course`
--

CREATE TABLE `tbl_add_delete_course` (
  `DataID` int(11) NOT NULL,
  `user_add` int(11) DEFAULT NULL,
  `courseID` varchar(250) DEFAULT NULL,
  `name` text,
  `class_level` varchar(250) DEFAULT NULL,
  `unit` decimal(2,1) DEFAULT NULL,
  `department` varchar(250) DEFAULT NULL,
  `hr_learn` varchar(250) DEFAULT NULL,
  `cdate` date NOT NULL,
  `status` int(11) NOT NULL,
  `status_form` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table `tbl_add_delete_course`
--

INSERT INTO `tbl_add_delete_course` (`DataID`, `user_add`, `courseID`, `name`, `class_level`, `unit`, `department`, `hr_learn`, `cdate`, `status`, `status_form`) VALUES
(409, 311, 'ท21101', 'ภาษาไทย1', 'p1', '1.5', '71', '60', '2018-06-29', 1, 11),
(410, 311, 'ท21102', 'ภาษาไทย2', 'p1', '1.5', '1', '60', '2018-06-29', 1, 12),
(411, 311, 'ค 21101', 'คณิตศาสตร์ พื้นฐาน', 'm2', '1.5', '2', '60', '2018-06-29', 1, 11),
(412, 311, 'ค 21102', 'คณิตศาสตร์ เพิ่มเติม', 'p1', '1.5', '2', '60', '2018-06-29', 1, 12),
(413, 311, 'อ15101', 'ภาษาอังกฤษ', 'p1', '2.5', '1', '5', '2018-06-29', 1, 11),
(414, 311, 'ท15201', 'ภาษาไทยเพิ่มเติม', 'p1', '0.5', '1', '1', '2018-06-29', 1, 11),
(416, 311, '2', '2', 'p1', '0.0', '', '2', '2018-07-02', 2, 22),
(417, 311, '1', '1', 'm1', '0.0', '', '1', '2018-07-02', 2, 26),
(418, 311, 'ค11111', 'คณิตศาสตร์ พื้นฐาน', 'm1', '1.0', '2', '3', '2018-07-03', 1, 11),
(419, 311, 'ท22222', 'ภาษาไทยพื้นฐาน', 'm1', '0.5', '1', '2', '2018-07-03', 1, 11),
(420, 311, 'ท33333', 'ภาษาไทยเพิ่มเติม', 'm1', '1.0', '1', '2', '2018-07-03', 1, 12),
(421, 311, 'ก11112', 'ก11112', 'm1', '0.5', '7', '4', '2018-07-04', 1, 11),
(422, 311, 'ก11113', 'ก11113', 'm1', '0.5', '2', '3', '2018-07-04', 1, 11),
(423, 311, 'ก11114', 'ก11114', 'm1', '0.5', '2', '2', '2018-07-04', 1, 11),
(424, 311, 'ก11115', 'ก11115', 'm1', '0.5', '2', '2', '2018-07-04', 1, 11),
(425, 311, 'ก11116', 'ก11116', 'm1', '0.5', '2', '1', '2018-07-04', 1, 11),
(426, 311, 'ก11117', 'ก11117', 'm1', '0.5', '2', '1', '2018-07-04', 1, 11),
(427, 311, 'ก11118', 'ก11118', 'm1', '0.5', '2', '1', '2018-07-04', 1, 11),
(428, 311, 'ก11119', 'ก11119', 'm1', '0.5', '2', '2', '2018-07-04', 1, 11),
(429, 311, 'ก111110', 'ก111110', 'm1', '0.5', '2', '2', '2018-07-04', 1, 11),
(430, 311, 'ก45623', 'แนะแนว', 'm1', '9.9', '', '3', '2018-07-19', 2, 25);

-- --------------------------------------------------------

--
-- Table structure for table `tbl_attend_class`
--

CREATE TABLE `tbl_attend_class` (
  `DataID` int(11) NOT NULL,
  `course_teaching_stdID` int(11) DEFAULT NULL,
  `week` int(11) DEFAULT NULL,
  `score_status` varchar(250) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- --------------------------------------------------------

--
-- Table structure for table `tbl_attend_class_std`
--

CREATE TABLE `tbl_attend_class_std` (
  `DataID` int(11) NOT NULL,
  `course_teaching_std_id` int(11) DEFAULT NULL,
  `set_attend_day_id` int(11) DEFAULT NULL,
  `week` int(11) DEFAULT NULL,
  `status` varchar(250) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table `tbl_attend_class_std`
--

INSERT INTO `tbl_attend_class_std` (`DataID`, `course_teaching_std_id`, `set_attend_day_id`, `week`, `status`) VALUES
(1, 17922, 658, 1, 'ล'),
(2, 17923, 673, 1, 'ล'),
(3, 17927, 672, 1, 'ล'),
(4, 17927, 672, 2, 'ล'),
(5, 17927, 672, 3, 'ล'),
(6, 17927, 672, 4, 'ล'),
(7, 17927, 672, 5, 'ล');

-- --------------------------------------------------------

--
-- Table structure for table `tbl_attend_class_week_list`
--

CREATE TABLE `tbl_attend_class_week_list` (
  `DataID` int(11) NOT NULL,
  `name` varchar(250) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table `tbl_attend_class_week_list`
--

INSERT INTO `tbl_attend_class_week_list` (`DataID`, `name`) VALUES
(1, 'จันทร์'),
(2, 'อังคาร'),
(3, 'พุธ'),
(4, 'พฤหัสบดี'),
(5, 'ศุกร์');

-- --------------------------------------------------------

--
-- Table structure for table `tbl_course_teacher`
--

CREATE TABLE `tbl_course_teacher` (
  `DataID` int(11) NOT NULL,
  `teacher_id` int(11) DEFAULT NULL,
  `regis_course_id` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table `tbl_course_teacher`
--

INSERT INTO `tbl_course_teacher` (`DataID`, `teacher_id`, `regis_course_id`) VALUES
(215, 323, 696),
(219, 323, 701),
(220, 323, 700),
(221, 323, 702),
(222, 323, 703),
(223, 323, 706),
(224, 323, 705),
(225, 323, 704),
(226, 323, 707),
(227, 323, 708),
(228, 323, 709),
(231, 323, 711),
(254, 323, 698),
(255, 325, 701);

-- --------------------------------------------------------

--
-- Table structure for table `tbl_course_teaching_std`
--

CREATE TABLE `tbl_course_teaching_std` (
  `DataID` int(11) NOT NULL,
  `registed_courseID` int(11) DEFAULT NULL,
  `stdID` varchar(250) DEFAULT NULL,
  `cdate` date DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table `tbl_course_teaching_std`
--

INSERT INTO `tbl_course_teaching_std` (`DataID`, `registed_courseID`, `stdID`, `cdate`) VALUES
(17895, 696, '01111', '2018-07-13'),
(17896, 696, '01112', '2018-07-13'),
(17897, 696, '01117', '2018-07-13'),
(17898, 697, '11141', '2018-07-13'),
(17899, 697, '11144', '2018-07-13'),
(17900, 698, '01111', '2018-07-13'),
(17901, 698, '01112', '2018-07-13'),
(17902, 698, '01117', '2018-07-13'),
(17903, 699, '11141', '2018-07-13'),
(17904, 699, '11144', '2018-07-13'),
(17905, 701, '01111', '2018-07-13'),
(17906, 701, '01112', '2018-07-13'),
(17907, 701, '01117', '2018-07-13'),
(17908, 700, '01111', '2018-07-13'),
(17909, 700, '01112', '2018-07-13'),
(17910, 700, '01117', '2018-07-13'),
(17911, 703, '01111', '2018-07-15'),
(17912, 702, '01111', '2018-07-15'),
(17913, 706, '11141', '2018-07-15'),
(17914, 705, '11141', '2018-07-15'),
(17915, 704, '11141', '2018-07-15'),
(17916, 707, '11141', '2018-07-15'),
(17917, 707, '11144', '2018-07-15'),
(17918, 708, '11141', '2018-07-15'),
(17919, 708, '11144', '2018-07-15'),
(17920, 709, '11141', '2018-07-15'),
(17921, 709, '11144', '2018-07-15'),
(17922, 698, '991115', '2018-07-19'),
(17923, 711, '11144', '2018-07-19'),
(17924, 711, '11141', '2018-07-19'),
(17925, 711, '111541', '2018-07-19'),
(17926, 711, '11143', '2018-07-19'),
(17927, 711, '11142', '2018-07-19');

-- --------------------------------------------------------

--
-- Table structure for table `tbl_desirable_1`
--

CREATE TABLE `tbl_desirable_1` (
  `DataID` int(11) NOT NULL,
  `course_teachingID` int(11) DEFAULT NULL,
  `stdID` varchar(250) DEFAULT NULL,
  `score` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table `tbl_desirable_1`
--

INSERT INTO `tbl_desirable_1` (`DataID`, `course_teachingID`, `stdID`, `score`) VALUES
(133, 447, '01111', 3),
(134, 447, '01112', 3),
(135, 447, '01117', 3),
(138, 449, '01111', 3),
(139, 449, '01112', 3),
(140, 449, '01117', 3),
(143, 451, '01111', 3),
(144, 451, '01112', 2),
(145, 451, '01117', 3),
(146, 453, '01111', 3),
(147, 454, '01111', 3),
(148, 455, '11141', 3),
(149, 456, '11141', 3),
(150, 458, '11141', 3),
(151, 458, '11144', 3),
(152, 459, '11141', 3),
(153, 459, '11144', 3),
(154, 460, '11141', 3),
(155, 460, '11144', 3),
(156, 449, '991115', 0),
(157, 1, '11141', 3),
(158, 1, '11142', 3);

-- --------------------------------------------------------

--
-- Table structure for table `tbl_desirable_2`
--

CREATE TABLE `tbl_desirable_2` (
  `DataID` int(11) NOT NULL,
  `course_teachingID` int(11) DEFAULT NULL,
  `stdID` varchar(250) DEFAULT NULL,
  `score` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table `tbl_desirable_2`
--

INSERT INTO `tbl_desirable_2` (`DataID`, `course_teachingID`, `stdID`, `score`) VALUES
(133, 447, '01111', 3),
(134, 447, '01112', 3),
(135, 447, '01117', 3),
(138, 449, '01111', 3),
(139, 449, '01112', 3),
(140, 449, '01117', 3),
(143, 451, '01111', 3),
(144, 451, '01112', 3),
(145, 451, '01117', 3),
(146, 453, '01111', 3),
(147, 454, '01111', 3),
(148, 455, '11141', 3),
(149, 456, '11141', 3),
(150, 458, '11141', 3),
(151, 458, '11144', 3),
(152, 459, '11141', 3),
(153, 459, '11144', 3),
(154, 460, '11141', 3),
(155, 460, '11144', 3),
(156, 449, '991115', 0),
(157, 1, '11141', 3),
(158, 1, '11142', 3);

-- --------------------------------------------------------

--
-- Table structure for table `tbl_desirable_3`
--

CREATE TABLE `tbl_desirable_3` (
  `DataID` int(11) NOT NULL,
  `course_teachingID` int(11) DEFAULT NULL,
  `stdID` varchar(250) DEFAULT NULL,
  `score` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table `tbl_desirable_3`
--

INSERT INTO `tbl_desirable_3` (`DataID`, `course_teachingID`, `stdID`, `score`) VALUES
(133, 447, '01111', 3),
(134, 447, '01112', 3),
(135, 447, '01117', 3),
(138, 449, '01111', 3),
(139, 449, '01112', 3),
(140, 449, '01117', 3),
(143, 451, '01111', 3),
(144, 451, '01112', 3),
(145, 451, '01117', 3),
(146, 453, '01111', 3),
(147, 454, '01111', 3),
(148, 455, '11141', 3),
(149, 456, '11141', 3),
(150, 458, '11141', 3),
(151, 458, '11144', 3),
(152, 459, '11141', 3),
(153, 459, '11144', 3),
(154, 460, '11141', 3),
(155, 460, '11144', 3),
(156, 449, '991115', 0),
(157, 1, '11141', 3),
(158, 1, '11142', 3);

-- --------------------------------------------------------

--
-- Table structure for table `tbl_desirable_4`
--

CREATE TABLE `tbl_desirable_4` (
  `DataID` int(11) NOT NULL,
  `course_teachingID` int(11) DEFAULT NULL,
  `stdID` varchar(250) DEFAULT NULL,
  `score` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table `tbl_desirable_4`
--

INSERT INTO `tbl_desirable_4` (`DataID`, `course_teachingID`, `stdID`, `score`) VALUES
(133, 447, '01111', 3),
(134, 447, '01112', 3),
(135, 447, '01117', 3),
(138, 449, '01111', 3),
(139, 449, '01112', 3),
(140, 449, '01117', 1),
(143, 451, '01111', 3),
(144, 451, '01112', 3),
(145, 451, '01117', 3),
(146, 453, '01111', 3),
(147, 454, '01111', 3),
(148, 455, '11141', 3),
(149, 456, '11141', 3),
(150, 458, '11141', 3),
(151, 458, '11144', 3),
(152, 459, '11141', 3),
(153, 459, '11144', 3),
(154, 460, '11141', 3),
(155, 460, '11144', 3),
(156, 449, '991115', 0),
(157, 1, '11141', 3),
(158, 1, '11142', 3);

-- --------------------------------------------------------

--
-- Table structure for table `tbl_desirable_5`
--

CREATE TABLE `tbl_desirable_5` (
  `DataID` int(11) NOT NULL,
  `course_teachingID` int(11) DEFAULT NULL,
  `stdID` varchar(250) DEFAULT NULL,
  `score` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table `tbl_desirable_5`
--

INSERT INTO `tbl_desirable_5` (`DataID`, `course_teachingID`, `stdID`, `score`) VALUES
(133, 447, '01111', 3),
(134, 447, '01112', 3),
(135, 447, '01117', 3),
(138, 449, '01111', 3),
(139, 449, '01112', 3),
(140, 449, '01117', 3),
(143, 451, '01111', 3),
(144, 451, '01112', 3),
(145, 451, '01117', 3),
(146, 453, '01111', 3),
(147, 454, '01111', 3),
(148, 455, '11141', 3),
(149, 456, '11141', 3),
(150, 458, '11141', 3),
(151, 458, '11144', 3),
(152, 459, '11141', 3),
(153, 459, '11144', 3),
(154, 460, '11141', 3),
(155, 460, '11144', 3),
(156, 449, '991115', 0),
(157, 1, '11141', 3),
(158, 1, '11142', 3);

-- --------------------------------------------------------

--
-- Table structure for table `tbl_desirable_6`
--

CREATE TABLE `tbl_desirable_6` (
  `DataID` int(11) NOT NULL,
  `course_teachingID` int(11) DEFAULT NULL,
  `stdID` varchar(250) DEFAULT NULL,
  `score` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table `tbl_desirable_6`
--

INSERT INTO `tbl_desirable_6` (`DataID`, `course_teachingID`, `stdID`, `score`) VALUES
(133, 447, '01111', 3),
(134, 447, '01112', 3),
(135, 447, '01117', 3),
(138, 449, '01111', 3),
(139, 449, '01112', 3),
(140, 449, '01117', 3),
(143, 451, '01111', 3),
(144, 451, '01112', 3),
(145, 451, '01117', 3),
(146, 453, '01111', 3),
(147, 454, '01111', 3),
(148, 455, '11141', 3),
(149, 456, '11141', 3),
(150, 458, '11141', 3),
(151, 458, '11144', 3),
(152, 459, '11141', 3),
(153, 459, '11144', 3),
(154, 460, '11141', 3),
(155, 460, '11144', 3),
(156, 449, '991115', 0),
(157, 1, '11141', 3),
(158, 1, '11142', 3);

-- --------------------------------------------------------

--
-- Table structure for table `tbl_desirable_7`
--

CREATE TABLE `tbl_desirable_7` (
  `DataID` int(11) NOT NULL,
  `course_teachingID` int(11) DEFAULT NULL,
  `stdID` varchar(250) DEFAULT NULL,
  `score` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table `tbl_desirable_7`
--

INSERT INTO `tbl_desirable_7` (`DataID`, `course_teachingID`, `stdID`, `score`) VALUES
(133, 447, '01111', 3),
(134, 447, '01112', 3),
(135, 447, '01117', 3),
(138, 449, '01111', 3),
(139, 449, '01112', 3),
(140, 449, '01117', 3),
(143, 451, '01111', 3),
(144, 451, '01112', 3),
(145, 451, '01117', 3),
(146, 453, '01111', 3),
(147, 454, '01111', 3),
(148, 455, '11141', 3),
(149, 456, '11141', 3),
(150, 458, '11141', 3),
(151, 458, '11144', 3),
(152, 459, '11141', 3),
(153, 459, '11144', 3),
(154, 460, '11141', 3),
(155, 460, '11144', 3),
(156, 449, '991115', 0),
(157, 1, '11141', 3),
(158, 1, '11142', 3);

-- --------------------------------------------------------

--
-- Table structure for table `tbl_desirable_8`
--

CREATE TABLE `tbl_desirable_8` (
  `DataID` int(11) NOT NULL,
  `course_teachingID` int(11) DEFAULT NULL,
  `stdID` varchar(250) DEFAULT NULL,
  `score` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table `tbl_desirable_8`
--

INSERT INTO `tbl_desirable_8` (`DataID`, `course_teachingID`, `stdID`, `score`) VALUES
(133, 447, '01111', 3),
(134, 447, '01112', 3),
(135, 447, '01117', 3),
(138, 449, '01111', 3),
(139, 449, '01112', 3),
(140, 449, '01117', 3),
(143, 451, '01111', 3),
(144, 451, '01112', 3),
(145, 451, '01117', 3),
(146, 453, '01111', 3),
(147, 454, '01111', 3),
(148, 455, '11141', 3),
(149, 456, '11141', 3),
(150, 458, '11141', 3),
(151, 458, '11144', 3),
(152, 459, '11141', 3),
(153, 459, '11144', 3),
(154, 460, '11141', 3),
(155, 460, '11144', 3),
(156, 449, '991115', 0),
(157, 1, '11141', 3),
(158, 1, '11142', 3);

-- --------------------------------------------------------

--
-- Table structure for table `tbl_exam_final_object`
--

CREATE TABLE `tbl_exam_final_object` (
  `DataID` int(11) NOT NULL,
  `courseID` int(11) DEFAULT NULL,
  `objective_conclude` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- --------------------------------------------------------

--
-- Table structure for table `tbl_exam_mid_object`
--

CREATE TABLE `tbl_exam_mid_object` (
  `DataID` int(11) NOT NULL,
  `courseID` int(11) DEFAULT NULL,
  `objective_conclude` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- --------------------------------------------------------

--
-- Table structure for table `tbl_final_exam_score`
--

CREATE TABLE `tbl_final_exam_score` (
  `DataID` int(11) NOT NULL,
  `course_teachingID` int(11) DEFAULT NULL,
  `stdID` varchar(250) DEFAULT NULL,
  `score` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table `tbl_final_exam_score`
--

INSERT INTO `tbl_final_exam_score` (`DataID`, `course_teachingID`, `stdID`, `score`) VALUES
(240, 447, '01111', 25),
(241, 447, '01112', 20),
(242, 447, '01117', 20),
(245, 451, '01111', 10),
(246, 451, '01112', 15),
(247, 451, '01117', 8),
(248, 453, '01111', 25),
(249, 454, '01111', 25),
(250, 455, '11141', 25),
(251, 456, '11141', 25),
(252, 458, '11141', 25),
(253, 458, '11144', 25),
(254, 459, '11141', 5),
(255, 459, '11144', 25),
(256, 460, '11141', 25),
(257, 460, '11144', 25);

-- --------------------------------------------------------

--
-- Table structure for table `tbl_log`
--

CREATE TABLE `tbl_log` (
  `log_id` int(11) NOT NULL,
  `title_action` varchar(255) NOT NULL,
  `menu_name` varchar(200) NOT NULL,
  `data_id` int(11) NOT NULL,
  `update_by` int(11) NOT NULL,
  `update_time` datetime NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

--
-- Dumping data for table `tbl_log`
--

INSERT INTO `tbl_log` (`log_id`, `title_action`, `menu_name`, `data_id`, `update_by`, `update_time`) VALUES
(559, 'แก้ไขข้อมูล Aboutus', 'Aboutus', 20, 1, '2017-03-02 15:21:51'),
(560, 'แก้ไขข้อมูล Aboutus', 'Aboutus', 20, 1, '2017-03-02 15:22:12'),
(561, 'แก้ไขข้อมูล Aboutus', 'Aboutus', 20, 1, '2017-03-02 15:23:18'),
(562, 'แก้ไขข้อมูล Aboutus', 'Aboutus', 20, 1, '2017-03-02 15:23:28'),
(563, 'แก้ไขข้อมูล Aboutus', 'Aboutus', 20, 1, '2017-03-02 15:23:47'),
(564, 'แก้ไขข้อมูล Contact', 'Contact', 8, 1, '2017-03-08 17:50:28'),
(565, 'เพิ่มข้อมูล Project', 'Project', 30, 1, '2017-03-29 12:23:47'),
(566, 'ลบข้อมูล Project', 'Project', 30, 1, '2017-03-29 12:23:54'),
(567, 'เพิ่มข้อมูล Project', 'Project', 31, 1, '2017-03-29 14:12:11'),
(568, 'เพิ่มข้อมูล Project', 'Project', 32, 1, '2017-03-29 14:12:37'),
(569, 'แก้ไขข้อมูล Project', 'Project', 0, 32, '2017-03-29 14:13:01'),
(570, 'แก้ไขข้อมูล Project', 'Project', 0, 32, '2017-03-29 14:13:23'),
(571, 'เพิ่มข้อมูล Project', 'Project', 33, 1, '2017-03-29 14:14:24'),
(572, 'แก้ไขข้อมูล Project', 'Project', 0, 33, '2017-03-29 14:15:37'),
(573, 'เพิ่มข้อมูล Project', 'Project', 34, 1, '2017-03-29 14:19:54'),
(574, 'ลบข้อมูล Project', 'Project', 33, 1, '2017-03-29 14:21:06'),
(575, 'ลบข้อมูล Project', 'Project', 34, 1, '2017-03-29 14:21:09'),
(576, 'แก้ไขข้อมูล Project', 'Project', 0, 29, '2017-03-29 14:21:25'),
(577, 'เพิ่มข้อมูล Project', 'Project', 35, 1, '2017-03-29 14:24:07'),
(578, 'ลบข้อมูล Product', 'Product', 32, 1, '2017-03-29 16:57:44'),
(579, 'แก้ไขข้อมูล km_strategic', 'km_strategic', 1, 1, '2017-08-17 22:33:40'),
(580, 'แก้ไขข้อมูล km_strategic', 'km_strategic', 1, 1, '2017-08-17 22:35:06'),
(581, 'แก้ไขข้อมูล km_strategic', 'km_strategic', 1, 1, '2017-08-17 22:35:15'),
(582, 'แก้ไขข้อมูล km_strategic', 'km_strategic', 1, 1, '2017-08-17 22:35:22'),
(583, 'แก้ไขข้อมูล km_strategic', 'km_strategic', 1, 1, '2017-08-17 22:36:10'),
(584, 'แก้ไขข้อมูล km_strategic', 'km_strategic', 1, 1, '2017-08-17 22:36:19'),
(585, 'แก้ไขข้อมูล km_strategic', 'km_strategic', 1, 1, '2017-08-17 22:36:43'),
(586, 'แก้ไขข้อมูล km_strategic', 'km_strategic', 1, 1, '2017-08-17 22:36:50'),
(587, 'แก้ไขข้อมูล km_strategic', 'km_strategic', 1, 1, '2017-08-17 22:39:05'),
(588, 'แก้ไขข้อมูล km_strategic', 'km_strategic', 1, 1, '2017-08-17 22:39:16'),
(589, 'แก้ไขข้อมูล km_strategic', 'km_strategic', 1, 1, '2017-08-17 22:39:29'),
(590, 'แก้ไขข้อมูล km_strategic', 'km_strategic', 1, 1, '2017-08-17 22:39:37'),
(591, 'แก้ไขข้อมูล km_strategic', 'km_strategic', 1, 1, '2017-08-17 22:41:26'),
(592, 'แก้ไขข้อมูล km_strategic', 'km_strategic', 1, 1, '2017-08-17 22:41:33'),
(593, 'แก้ไขข้อมูล km_strategic', 'km_strategic', 1, 1, '2017-08-17 22:41:39'),
(594, 'เพิ่มข้อมูล km_strategic', 'km_strategic', 2, 1, '2017-08-17 22:48:15'),
(595, 'เพิ่มข้อมูล km_strategic', 'km_strategic', 3, 1, '2017-08-17 22:52:03'),
(596, 'แก้ไขข้อมูล km_strategic', 'km_strategic', 3, 1, '2017-08-17 22:56:55'),
(597, 'เพิ่มข้อมูล km_strategic', 'km_strategic', 4, 1, '2017-08-17 22:57:44'),
(598, 'เพิ่มข้อมูล km_strategic', 'km_strategic', 5, 1, '2017-08-18 10:45:38'),
(599, 'เพิ่มข้อมูล km_strategic', 'km_strategic', 6, 1, '2017-08-18 10:45:50'),
(600, 'เพิ่มข้อมูล km_strategic', 'km_strategic', 7, 1, '2017-08-18 10:50:00'),
(601, 'เพิ่มข้อมูล km_strategic', 'km_strategic', 8, 1, '2017-08-18 10:50:22'),
(602, 'เพิ่มข้อมูล km_strategic', 'km_strategic', 9, 1, '2017-08-18 10:52:03'),
(603, 'เพิ่มข้อมูล km_committee', 'km_committee', 10, 1, '2017-08-18 11:11:03'),
(604, 'เพิ่มข้อมูล km_committee', 'km_committee', 11, 1, '2017-08-18 11:27:37'),
(605, 'แก้ไขข้อมูล km_department', 'km_department', 10, 1, '2017-08-18 11:30:01'),
(606, 'แก้ไขข้อมูล km_department_work', 'km_department_work', 2, 1, '2017-08-21 20:26:00'),
(607, 'แก้ไขข้อมูล km_department_work', 'km_department_work', 2, 1, '2017-08-21 20:27:15'),
(608, 'แก้ไขข้อมูล km_department_work', 'km_department_work', 1, 1, '2017-08-21 20:29:41'),
(609, 'แก้ไขข้อมูล km_department_work', 'km_department_work', 1, 1, '2017-08-21 20:30:05'),
(610, 'แก้ไขข้อมูล km_department_work', 'km_department_work', 1, 1, '2017-08-21 20:31:53'),
(611, 'แก้ไขข้อมูล km_department_work', 'km_department_work', 2, 1, '2017-08-21 21:23:54'),
(612, 'แก้ไขข้อมูล km_department_work', 'km_department_work', 2, 1, '2017-08-21 21:23:55'),
(613, 'แก้ไขข้อมูล km_department_work', 'km_department_work', 1, 1, '2017-08-21 21:24:29'),
(614, 'แก้ไขข้อมูล km_department_work', 'km_department_work', 1, 1, '2017-08-21 21:26:15'),
(615, 'แก้ไขข้อมูล km_department_work', 'km_department_work', 2, 1, '2017-08-21 21:27:34'),
(616, 'แก้ไขข้อมูล km_department_work', 'km_department_work', 1, 1, '2017-08-21 21:34:42'),
(617, 'แก้ไขข้อมูล km_innovations_group', 'km_innovations_group', 12, 1, '2017-08-22 10:03:02'),
(618, 'แก้ไขข้อมูล km_innovations_group', 'km_innovations_group', 12, 1, '2017-08-22 10:03:07'),
(619, 'แก้ไขข้อมูล km_innovations', 'km_innovations', 1, 1, '2017-08-22 10:34:54'),
(620, 'แก้ไขข้อมูล km_innovations', 'km_innovations', 1, 1, '2017-08-22 10:35:19'),
(621, 'แก้ไขข้อมูล km_innovations', 'km_innovations', 1, 1, '2017-08-22 10:35:29'),
(622, 'แก้ไขข้อมูล km_innovations', 'km_innovations', 1, 1, '2017-08-22 10:36:22'),
(623, 'เพิ่มข้อมูล km_innovations_group', 'km_innovations_group', 13, 1, '2017-08-22 10:37:59'),
(624, 'แก้ไขข้อมูล km_innovations', 'km_innovations', 1, 1, '2017-08-22 10:38:08'),
(625, 'แก้ไขข้อมูล km_innovations', 'km_innovations', 1, 1, '2017-08-22 10:39:00'),
(626, 'แก้ไขข้อมูล km_innovations', 'km_innovations', 1, 1, '2017-08-22 10:39:08'),
(627, 'เพิ่มข้อมูล km_strategic', 'km_strategic', 1, 1, '2017-08-22 11:24:59'),
(628, 'เพิ่มข้อมูล km_strategic', 'km_strategic', 2, 1, '2017-08-22 11:25:09'),
(629, 'เพิ่มข้อมูล km_strategic', 'km_strategic', 3, 1, '2017-08-22 11:25:16'),
(630, 'แก้ไขข้อมูล km_strategic', 'km_strategic', 3, 1, '2017-08-22 11:25:29'),
(631, 'แก้ไขข้อมูล km_committee', 'km_committee', 10, 1, '2017-08-22 11:32:03'),
(632, 'แก้ไขข้อมูล km_committee', 'km_committee', 11, 1, '2017-08-22 11:32:20'),
(633, 'เพิ่มข้อมูล km_committee', 'km_committee', 12, 1, '2017-08-22 11:32:34'),
(634, 'เพิ่มข้อมูล km_department', 'km_department', 12, 1, '2017-08-22 11:36:17'),
(635, 'เพิ่มข้อมูล km_department', 'km_department', 13, 1, '2017-08-22 11:36:40'),
(636, 'แก้ไขข้อมูล km_department', 'km_department', 10, 1, '2017-08-22 11:36:51'),
(637, 'จัดอันดับข้อมูล km_department', 'km_department', 12, 1, '2017-08-22 11:37:08'),
(638, 'เพิ่มข้อมูล km_department', 'km_department', 14, 1, '2017-08-22 11:38:32'),
(639, 'เพิ่มข้อมูล km_department', 'km_department', 15, 1, '2017-08-22 11:38:56'),
(640, 'เพิ่มข้อมูล km_department', 'km_department', 16, 1, '2017-08-22 11:39:23'),
(641, 'แก้ไขข้อมูล km_department_work', 'km_department_work', 1, 1, '2017-08-22 11:40:08'),
(642, 'แก้ไขข้อมูล km_department_work', 'km_department_work', 1, 1, '2017-08-22 11:40:21'),
(643, 'แก้ไขข้อมูล km_department_work', 'km_department_work', 1, 1, '2017-08-22 11:40:33'),
(644, 'แก้ไขข้อมูล km_department_work', 'km_department_work', 1, 1, '2017-08-22 11:42:49'),
(645, 'แก้ไขข้อมูล km_department_work', 'km_department_work', 1, 1, '2017-08-22 11:43:30'),
(646, 'แก้ไขข้อมูล km_department_work', 'km_department_work', 1, 1, '2017-08-22 11:45:31'),
(647, 'แก้ไขข้อมูล km_department_work', 'km_department_work', 1, 1, '2017-08-22 11:46:16'),
(648, 'แก้ไขข้อมูล km_department_work', 'km_department_work', 1, 1, '2017-08-22 11:46:51'),
(649, 'เพิ่มข้อมูล km_department_work', 'km_department_work', 3, 1, '2017-08-22 11:47:28'),
(650, 'แก้ไขข้อมูล km_department_work', 'km_department_work', 3, 1, '2017-08-22 11:47:44'),
(651, 'เพิ่มข้อมูล km_department_work', 'km_department_work', 4, 1, '2017-08-22 11:48:44'),
(652, 'แก้ไขข้อมูล km_innovations_group', 'km_innovations_group', 12, 1, '2017-08-22 12:01:14'),
(653, 'แก้ไขข้อมูล km_innovations_group', 'km_innovations_group', 13, 1, '2017-08-22 12:01:18'),
(654, 'แก้ไขข้อมูล km_innovations', 'km_innovations', 1, 1, '2017-08-22 12:02:57'),
(655, 'เพิ่มข้อมูล km_innovations', 'km_innovations', 2, 1, '2017-08-22 12:03:26'),
(656, 'แก้ไขข้อมูล km_innovations', 'km_innovations', 1, 1, '2017-08-22 13:14:34'),
(657, 'เพิ่มข้อมูล km_conner', 'km_conner', 2, 1, '2017-08-22 13:17:51'),
(658, 'เพิ่มข้อมูล km_conner', 'km_conner', 3, 1, '2017-08-22 13:18:02'),
(659, 'เพิ่มข้อมูล km_conner', 'km_conner', 4, 1, '2017-08-22 13:18:12'),
(660, 'เพิ่มข้อมูล km_conner', 'km_conner', 5, 1, '2017-08-22 13:18:23'),
(661, 'เพิ่มข้อมูล km_conner', 'km_conner', 6, 1, '2017-08-22 13:18:34'),
(662, 'เพิ่มข้อมูล km_conner', 'km_conner', 7, 1, '2017-08-22 13:18:46'),
(663, 'เพิ่มข้อมูล km_conner', 'km_conner', 8, 1, '2017-08-22 13:19:01'),
(664, 'เพิ่มข้อมูล km_innovations', 'km_innovations', 3, 1, '2017-08-22 13:34:07'),
(665, 'แก้ไขข้อมูล km_innovations', 'km_innovations', 3, 1, '2017-08-22 13:34:16'),
(666, 'เพิ่มข้อมูล km_innovations', 'km_innovations', 4, 1, '2017-08-22 13:35:34'),
(667, 'แก้ไขข้อมูล km_innovations', 'km_innovations', 4, 1, '2017-08-22 13:36:22'),
(668, 'เพิ่มข้อมูล km_innovations', 'km_innovations', 5, 1, '2017-08-22 13:36:54'),
(669, 'เพิ่มข้อมูล km_innovations', 'km_innovations', 6, 1, '2017-08-22 13:37:18'),
(670, 'เพิ่มข้อมูล km_innovations', 'km_innovations', 7, 1, '2017-08-22 13:37:48'),
(671, 'เพิ่มข้อมูล km_innovations', 'km_innovations', 8, 1, '2017-08-22 13:42:13'),
(672, 'เพิ่มข้อมูล km_innovations', 'km_innovations', 9, 1, '2017-08-22 13:43:14'),
(673, 'เพิ่มข้อมูล km_innovations', 'km_innovations', 10, 1, '2017-08-22 13:43:37'),
(674, 'เพิ่มข้อมูล km_innovations', 'km_innovations', 11, 1, '2017-08-22 13:43:55'),
(675, 'เพิ่มข้อมูล km_innovations', 'km_innovations', 12, 1, '2017-08-22 13:44:18'),
(676, 'แก้ไขข้อมูล km_innovations', 'km_innovations', 11, 1, '2017-08-22 13:44:51'),
(677, 'แก้ไขข้อมูล km_activities', 'km_activities', 1, 1, '2017-08-25 22:21:03'),
(678, 'แก้ไขข้อมูล km_activities', 'km_activities', 1, 1, '2017-08-25 22:21:12'),
(679, 'แก้ไขข้อมูล km_activities', 'km_activities', 1, 1, '2017-08-25 22:21:18'),
(680, 'เพิ่มข้อมูล km_activities', 'km_activities', 2, 1, '2017-08-25 22:22:56'),
(681, 'เพิ่มข้อมูล km_activities', 'km_activities', 3, 1, '2017-08-25 22:23:04'),
(682, 'แก้ไขข้อมูล km_activities', 'km_activities', 1, 1, '2017-08-25 22:23:30'),
(683, 'แก้ไขข้อมูล km_activities', 'km_activities', 1, 1, '2017-08-25 22:23:34'),
(684, 'แก้ไขข้อมูล km_activities', 'km_activities', 1, 1, '2017-08-25 22:23:39'),
(685, 'แก้ไขข้อมูล km_activities', 'km_activities', 1, 1, '2017-08-25 22:23:46'),
(686, 'แก้ไขข้อมูล km_activities', 'km_activities', 1, 1, '2017-08-25 22:23:54'),
(687, 'แก้ไขข้อมูล km_activities', 'km_activities', 1, 1, '2017-08-25 22:23:59'),
(688, 'แก้ไขข้อมูล km_activities', 'km_activities', 1, 1, '2017-08-25 22:24:04'),
(689, 'แก้ไขข้อมูล km_activities', 'km_activities', 1, 1, '2017-08-25 22:24:09'),
(690, 'เพิ่มข้อมูล km_activities', 'km_activities', 4, 1, '2017-08-25 22:24:29'),
(691, 'เพิ่มข้อมูล km_activities', 'km_activities', 5, 1, '2017-08-26 14:06:25'),
(692, 'เพิ่มข้อมูล km_activities', 'km_activities', 6, 1, '2017-08-26 14:25:11'),
(693, 'แก้ไขข้อมูล km_activities', 'km_activities', 5, 1, '2017-08-26 17:03:43'),
(694, 'แก้ไขข้อมูล km_innovations', 'km_innovations', 2, 1, '2017-08-27 10:44:40'),
(695, 'แก้ไขข้อมูล km_innovations', 'km_innovations', 1, 1, '2017-08-27 10:45:29'),
(696, 'แก้ไขข้อมูล km_innovations', 'km_innovations', 2, 1, '2017-08-27 11:12:39'),
(697, 'แก้ไขข้อมูล km_innovations', 'km_innovations', 2, 1, '2017-08-27 11:12:47'),
(698, 'แก้ไขข้อมูล km_innovations', 'km_innovations', 2, 1, '2017-08-27 11:13:33'),
(699, 'แก้ไขข้อมูล km_innovations', 'km_innovations', 2, 1, '2017-08-27 11:17:55'),
(700, 'แก้ไขข้อมูล km_innovations', 'km_innovations', 2, 1, '2017-08-27 11:18:16'),
(701, 'แก้ไขข้อมูล km_innovations', 'km_innovations', 6, 1, '2017-08-27 11:18:50'),
(702, 'แก้ไขข้อมูล km_conner', 'km_conner', 2, 1, '2017-08-27 11:31:49'),
(703, 'แก้ไขข้อมูล km_conner', 'km_conner', 2, 1, '2017-08-27 11:32:24'),
(704, 'แก้ไขข้อมูล km_documents', 'km_documents', 2, 1, '2017-08-27 11:34:38'),
(705, 'แก้ไขข้อมูล km_conner', 'km_conner', 3, 1, '2017-08-27 11:37:04'),
(706, 'เพิ่มข้อมูล km_documents', 'km_documents', 3, 1, '2017-08-27 14:01:03'),
(707, 'เพิ่มข้อมูล km_documents', 'km_documents', 4, 1, '2017-08-27 14:01:36'),
(708, 'แก้ไขข้อมูล km_documents', 'km_documents', 2, 1, '2017-08-27 14:02:25'),
(709, 'แก้ไขข้อมูล km_documents', 'km_documents', 2, 1, '2017-08-27 14:07:45'),
(710, 'เพิ่มข้อมูล km_documents', 'km_documents', 5, 1, '2017-08-27 14:09:41'),
(711, 'เพิ่มข้อมูล km_documents', 'km_documents', 6, 1, '2017-08-27 14:21:08'),
(712, 'แก้ไขข้อมูล km_innovations', 'km_innovations', 2, 1, '2017-08-27 14:41:17'),
(713, 'แก้ไขข้อมูล km_innovations', 'km_innovations', 1, 1, '2017-08-27 15:06:09'),
(714, 'แก้ไขข้อมูล km_innovations', 'km_innovations', 4, 1, '2017-08-27 15:09:31');

-- --------------------------------------------------------

--
-- Table structure for table `tbl_log_upclass`
--

CREATE TABLE `tbl_log_upclass` (
  `DataID` int(11) NOT NULL,
  `user_add` int(11) NOT NULL,
  `c_date` date NOT NULL,
  `std_year_old` varchar(250) NOT NULL,
  `std_year_new` varchar(250) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- --------------------------------------------------------

--
-- Table structure for table `tbl_mid_exam_score`
--

CREATE TABLE `tbl_mid_exam_score` (
  `DataID` int(11) NOT NULL,
  `course_teachingID` int(11) DEFAULT NULL,
  `stdID` varchar(250) DEFAULT NULL,
  `score` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table `tbl_mid_exam_score`
--

INSERT INTO `tbl_mid_exam_score` (`DataID`, `course_teachingID`, `stdID`, `score`) VALUES
(240, 447, '01111', 25),
(241, 447, '01112', 25),
(242, 447, '01117', 25),
(245, 451, '01111', 25),
(246, 451, '01112', 25),
(247, 451, '01117', 25),
(248, 453, '01111', 25),
(249, 454, '01111', 25),
(250, 455, '11141', 25),
(251, 456, '11141', 25),
(252, 458, '11141', 25),
(253, 458, '11144', 25),
(254, 459, '11141', 5),
(255, 459, '11144', 25),
(256, 460, '11141', 25),
(257, 460, '11144', 25);

-- --------------------------------------------------------

--
-- Table structure for table `tbl_news`
--

CREATE TABLE `tbl_news` (
  `DataID` int(11) NOT NULL,
  `title` text NOT NULL,
  `detail` text NOT NULL,
  `author` int(11) NOT NULL,
  `date` date NOT NULL,
  `status` int(11) NOT NULL DEFAULT '1'
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table `tbl_news`
--

INSERT INTO `tbl_news` (`DataID`, `title`, `detail`, `author`, `date`, `status`) VALUES
(48, 'โรงเรียนรับการประเมินสุขาน่าใช้ ส้วมปลอดภัย ประจำปี 2561', 'คณะกรรมการจาก กองสาธารณสุข ร่วมกับ รพ.ร้อยเอ็ด ประเมินสุขาน่าใช้ ส้วมปลอดภัย ประจำปี 2561 โดยมีคณะผู้บริหารสถานศึกษา หัวหน้าช่วงชั้น และคณะกรรมการนักเรียน ร่วมต้อนรับและ รายงานผลการปฏิบัติงาน', 313, '2018-06-29', 1),
(49, 'อธิบดีกรมส่งเสริมการปกครองท้องถิ่นเยี่ยมชมโรงเรียน', 'คณะผู้บริหาร คณะครู และนักเรียนโรงเรียนเทศบาลวัดสระทอง ร่วมต้อนรับนายสุทธิพงษ์ จุลเจริญ อธิบดีกรมส่งเสริมการปกครองท้องถิ่น นายนายวันชัย คงเกษม ผู้ว่าราชการจังหวัดร้อยเอ็ด นายบรรจง โฆษิตจิรนันท์ นายกเทศมนตรีเมืองร้อยเอ็ด พร้อมคณะ เยี่ยมชมโครงการ SBMLD ของโรงเรียน เยี่ยมชมการแสดงของนักเรียน และเยี่ยมชมการเรียนการสอนภาษาจีนในโรงเรียน', 313, '2018-06-29', 1),
(50, 'คุณครูสอนภาษาจีนคนใหม่ ประจำปีการศึกษา 2561', 'คณะผู้บริหาร คณะครูเดินทางไปสถาบันขงจื้อ มหาวิทยาลัยมหาสารคาม เพื่อรับคุณครูสอนภาษาจีนคนใหม่ ประจำปีการศึกษา 2561', 313, '2018-06-29', 1),
(51, 'งานแถลงข่าวการจัดงาน &quot;เล่าเรื่องเมืองร้อยเอ็ด&quot; 243 ปี', 'คณะผู้บริหารโรงเรียนนำโดยท่าน ดร. ประวิทย์ โอวาทกานนท์ ผู้บริหารสถานศึกษา พร้อม คณะครู นักเรียน ร่วมต้อนรับนายวันชัย คงเกษม ผู้ว่าราชการจังหวัดร้อยเอ็ด ในงานแถลงข่าวการจัดงาน &quot;เล่าเรื่องเมืองร้อยเอ็ด&quot; 243 ปี', 313, '2018-06-29', 1);

-- --------------------------------------------------------

--
-- Table structure for table `tbl_news_gallery`
--

CREATE TABLE `tbl_news_gallery` (
  `DataID` int(11) NOT NULL,
  `newsID` int(11) DEFAULT NULL,
  `file_name` text
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table `tbl_news_gallery`
--

INSERT INTO `tbl_news_gallery` (`DataID`, `newsID`, `file_name`) VALUES
(14, 48, 'file_5b3541d9193e0.jpg'),
(15, 49, 'file_5b3542063d8dc.jpg'),
(16, 50, 'file_5b35422438d98.jpg'),
(17, 51, 'file_5b354251e7891.jpg');

-- --------------------------------------------------------

--
-- Table structure for table `tbl_news_gallery_sub`
--

CREATE TABLE `tbl_news_gallery_sub` (
  `DataID` int(11) NOT NULL,
  `newsID` int(11) DEFAULT NULL,
  `file_name` text
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table `tbl_news_gallery_sub`
--

INSERT INTO `tbl_news_gallery_sub` (`DataID`, `newsID`, `file_name`) VALUES
(31, 48, 'file_5b3541d923851.jpg'),
(32, 48, 'file_5b3541d934d17.jpg'),
(33, 48, 'file_5b3541d9440df.jpg'),
(34, 49, 'file_5b35420658d82.jpg'),
(35, 49, 'file_5b35420678901.jpg'),
(36, 49, 'file_5b3542068bc17.jpg'),
(37, 50, 'file_5b35422444f10.jpg'),
(38, 50, 'file_5b35422450487.jpg'),
(39, 51, 'file_5b35425210ccc.jpg'),
(40, 51, 'file_5b354252290a6.jpg'),
(41, 51, 'file_5b35425233530.jpg'),
(42, 51, 'file_5b3542523a8f3.jpg');

-- --------------------------------------------------------

--
-- Table structure for table `tbl_objective_conclude`
--

CREATE TABLE `tbl_objective_conclude` (
  `DataID` int(11) NOT NULL,
  `courseID` int(11) DEFAULT NULL,
  `no_order` int(11) DEFAULT NULL,
  `detail` text,
  `proportion_status` int(11) NOT NULL,
  `score` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table `tbl_objective_conclude`
--

INSERT INTO `tbl_objective_conclude` (`DataID`, `courseID`, `no_order`, `detail`, `proportion_status`, `score`) VALUES
(31, 412, 1, '1', 1, 25),
(32, 412, 2, '2', 2, 25),
(33, 419, 1, '1', 1, 25),
(34, 419, 2, '2', 2, 25),
(35, 409, 1, '1', 1, 25),
(36, 409, 2, '2', 2, 25),
(37, 410, 1, '1', 1, 25),
(38, 410, 2, '2', 2, 25),
(39, 413, 1, '1', 1, 25),
(40, 413, 2, '2', 2, 25),
(41, 414, 1, '1', 1, 25),
(42, 414, 2, '2', 2, 25),
(43, 418, 1, '1', 1, 25),
(44, 418, 2, '2', 2, 25),
(45, 420, 1, '1', 1, 25),
(46, 420, 2, '2', 2, 25),
(47, 421, 1, '1', 1, 25),
(48, 421, 2, '2', 2, 25);

-- --------------------------------------------------------

--
-- Table structure for table `tbl_objective_score_std`
--

CREATE TABLE `tbl_objective_score_std` (
  `DataID` int(11) NOT NULL,
  `objectiveID` int(11) DEFAULT NULL,
  `registed_courseID` int(11) DEFAULT NULL,
  `staID` varchar(250) DEFAULT NULL,
  `score` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table `tbl_objective_score_std`
--

INSERT INTO `tbl_objective_score_std` (`DataID`, `objectiveID`, `registed_courseID`, `staID`, `score`) VALUES
(479, 32, 696, '01111', 25),
(480, 32, 696, '01112', 25),
(481, 32, 696, '01117', 25),
(482, 31, 696, '01111', 25),
(483, 31, 696, '01112', 25),
(484, 31, 696, '01117', 25),
(485, 33, 697, '11141', 25),
(486, 33, 697, '11144', 25),
(487, 34, 697, '11141', 25),
(488, 34, 697, '11144', 25),
(489, 35, 701, '01111', 25),
(490, 35, 701, '01112', 24),
(491, 35, 701, '01117', 25),
(492, 36, 701, '01111', 25),
(493, 36, 701, '01112', 25),
(494, 36, 701, '01117', 25),
(495, 41, 702, '01111', 25),
(496, 42, 702, '01111', 25),
(497, 39, 703, '01111', 25),
(498, 40, 703, '01111', 25),
(499, 43, 706, '11141', 25),
(500, 44, 706, '11141', 25),
(501, 33, 705, '11141', 25),
(502, 34, 705, '11141', 25),
(503, 47, 707, '11141', 25),
(504, 47, 707, '11144', 25),
(505, 48, 707, '11141', 25),
(506, 48, 707, '11144', 25),
(507, 45, 708, '11141', 25),
(508, 45, 708, '11144', 25),
(509, 46, 708, '11141', 25),
(510, 46, 708, '11144', 25),
(511, 43, 709, '11141', 25),
(512, 43, 709, '11144', 25),
(513, 44, 709, '11141', 25),
(514, 44, 709, '11144', 25);

-- --------------------------------------------------------

--
-- Table structure for table `tbl_pp6`
--

CREATE TABLE `tbl_pp6` (
  `DataID` int(11) NOT NULL,
  `std_ID` varchar(250) DEFAULT NULL,
  `card_ID` varchar(250) NOT NULL,
  `name_title` varchar(250) NOT NULL,
  `fname` varchar(250) NOT NULL,
  `lname` varchar(250) NOT NULL,
  `class_level` varchar(250) NOT NULL,
  `room` varchar(250) NOT NULL,
  `term` varchar(250) DEFAULT NULL,
  `year` varchar(250) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table `tbl_pp6`
--

INSERT INTO `tbl_pp6` (`DataID`, `std_ID`, `card_ID`, `name_title`, `fname`, `lname`, `class_level`, `room`, `term`, `year`) VALUES
(1745, '11141', '1232312321122', 'dekchai', 'นักเรียน17', 'นักเรียน17', 'm1', '1', '2', '2561'),
(1746, '11142', '1232312324414', 'dekchai', 'นักเรียน19', 'นักเรียน19', 'm1', '1', '2', '2561'),
(1747, '11144', '1232312321891', 'dekchai', 'นักเรียน18', 'นักเรียน18', 'm1', '2', '2', '2561'),
(1748, '11143', '3322312321892', 'dekchai', 'นักเรียน20', 'นักเรียน20', 'm1', '2', '2', '2561'),
(1749, '111541', '1232312321224', 'dekchai', 'นักเรียน21', 'นักเรียน21', 'm1', '3', '2', '2561'),
(1750, '01112', '1232345432344', 'dekchai', 'นักเรียน2', 'นักเรียน2', 'p1', '1', '1,2', '2561'),
(1751, '01117', '1232123456543', 'nangsaw', 'นักเรียน6', 'นักเรียน6', 'p1', '1', '1,2', '2561'),
(1752, '991115', '2345434567654', 'dekchai', '991115', '991115', 'p1', '2', '1,2', '2561');

-- --------------------------------------------------------

--
-- Table structure for table `tbl_pp6_mid`
--

CREATE TABLE `tbl_pp6_mid` (
  `DataID` int(11) NOT NULL,
  `std_ID` varchar(250) DEFAULT NULL,
  `card_ID` varchar(250) DEFAULT NULL,
  `name_title` varchar(250) DEFAULT NULL,
  `fname` varchar(250) DEFAULT NULL,
  `lname` varchar(250) DEFAULT NULL,
  `class_level` varchar(250) DEFAULT NULL,
  `room` varchar(250) DEFAULT NULL,
  `term` varchar(250) DEFAULT NULL,
  `year` varchar(250) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table `tbl_pp6_mid`
--

INSERT INTO `tbl_pp6_mid` (`DataID`, `std_ID`, `card_ID`, `name_title`, `fname`, `lname`, `class_level`, `room`, `term`, `year`) VALUES
(550, '01112', '1232345432344', 'dekchai', 'นักเรียน2', 'นักเรียน2', 'p1', '1', '1,2', '2561'),
(551, '01117', '1232123456543', 'nangsaw', 'นักเรียน6', 'นักเรียน6', 'p1', '1', '1,2', '2561');

-- --------------------------------------------------------

--
-- Table structure for table `tbl_proportion`
--

CREATE TABLE `tbl_proportion` (
  `DataID` int(11) NOT NULL,
  `courseID` int(11) DEFAULT NULL,
  `comulative` int(11) DEFAULT NULL,
  `mid_exam` int(11) DEFAULT NULL,
  `final_exam` int(11) DEFAULT NULL,
  `cumulative_before_mid` int(11) NOT NULL,
  `cumulative_after_mid` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table `tbl_proportion`
--

INSERT INTO `tbl_proportion` (`DataID`, `courseID`, `comulative`, `mid_exam`, `final_exam`, `cumulative_before_mid`, `cumulative_after_mid`) VALUES
(1770, 412, NULL, 25, 25, 25, 25),
(1771, 419, NULL, 25, 25, 25, 25),
(1772, 409, NULL, 25, 25, 25, 25),
(1773, 410, NULL, 25, 25, 25, 25),
(1774, 413, NULL, 25, 25, 25, 25),
(1775, 414, NULL, 25, 25, 25, 25),
(1776, 418, NULL, 25, 25, 25, 25),
(1777, 420, NULL, 25, 25, 25, 25),
(1778, 421, NULL, 25, 25, 25, 25);

-- --------------------------------------------------------

--
-- Table structure for table `tbl_read_score`
--

CREATE TABLE `tbl_read_score` (
  `DataID` int(11) NOT NULL,
  `course_teachingID` int(11) DEFAULT NULL,
  `stdID` varchar(250) DEFAULT NULL,
  `score` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table `tbl_read_score`
--

INSERT INTO `tbl_read_score` (`DataID`, `course_teachingID`, `stdID`, `score`) VALUES
(133, 447, '01111', 3),
(134, 447, '01112', 3),
(135, 447, '01117', 3),
(138, 449, '01111', 3),
(139, 449, '01112', 3),
(140, 449, '01117', 3),
(143, 451, '01111', 3),
(144, 451, '01112', 3),
(145, 451, '01117', 1),
(146, 453, '01111', 3),
(147, 454, '01111', 3),
(148, 455, '11141', 3),
(149, 456, '11141', 3),
(150, 458, '11141', 3),
(151, 458, '11144', 3),
(152, 459, '11141', 3),
(153, 459, '11144', 3),
(154, 460, '11141', 3),
(155, 460, '11144', 3),
(156, 1, '11141', 3),
(157, 1, '11142', 3),
(158, 1, '11144', 2);

-- --------------------------------------------------------

--
-- Table structure for table `tbl_registed_course`
--

CREATE TABLE `tbl_registed_course` (
  `DataID` int(11) NOT NULL,
  `courseID` int(11) DEFAULT NULL,
  `term` varchar(250) DEFAULT NULL,
  `year` varchar(250) DEFAULT NULL,
  `cdate` date DEFAULT NULL,
  `export_status` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tbl_registed_course`
--

INSERT INTO `tbl_registed_course` (`DataID`, `courseID`, `term`, `year`, `cdate`, `export_status`) VALUES
(696, 412, '1,2', '2561', '2018-07-13', 0),
(697, 419, '1', '2561', '2018-07-13', 0),
(698, 416, '1,2', '2561', '2018-07-13', 0),
(699, 417, '1', '2561', '2018-07-13', 0),
(700, 410, '1,2', '2561', '2018-07-13', 0),
(701, 409, '1,2', '2561', '2018-07-13', 0),
(703, 413, '1,2', '2560', '2018-07-15', 0),
(704, 420, '1', '2560', '2018-07-15', 0),
(707, 421, '1', '2561', '2018-07-15', 0),
(708, 420, '1', '2561', '2018-07-15', 0),
(709, 418, '2', '2561', '2018-07-15', 0),
(710, 417, '1', '2560', '2018-07-18', 0),
(711, 430, '2', '2561', '2018-07-19', 0);

-- --------------------------------------------------------

--
-- Table structure for table `tbl_registed_course_teaching`
--

CREATE TABLE `tbl_registed_course_teaching` (
  `DataID` int(11) NOT NULL,
  `registed_courseID` int(11) DEFAULT NULL,
  `cdate` date DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table `tbl_registed_course_teaching`
--

INSERT INTO `tbl_registed_course_teaching` (`DataID`, `registed_courseID`, `cdate`) VALUES
(1, 711, '2018-07-19'),
(447, 696, '2018-07-13'),
(451, 701, '2018-07-13'),
(452, 700, '2018-07-13'),
(453, 702, '2018-07-15'),
(454, 703, '2018-07-15'),
(455, 706, '2018-07-15'),
(456, 705, '2018-07-15'),
(457, 704, '2018-07-15'),
(458, 707, '2018-07-15'),
(459, 708, '2018-07-15'),
(460, 709, '2018-07-15'),
(483, 698, '2018-07-20');

-- --------------------------------------------------------

--
-- Table structure for table `tbl_regis_teacher`
--

CREATE TABLE `tbl_regis_teacher` (
  `DataID` int(11) NOT NULL,
  `positionID` varchar(250) NOT NULL,
  `username` varchar(250) NOT NULL,
  `password` varchar(250) NOT NULL,
  `position_name` varchar(250) NOT NULL,
  `department` text NOT NULL,
  `work` text NOT NULL,
  `more_detail` text NOT NULL,
  `fname_th` varchar(250) NOT NULL,
  `lname_th` varchar(250) NOT NULL,
  `fname_en` varchar(250) NOT NULL,
  `lname_en` varchar(250) NOT NULL,
  `study_history` text NOT NULL,
  `birthday` date NOT NULL,
  `blood_group` varchar(250) NOT NULL,
  `gender` varchar(250) NOT NULL,
  `tell` varchar(250) NOT NULL,
  `email` varchar(250) NOT NULL,
  `address` text NOT NULL,
  `cdate` date NOT NULL,
  `status` int(11) NOT NULL,
  `teacher_status` varchar(250) NOT NULL,
  `who_status` varchar(250) NOT NULL,
  `status_rang` int(11) NOT NULL,
  `status_alive` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table `tbl_regis_teacher`
--

INSERT INTO `tbl_regis_teacher` (`DataID`, `positionID`, `username`, `password`, `position_name`, `department`, `work`, `more_detail`, `fname_th`, `lname_th`, `fname_en`, `lname_en`, `study_history`, `birthday`, `blood_group`, `gender`, `tell`, `email`, `address`, `cdate`, `status`, `teacher_status`, `who_status`, `status_rang`, `status_alive`) VALUES
(21, '07693-2', 'admin_eva', '82219639bd900cdaf1c6b2e8c8064f0a', 'ครู', '', '', '', 'กัญญาวีร์', 'เขตคาม', 'gunyavi', 'khetkam', '', '1970-01-01', 'A', 'female', '-', '-', '-', '2017-09-10', 2, '', '1', 3, 5),
(311, '000001', 'Admin.E', '5dfb5c7190c9c6cec5bb20cf128a8c16', '', '', '', '', 'แอดมิน', 'วัดผล', 'Admin', 'Evaluation', '', '2008-01-16', 'A', 'male', '', '', '', '2018-06-19', 2, '', '', 3, 1),
(312, '000002', 'Admin.H', '12d0caa96704aa2fa0eafcda1da2f514', '', '', '', '', 'แอดมิน', 'สายชั้น', 'Admin', 'Headline', '', '2008-01-02', 'A', 'male', '', '', '', '2018-06-19', 4, '', '', 0, 1),
(313, '000003', 'Admin.N', 'ab7c65eb52e56a61e941f009a6e44c17', '', '', '', '', 'แอดมิน', 'ข่าว', 'Admin', 'News', '', '2008-01-01', 'A', 'male', '', '', '', '2018-06-19', 3, '', '', 0, 1),
(321, '2000002', 'two.m', 'ab7c65eb52e56a61e941f009a6e44c17', '', '', '', '', 'สอง', 'คณิต', 'two', 'ma', '', '1970-01-01', '', '', '', '', '', '0000-00-00', 1, '', '', 0, 1),
(323, '2000001', 'one.m', 'ab7c65eb52e56a61e941f009a6e44c17', '', '', '', '', 'หนึ่ง', 'คณิต', 'one', 'ma', '', '0000-00-00', '', '', '', '', '', '0000-00-00', 1, '', '', 0, 1),
(325, '2000003', 'tree.s', 'ab7c65eb52e56a61e941f009a6e44c17', '', '', '', '', 'สาม', 'วิทย์', 'tree', 'sci', '', '0000-00-00', '', '', '', '', '', '0000-00-00', 1, '', '', 0, 1),
(326, '2000004', 'four.t', 'ab7c65eb52e56a61e941f009a6e44c17', '', '', '', '', 'สี่', 'ไทย', 'four', 'th', '', '0000-00-00', '', '', '', '', '', '0000-00-00', 1, '', '', 0, 1),
(327, '2000005', 'five.e', 'ab7c65eb52e56a61e941f009a6e44c17', '', '', '', '', 'ห้า', 'สังคม', 'five', 'en', '', '0000-00-00', '', '', '', '', '', '0000-00-00', 1, '', '', 0, 1);

-- --------------------------------------------------------

--
-- Table structure for table `tbl_regis_teacher_gallery`
--

CREATE TABLE `tbl_regis_teacher_gallery` (
  `DataID` int(11) NOT NULL,
  `regis_teacher_id` int(11) DEFAULT NULL,
  `FileName` text
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table `tbl_regis_teacher_gallery`
--

INSERT INTO `tbl_regis_teacher_gallery` (`DataID`, `regis_teacher_id`, `FileName`) VALUES
(126, 312, 'file_5b28b6640cd25.png'),
(127, 313, 'file_5b28b67eab1d2.png'),
(129, 311, 'file_5b28b6b832273.png'),
(130, 21, 'file_5b31d38264d07.jpg');

-- --------------------------------------------------------

--
-- Table structure for table `tbl_report_mid`
--

CREATE TABLE `tbl_report_mid` (
  `DataID` int(11) NOT NULL,
  `pp6_mid_ID` int(11) DEFAULT NULL,
  `sub_ID` int(11) DEFAULT NULL,
  `courseID` varchar(250) DEFAULT NULL,
  `name` text,
  `unit` decimal(2,1) DEFAULT NULL,
  `department` varchar(250) DEFAULT NULL,
  `status` int(11) DEFAULT NULL,
  `status_form` int(11) DEFAULT NULL,
  `score_mid` int(11) DEFAULT NULL,
  `score_final` int(11) DEFAULT NULL,
  `score_total` int(11) DEFAULT NULL,
  `score_desirable` float DEFAULT NULL,
  `score_rtw` float DEFAULT NULL,
  `score_attend` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table `tbl_report_mid`
--

INSERT INTO `tbl_report_mid` (`DataID`, `pp6_mid_ID`, `sub_ID`, `courseID`, `name`, `unit`, `department`, `status`, `status_form`, `score_mid`, `score_final`, `score_total`, `score_desirable`, `score_rtw`, `score_attend`) VALUES
(1634, 550, 409, 'ท21101', 'ภาษาไทย1', '1.5', '71', 1, 11, 50, 40, 50, 3, 3, 1),
(1635, 551, 409, 'ท21101', 'ภาษาไทย1', '1.5', '71', 1, 11, 50, 33, 50, 3, 3, 1);

-- --------------------------------------------------------

--
-- Table structure for table `tbl_room_export`
--

CREATE TABLE `tbl_room_export` (
  `DataID` int(11) NOT NULL,
  `registed_courseID` int(11) DEFAULT NULL,
  `room` int(11) DEFAULT NULL,
  `cdate` date DEFAULT NULL,
  `status` int(11) NOT NULL,
  `sended_status` int(11) NOT NULL,
  `user_add` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table `tbl_room_export`
--

INSERT INTO `tbl_room_export` (`DataID`, `registed_courseID`, `room`, `cdate`, `status`, `sended_status`, `user_add`) VALUES
(235, 711, 1, '2018-07-23', 0, 0, 323),
(236, 711, 2, '2018-07-23', 0, 0, 323),
(237, 711, 3, '2018-07-23', 0, 0, 323),
(238, 698, 0, '2018-07-23', 0, 0, 323),
(239, 709, 1, '2018-07-23', 0, 0, 323),
(240, 696, 1, '2018-07-23', 0, 0, 323);

-- --------------------------------------------------------

--
-- Table structure for table `tbl_room_teacher`
--

CREATE TABLE `tbl_room_teacher` (
  `DataID` int(11) NOT NULL,
  `course_teacherID` int(11) DEFAULT NULL,
  `room` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table `tbl_room_teacher`
--

INSERT INTO `tbl_room_teacher` (`DataID`, `course_teacherID`, `room`) VALUES
(172, 215, 1),
(173, NULL, 1),
(175, NULL, 1),
(176, 219, 1),
(177, 220, 1),
(178, 221, 1),
(179, 222, 1),
(180, 225, 1),
(181, 224, 1),
(182, 223, 1),
(183, 226, 1),
(184, 227, 1),
(185, 228, 1),
(186, 231, 1),
(187, 231, 2),
(188, 231, 3),
(197, 234, 1),
(199, 240, 1),
(205, 244, 1),
(206, 248, 1),
(207, 252, 2),
(208, 252, 3),
(209, 254, 1),
(210, 254, 2),
(212, 255, 1);

-- --------------------------------------------------------

--
-- Table structure for table `tbl_rtw_4_score`
--

CREATE TABLE `tbl_rtw_4_score` (
  `DataID` int(11) NOT NULL,
  `course_teachingID` int(11) DEFAULT NULL,
  `stdID` varchar(250) DEFAULT NULL,
  `score` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table `tbl_rtw_4_score`
--

INSERT INTO `tbl_rtw_4_score` (`DataID`, `course_teachingID`, `stdID`, `score`) VALUES
(1, 1, '11141', 3),
(133, 447, '01111', 3),
(134, 447, '01112', 3),
(135, 447, '01117', 3),
(138, 449, '01111', 3),
(139, 449, '01112', 3),
(140, 449, '01117', 3),
(143, 451, '01111', 3),
(144, 451, '01112', 3),
(145, 451, '01117', 3),
(146, 453, '01111', 3),
(147, 454, '01111', 3),
(148, 455, '11141', 3),
(149, 456, '11141', 3),
(150, 458, '11141', 3),
(151, 458, '11144', 3),
(152, 459, '11141', 3),
(153, 459, '11144', 3),
(154, 460, '11141', 3),
(155, 460, '11144', 3),
(156, 1, '11142', 3);

-- --------------------------------------------------------

--
-- Table structure for table `tbl_rtw_5_score`
--

CREATE TABLE `tbl_rtw_5_score` (
  `DataID` int(11) NOT NULL,
  `course_teachingID` int(11) DEFAULT NULL,
  `stdID` varchar(250) DEFAULT NULL,
  `score` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table `tbl_rtw_5_score`
--

INSERT INTO `tbl_rtw_5_score` (`DataID`, `course_teachingID`, `stdID`, `score`) VALUES
(1, 1, '11141', 3),
(133, 447, '01111', 3),
(134, 447, '01112', 3),
(135, 447, '01117', 3),
(138, 449, '01111', 3),
(139, 449, '01112', 3),
(140, 449, '01117', 3),
(143, 451, '01111', 3),
(144, 451, '01112', 3),
(145, 451, '01117', 3),
(146, 453, '01111', 3),
(147, 454, '01111', 3),
(148, 455, '11141', 3),
(149, 456, '11141', 3),
(150, 458, '11141', 3),
(151, 458, '11144', 3),
(152, 459, '11141', 3),
(153, 459, '11144', 3),
(154, 460, '11141', 3),
(155, 460, '11144', 3),
(156, 1, '11142', 3);

-- --------------------------------------------------------

--
-- Table structure for table `tbl_set_attend_day`
--

CREATE TABLE `tbl_set_attend_day` (
  `DataID` int(11) NOT NULL,
  `registed_course_teachingID` int(11) DEFAULT NULL,
  `attend_class_week_listID` int(11) DEFAULT NULL,
  `hr` int(11) NOT NULL,
  `room` varchar(250) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table `tbl_set_attend_day`
--

INSERT INTO `tbl_set_attend_day` (`DataID`, `registed_course_teachingID`, `attend_class_week_listID`, `hr`, `room`) VALUES
(662, 451, 3, 1, '1'),
(663, 452, 4, 1, '1'),
(664, 453, 3, 1, '1'),
(665, 454, 5, 1, '1'),
(666, 455, 2, 1, '1'),
(667, 456, 5, 1, '1'),
(668, 457, 1, 1, '1'),
(669, 458, 2, 1, '1'),
(670, 459, 4, 1, '1'),
(671, 460, 3, 1, '1'),
(672, 1, 4, 1, '1'),
(673, 1, 3, 1, '2'),
(674, 1, 2, 1, '2'),
(678, 1, 1, 1, '3'),
(690, 449, 1, 1, '1'),
(691, 447, 2, 1, '1'),
(692, 482, 2, 1, ''),
(693, 483, 1, 1, '');

-- --------------------------------------------------------

--
-- Table structure for table `tbl_set_count_adttend_class`
--

CREATE TABLE `tbl_set_count_adttend_class` (
  `DataID` int(11) NOT NULL,
  `registed_courseID` int(11) DEFAULT NULL,
  `week_name` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table `tbl_set_count_adttend_class`
--

INSERT INTO `tbl_set_count_adttend_class` (`DataID`, `registed_courseID`, `week_name`) VALUES
(0, 710, 20),
(426, 696, 20),
(427, 697, 20),
(428, 698, 20),
(429, 699, 20),
(430, 700, 20),
(431, 701, 20),
(432, 702, 20),
(433, 703, 20),
(434, 704, 20),
(435, 705, 20),
(436, 706, 20),
(437, 707, 20),
(438, 708, 20),
(439, 709, 20);

-- --------------------------------------------------------

--
-- Table structure for table `tbl_set_term_year`
--

CREATE TABLE `tbl_set_term_year` (
  `DataID` int(11) NOT NULL,
  `term` varchar(250) NOT NULL,
  `year` varchar(250) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table `tbl_set_term_year`
--

INSERT INTO `tbl_set_term_year` (`DataID`, `term`, `year`) VALUES
(1, '2', '2561');

-- --------------------------------------------------------

--
-- Table structure for table `tbl_std_class_room`
--

CREATE TABLE `tbl_std_class_room` (
  `DataID` int(11) NOT NULL,
  `std_ID` varchar(250) DEFAULT NULL,
  `class_level` varchar(250) DEFAULT NULL,
  `room` varchar(250) DEFAULT NULL,
  `year` varchar(250) DEFAULT NULL,
  `status` int(11) DEFAULT '1' COMMENT '1 = active'
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table `tbl_std_class_room`
--

INSERT INTO `tbl_std_class_room` (`DataID`, `std_ID`, `class_level`, `room`, `year`, `status`) VALUES
(1, '991114', 'p1', '1', '2560', 1),
(3, '01115', 'p2', '1', '2561', 1),
(4, '01116', 'p2', '1', '2561', 1),
(5, '1118', 'p3', '1', '2561', 1),
(6, '1119', 'p3', '1', '2561', 1),
(7, '11120', 'p4', '1', '2561', 1),
(8, '11121', 'p4', '1', '2561', 1),
(9, '11122', 'p4', '2', '2561', 1),
(10, '11123', 'p4', '2', '2561', 1),
(11, '11131', 'p5', '1', '2561', 1),
(12, '11134', 'p5', '1', '2561', 1),
(13, '11132', 'p6', '1', '2561', 1),
(14, '11133', 'p6', '1', '2561', 1),
(15, '11141', 'm1', '1', '2561', 1),
(16, '11144', 'm1', '2', '2561', 1),
(17, '11142', 'm1', '1', '2561', 1),
(18, '11143', 'm1', '2', '2561', 1),
(19, '111541', 'm1', '3', '2561', 1),
(20, '111144', 'm3', '1', '2561', 1),
(21, '111142', 'm4', '1', '2561', 1),
(22, '111143', 'm4', '1', '2561', 1),
(23, '211541', 'm5', '1', '2561', 1),
(24, '211144', 'm5', '1', '2561', 1),
(25, '211142', 'm6', '1', '2561', 1),
(26, '211143', 'm6', '1', '2561', 1),
(27, '01111', 'p1', '1', '2561', 0),
(28, '01112', 'p1', '1', '2561', 1),
(29, '01113', 'p1', '2', '2561', 1),
(30, '01117', 'p1', '1', '2561', 1),
(31, '01111', 'p1', '1', '2560', 1),
(32, '11141', 'm1', '1', '2560', 1),
(33, '991115', 'p1', '2', '2561', 1);

-- --------------------------------------------------------

--
-- Table structure for table `tbl_student`
--

CREATE TABLE `tbl_student` (
  `std_ID` varchar(250) NOT NULL,
  `card_ID` varchar(250) NOT NULL,
  `password` varchar(250) NOT NULL,
  `class_level` varchar(250) NOT NULL,
  `room` varchar(250) NOT NULL,
  `name_title` varchar(250) NOT NULL,
  `fname` varchar(250) NOT NULL,
  `lname` varchar(250) NOT NULL,
  `birthday` date NOT NULL,
  `blood_group` varchar(250) NOT NULL,
  `address` mediumtext NOT NULL,
  `parent_name_title` varchar(250) NOT NULL,
  `parent_fname` varchar(250) NOT NULL,
  `parent_lname` varchar(250) NOT NULL,
  `tell` varchar(250) NOT NULL,
  `parent_address` mediumtext NOT NULL,
  `status` int(11) NOT NULL,
  `cdate` date NOT NULL,
  `status_alive` int(11) NOT NULL DEFAULT '1'
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table `tbl_student`
--

INSERT INTO `tbl_student` (`std_ID`, `card_ID`, `password`, `class_level`, `room`, `name_title`, `fname`, `lname`, `birthday`, `blood_group`, `address`, `parent_name_title`, `parent_fname`, `parent_lname`, `tell`, `parent_address`, `status`, `cdate`, `status_alive`) VALUES
('01111', '1234567898765', 'e10adc3949ba59abbe56e057f20f883e', '', '', 'dekchai', 'นักเรียน1', 'นักเรียน1', '2017-01-01', 'A', '', 'nai', '', '', '', '', 1, '2018-07-12', 1),
('01112', '1232345432344', 'e10adc3949ba59abbe56e057f20f883e', '', '', 'dekchai', 'นักเรียน2', 'นักเรียน2', '2018-01-01', 'A', '', 'nai', '', '', '', '', 1, '2018-07-12', 1),
('01113', '2312344454322', 'e10adc3949ba59abbe56e057f20f883e', '', '', 'dekying', 'นักเรียน3', 'นักเรียน3', '2018-01-01', 'A', '', 'nai', '', '', '', '', 1, '2018-07-12', 1),
('01115', '2231234565432', 'e10adc3949ba59abbe56e057f20f883e', '', '', 'dekchai', 'นักเรียน4', 'นักเรียน4', '2018-01-01', 'A', '', 'nai', '', '', '', '', 1, '2018-07-12', 1),
('01116', '1234323454322', 'e10adc3949ba59abbe56e057f20f883e', '', '', 'nai', 'นักเรียน5', 'นักเรียน5', '2018-01-01', 'A', '', 'nai', '', '', '', '', 1, '2018-07-12', 1),
('01117', '1232123456543', 'e10adc3949ba59abbe56e057f20f883e', '', '', 'nangsaw', 'นักเรียน6', 'นักเรียน6', '2018-01-01', 'A', '', 'nai', '', '', '', '', 1, '2018-07-12', 1),
('111142', '1232312324416', '7d8209670a3415eee3f55abc59e87e63', '', '', 'dekchai', 'นักเรียน23', 'นักเรียน23', '1994-07-26', '', '', '', '', '', '', '', 0, '0000-00-00', 1),
('111143', '3322312321893', '7d8209670a3415eee3f55abc59e87e63', '', '', 'dekchai', 'นักเรียน24', 'นักเรียน24', '1994-07-26', '', '', '', '', '', '', '', 0, '0000-00-00', 1),
('111144', '1232312321774', '7d8209670a3415eee3f55abc59e87e63', '', '', 'dekchai', 'นักเรียน22', 'นักเรียน22', '1994-07-26', '', '', '', '', '', '', '', 0, '0000-00-00', 1),
('11120', '1232312321188', '7d8209670a3415eee3f55abc59e87e63', '', '', 'dekchai', 'นักเรียน9', 'นักเรียน9', '1994-07-26', '', '', '', '', '', '', '', 0, '0000-00-00', 1),
('11121', '1232312321899', '7d8209670a3415eee3f55abc59e87e63', '', '', 'dekchai', 'นักเรียน10', 'นักเรียน10', '1994-07-26', '', '', '', '', '', '', '', 0, '0000-00-00', 1),
('11122', '1232312324412', '7d8209670a3415eee3f55abc59e87e63', '', '', 'dekchai', 'นักเรียน11', 'นักเรียน11', '1994-07-26', '', '', '', '', '', '', '', 0, '0000-00-00', 1),
('11123', '3322312321899', '7d8209670a3415eee3f55abc59e87e63', '', '', 'dekchai', 'นักเรียน12', 'นักเรียน12', '1994-07-26', '', '', '', '', '', '', '', 0, '0000-00-00', 1),
('11131', '1232312321115', '7d8209670a3415eee3f55abc59e87e63', '', '', 'dekchai', 'นักเรียน13', 'นักเรียน13', '1994-07-26', '', '', '', '', '', '', '', 0, '0000-00-00', 1),
('11132', '1232312324411', '7d8209670a3415eee3f55abc59e87e63', '', '', 'dekchai', 'นักเรียน15', 'นักเรียน15', '1994-07-26', '', '', '', '', '', '', '', 0, '0000-00-00', 1),
('11133', '3322312321891', '7d8209670a3415eee3f55abc59e87e63', '', '', 'dekchai', 'นักเรียน16', 'นักเรียน16', '1994-07-26', '', '', '', '', '', '', '', 0, '0000-00-00', 1),
('11134', '1232312321897', '7d8209670a3415eee3f55abc59e87e63', '', '', 'dekchai', 'นักเรียน14', 'นักเรียน14', '1994-07-26', '', '', '', '', '', '', '', 0, '0000-00-00', 1),
('11141', '1232312321122', '7d8209670a3415eee3f55abc59e87e63', '', '', 'dekchai', 'นักเรียน17', 'นักเรียน17', '1994-07-26', '', '', '', '', '', '', '', 0, '0000-00-00', 1),
('11142', '1232312324414', '7d8209670a3415eee3f55abc59e87e63', '', '', 'dekchai', 'นักเรียน19', 'นักเรียน19', '1994-07-26', '', '', '', '', '', '', '', 0, '0000-00-00', 1),
('11143', '3322312321892', '7d8209670a3415eee3f55abc59e87e63', '', '', 'dekchai', 'นักเรียน20', 'นักเรียน20', '1994-07-26', '', '', '', '', '', '', '', 0, '0000-00-00', 1),
('11144', '1232312321891', '7d8209670a3415eee3f55abc59e87e63', '', '', 'dekchai', 'นักเรียน18', 'นักเรียน18', '1994-07-26', '', '', '', '', '', '', '', 0, '0000-00-00', 1),
('111541', '1232312321224', '7d8209670a3415eee3f55abc59e87e63', '', '', 'dekchai', 'นักเรียน21', 'นักเรียน21', '1994-07-26', '', '', '', '', '', '', '', 0, '0000-00-00', 1),
('1118', '1232312321123', '7d8209670a3415eee3f55abc59e87e63', '', '', 'nai', 'นักเรียน7', 'นักเรียน7', '1994-07-26', '', '', '', '', '', '', '', 0, '0000-00-00', 1),
('1119', '1232312321127', '7d8209670a3415eee3f55abc59e87e63', '', '', 'nai', 'นักเรียน8', 'นักเรียน8', '1994-07-26', '', '', '', '', '', '', '', 0, '0000-00-00', 1),
('211142', '1232312324418', '7d8209670a3415eee3f55abc59e87e63', '', '', 'dekchai', 'นักเรียน27', 'นักเรียน27', '1994-07-26', '', '', '', '', '', '', '', 0, '0000-00-00', 1),
('211143', '3322312321894', '7d8209670a3415eee3f55abc59e87e63', '', '', 'dekchai', 'นักเรียน28', 'นักเรียน28', '1994-07-26', '', '', '', '', '', '', '', 0, '0000-00-00', 1),
('211144', '1232312321112', '7d8209670a3415eee3f55abc59e87e63', '', '', 'dekchai', 'นักเรียน26', 'นักเรียน26', '1994-07-26', '', '', '', '', '', '', '', 0, '0000-00-00', 1),
('211541', '1232312321889', '7d8209670a3415eee3f55abc59e87e63', '', '', 'dekchai', 'นักเรียน25', 'นักเรียน25', '1994-07-26', '', '', '', '', '', '', '', 0, '0000-00-00', 1),
('991112', '1223432343233', 'e10adc3949ba59abbe56e057f20f883e', '', '', 'dekchai', '991112', '991112', '2018-01-01', 'A', '', 'nai', '', '', '', '', 0, '2018-07-18', 1),
('991114', '2312345456542', 'e10adc3949ba59abbe56e057f20f883e', '', '', 'dekchai', '991114', '991114', '2017-01-01', 'A', '', 'nai', '', '', '', '', 0, '2018-07-18', 1),
('991115', '2345434567654', 'e10adc3949ba59abbe56e057f20f883e', '', '', 'dekchai', '991115', '991115', '2018-01-01', 'A', '', 'nai', '', '', '', '', 0, '2018-07-18', 1);

-- --------------------------------------------------------

--
-- Table structure for table `tbl_sub_pp6`
--

CREATE TABLE `tbl_sub_pp6` (
  `DataID` int(11) NOT NULL,
  `pp6_ID` int(11) DEFAULT NULL,
  `sub_ID` int(11) DEFAULT NULL,
  `courseID` varchar(250) NOT NULL,
  `name` text NOT NULL,
  `unit` decimal(2,1) NOT NULL,
  `department` varchar(250) NOT NULL,
  `status` int(11) NOT NULL,
  `status_form` int(11) NOT NULL,
  `score_mid` int(11) DEFAULT NULL,
  `score_final` int(11) DEFAULT NULL,
  `score_total` int(11) NOT NULL,
  `score_desirable` float DEFAULT NULL,
  `score_rtw` float DEFAULT NULL,
  `score_attend` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table `tbl_sub_pp6`
--

INSERT INTO `tbl_sub_pp6` (`DataID`, `pp6_ID`, `sub_ID`, `courseID`, `name`, `unit`, `department`, `status`, `status_form`, `score_mid`, `score_final`, `score_total`, `score_desirable`, `score_rtw`, `score_attend`) VALUES
(4311, 1745, 430, 'ก45623', 'แนะแนว', '9.9', '', 2, 25, 0, 0, -1, 3, 3, 1),
(4312, 1746, 430, 'ก45623', 'แนะแนว', '9.9', '', 2, 25, 0, 0, -1, 3, 3, -1),
(4313, 1747, 430, 'ก45623', 'แนะแนว', '9.9', '', 2, 25, 0, 0, -1, 0, 0.4, 1),
(4314, 1748, 430, 'ก45623', 'แนะแนว', '9.9', '', 2, 25, 0, 0, -1, 0, 0, 1),
(4315, 1749, 430, 'ก45623', 'แนะแนว', '9.9', '', 2, 25, 0, 0, -1, 0, 0, 1),
(4316, 1750, 416, '2', '2', '0.0', '', 2, 22, 0, 0, -1, 0, 0, 1),
(4317, 1751, 416, '2', '2', '0.0', '', 2, 22, 0, 0, -1, 0, 0, 1),
(4318, 1752, 416, '2', '2', '0.0', '', 2, 22, 0, 0, -1, 0, 0, 1),
(4319, 1745, 418, 'ค11111', 'คณิตศาสตร์ พื้นฐาน', '1.0', '2', 1, 11, 50, 50, 100, 3, 3, 1);

-- --------------------------------------------------------

--
-- Table structure for table `tbl_think_score`
--

CREATE TABLE `tbl_think_score` (
  `DataID` int(11) NOT NULL,
  `course_teachingID` int(11) DEFAULT NULL,
  `stdID` varchar(250) DEFAULT NULL,
  `score` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table `tbl_think_score`
--

INSERT INTO `tbl_think_score` (`DataID`, `course_teachingID`, `stdID`, `score`) VALUES
(1, 1, '11141', 3),
(133, 447, '01111', 3),
(134, 447, '01112', 3),
(135, 447, '01117', 3),
(138, 449, '01111', 3),
(139, 449, '01112', 3),
(140, 449, '01117', 3),
(143, 451, '01111', 3),
(144, 451, '01112', 3),
(145, 451, '01117', 3),
(146, 453, '01111', 3),
(147, 454, '01111', 3),
(148, 455, '11141', 3),
(149, 456, '11141', 3),
(150, 458, '11141', 3),
(151, 458, '11144', 3),
(152, 459, '11141', 3),
(153, 459, '11144', 3),
(154, 460, '11141', 3),
(155, 460, '11144', 3),
(156, 1, '11142', 3);

-- --------------------------------------------------------

--
-- Table structure for table `tbl_write_score`
--

CREATE TABLE `tbl_write_score` (
  `DataID` int(11) NOT NULL,
  `course_teachingID` int(11) DEFAULT NULL,
  `stdID` varchar(250) DEFAULT NULL,
  `score` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table `tbl_write_score`
--

INSERT INTO `tbl_write_score` (`DataID`, `course_teachingID`, `stdID`, `score`) VALUES
(1, 1, '11141', 3),
(133, 447, '01111', 3),
(134, 447, '01112', 3),
(135, 447, '01117', 3),
(138, 449, '01111', 3),
(139, 449, '01112', 3),
(140, 449, '01117', 3),
(143, 451, '01111', 3),
(144, 451, '01112', 3),
(145, 451, '01117', 3),
(146, 453, '01111', 3),
(147, 454, '01111', 3),
(148, 455, '11141', 3),
(149, 456, '11141', 3),
(150, 458, '11141', 3),
(151, 458, '11144', 3),
(152, 459, '11141', 3),
(153, 459, '11144', 3),
(154, 460, '11141', 3),
(155, 460, '11144', 3),
(156, 1, '11142', 3);

-- --------------------------------------------------------

--
-- Table structure for table `wait_data_objective`
--

CREATE TABLE `wait_data_objective` (
  `no_order` int(11) NOT NULL,
  `detail` text NOT NULL,
  `user_do` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table `wait_data_objective`
--

INSERT INTO `wait_data_objective` (`no_order`, `detail`, `user_do`) VALUES
(10, '10', 21),
(20, '20', 21);

--
-- Indexes for dumped tables
--

--
-- Indexes for table `ath_role_reletion_tasks`
--
ALTER TABLE `ath_role_reletion_tasks`
  ADD PRIMARY KEY (`rel_id`);

--
-- Indexes for table `ath_tasks`
--
ALTER TABLE `ath_tasks`
  ADD PRIMARY KEY (`task_id`);

--
-- Indexes for table `ath_users`
--
ALTER TABLE `ath_users`
  ADD PRIMARY KEY (`user_id`);

--
-- Indexes for table `tbl_add_delete_course`
--
ALTER TABLE `tbl_add_delete_course`
  ADD PRIMARY KEY (`DataID`),
  ADD KEY `tbl_add_delete_course_fk1` (`user_add`);

--
-- Indexes for table `tbl_attend_class`
--
ALTER TABLE `tbl_attend_class`
  ADD PRIMARY KEY (`DataID`),
  ADD KEY `tbl_attend_class_fk1` (`course_teaching_stdID`);

--
-- Indexes for table `tbl_attend_class_std`
--
ALTER TABLE `tbl_attend_class_std`
  ADD PRIMARY KEY (`DataID`),
  ADD KEY `tbl_attend_class_std_fk1` (`course_teaching_std_id`),
  ADD KEY `tbl_attend_class_std_fk2` (`set_attend_day_id`);

--
-- Indexes for table `tbl_attend_class_week_list`
--
ALTER TABLE `tbl_attend_class_week_list`
  ADD PRIMARY KEY (`DataID`);

--
-- Indexes for table `tbl_course_teacher`
--
ALTER TABLE `tbl_course_teacher`
  ADD PRIMARY KEY (`DataID`),
  ADD KEY `tbl_course_teacher_fk_1` (`teacher_id`),
  ADD KEY `tbl_course_teacher_fk_2` (`regis_course_id`);

--
-- Indexes for table `tbl_course_teaching_std`
--
ALTER TABLE `tbl_course_teaching_std`
  ADD PRIMARY KEY (`DataID`),
  ADD KEY `tbl_course_teaching_std_fk1` (`registed_courseID`),
  ADD KEY `tbl_course_teaching_std_fk2` (`stdID`);

--
-- Indexes for table `tbl_desirable_1`
--
ALTER TABLE `tbl_desirable_1`
  ADD PRIMARY KEY (`DataID`),
  ADD KEY `tbl_desirable_1_fk1` (`course_teachingID`),
  ADD KEY `tbl_desirable_1_fk2` (`stdID`);

--
-- Indexes for table `tbl_desirable_2`
--
ALTER TABLE `tbl_desirable_2`
  ADD PRIMARY KEY (`DataID`),
  ADD KEY `tbl_desirable_2_fk1` (`course_teachingID`),
  ADD KEY `tbl_desirable_2_fk2` (`stdID`);

--
-- Indexes for table `tbl_desirable_3`
--
ALTER TABLE `tbl_desirable_3`
  ADD PRIMARY KEY (`DataID`),
  ADD KEY `tbl_desirable_3_fk1` (`course_teachingID`),
  ADD KEY `tbl_desirable_3_fk2` (`stdID`);

--
-- Indexes for table `tbl_desirable_4`
--
ALTER TABLE `tbl_desirable_4`
  ADD PRIMARY KEY (`DataID`),
  ADD KEY `tbl_desirable_4_fk1` (`course_teachingID`),
  ADD KEY `tbl_desirable_4_fk2` (`stdID`);

--
-- Indexes for table `tbl_desirable_5`
--
ALTER TABLE `tbl_desirable_5`
  ADD PRIMARY KEY (`DataID`),
  ADD KEY `tbl_desirable_5_fk1` (`course_teachingID`),
  ADD KEY `tbl_desirable_5_fk2` (`stdID`);

--
-- Indexes for table `tbl_desirable_6`
--
ALTER TABLE `tbl_desirable_6`
  ADD PRIMARY KEY (`DataID`),
  ADD KEY `tbl_desirable_6_fk1` (`course_teachingID`),
  ADD KEY `tbl_desirable_6_fk2` (`stdID`);

--
-- Indexes for table `tbl_desirable_7`
--
ALTER TABLE `tbl_desirable_7`
  ADD PRIMARY KEY (`DataID`),
  ADD KEY `tbl_desirable_7_fk1` (`course_teachingID`),
  ADD KEY `tbl_desirable_7_fk2` (`stdID`);

--
-- Indexes for table `tbl_desirable_8`
--
ALTER TABLE `tbl_desirable_8`
  ADD PRIMARY KEY (`DataID`),
  ADD KEY `tbl_desirable_8_fk1` (`course_teachingID`),
  ADD KEY `tbl_desirable_8_fk2` (`stdID`);

--
-- Indexes for table `tbl_exam_final_object`
--
ALTER TABLE `tbl_exam_final_object`
  ADD PRIMARY KEY (`DataID`),
  ADD KEY `exam_final_object_fk1` (`courseID`),
  ADD KEY `exam_final_object_fk2` (`objective_conclude`);

--
-- Indexes for table `tbl_exam_mid_object`
--
ALTER TABLE `tbl_exam_mid_object`
  ADD PRIMARY KEY (`DataID`),
  ADD KEY `exam_mid_object_fk1` (`courseID`),
  ADD KEY `exam_mid_object_fk2` (`objective_conclude`);

--
-- Indexes for table `tbl_final_exam_score`
--
ALTER TABLE `tbl_final_exam_score`
  ADD PRIMARY KEY (`DataID`),
  ADD KEY `final_exam_score_fk1` (`course_teachingID`),
  ADD KEY `final_exam_score_fk2` (`stdID`);

--
-- Indexes for table `tbl_log`
--
ALTER TABLE `tbl_log`
  ADD PRIMARY KEY (`log_id`);

--
-- Indexes for table `tbl_log_upclass`
--
ALTER TABLE `tbl_log_upclass`
  ADD PRIMARY KEY (`DataID`);

--
-- Indexes for table `tbl_mid_exam_score`
--
ALTER TABLE `tbl_mid_exam_score`
  ADD PRIMARY KEY (`DataID`),
  ADD KEY `mid_exam_score_fk1` (`course_teachingID`),
  ADD KEY `mid_exam_score_fk2` (`stdID`);

--
-- Indexes for table `tbl_news`
--
ALTER TABLE `tbl_news`
  ADD PRIMARY KEY (`DataID`);

--
-- Indexes for table `tbl_news_gallery`
--
ALTER TABLE `tbl_news_gallery`
  ADD PRIMARY KEY (`DataID`),
  ADD KEY `tbl_news_gallery_fk1` (`newsID`);

--
-- Indexes for table `tbl_news_gallery_sub`
--
ALTER TABLE `tbl_news_gallery_sub`
  ADD PRIMARY KEY (`DataID`),
  ADD KEY `tbl_news_gallery_subpk_fk1` (`newsID`);

--
-- Indexes for table `tbl_objective_conclude`
--
ALTER TABLE `tbl_objective_conclude`
  ADD PRIMARY KEY (`DataID`),
  ADD KEY `tbl_objective_conclude_fk1` (`courseID`);

--
-- Indexes for table `tbl_objective_score_std`
--
ALTER TABLE `tbl_objective_score_std`
  ADD PRIMARY KEY (`DataID`),
  ADD KEY `tbl_objective_score_std_fk1` (`objectiveID`),
  ADD KEY `tbl_objective_score_std_fk2` (`staID`),
  ADD KEY `tbl_objective_score_std_fk3` (`registed_courseID`);

--
-- Indexes for table `tbl_pp6`
--
ALTER TABLE `tbl_pp6`
  ADD PRIMARY KEY (`DataID`);

--
-- Indexes for table `tbl_pp6_mid`
--
ALTER TABLE `tbl_pp6_mid`
  ADD PRIMARY KEY (`DataID`);

--
-- Indexes for table `tbl_proportion`
--
ALTER TABLE `tbl_proportion`
  ADD PRIMARY KEY (`DataID`),
  ADD KEY `tbl_proportion_fk1` (`courseID`);

--
-- Indexes for table `tbl_read_score`
--
ALTER TABLE `tbl_read_score`
  ADD PRIMARY KEY (`DataID`),
  ADD KEY `tbl_read_score_fk1` (`course_teachingID`),
  ADD KEY `tbl_read_score_fk2` (`stdID`);

--
-- Indexes for table `tbl_registed_course`
--
ALTER TABLE `tbl_registed_course`
  ADD PRIMARY KEY (`DataID`),
  ADD KEY `tbl_registed_course_fk1` (`courseID`);

--
-- Indexes for table `tbl_registed_course_teaching`
--
ALTER TABLE `tbl_registed_course_teaching`
  ADD PRIMARY KEY (`DataID`),
  ADD KEY `tbl_registed_course_teaching_fk1` (`registed_courseID`);

--
-- Indexes for table `tbl_regis_teacher`
--
ALTER TABLE `tbl_regis_teacher`
  ADD PRIMARY KEY (`DataID`);

--
-- Indexes for table `tbl_regis_teacher_gallery`
--
ALTER TABLE `tbl_regis_teacher_gallery`
  ADD PRIMARY KEY (`DataID`),
  ADD KEY `regis_teacher_gal_fk1` (`regis_teacher_id`);

--
-- Indexes for table `tbl_report_mid`
--
ALTER TABLE `tbl_report_mid`
  ADD PRIMARY KEY (`DataID`),
  ADD KEY `tbl_report_mid_1` (`pp6_mid_ID`);

--
-- Indexes for table `tbl_room_export`
--
ALTER TABLE `tbl_room_export`
  ADD PRIMARY KEY (`DataID`),
  ADD KEY `tbl_room_exportfk1` (`registed_courseID`);

--
-- Indexes for table `tbl_room_teacher`
--
ALTER TABLE `tbl_room_teacher`
  ADD PRIMARY KEY (`DataID`),
  ADD KEY `tbl_room_teacher_fk1` (`course_teacherID`);

--
-- Indexes for table `tbl_rtw_4_score`
--
ALTER TABLE `tbl_rtw_4_score`
  ADD PRIMARY KEY (`DataID`),
  ADD KEY `rtw_4_score_fk1` (`course_teachingID`),
  ADD KEY `rtw_4_score_fk2` (`stdID`);

--
-- Indexes for table `tbl_rtw_5_score`
--
ALTER TABLE `tbl_rtw_5_score`
  ADD PRIMARY KEY (`DataID`),
  ADD KEY `rtw_5_score_fk1` (`course_teachingID`),
  ADD KEY `rtw_5_score_fk2` (`stdID`);

--
-- Indexes for table `tbl_set_attend_day`
--
ALTER TABLE `tbl_set_attend_day`
  ADD PRIMARY KEY (`DataID`),
  ADD KEY `tbl_set_attend_day_fk1` (`registed_course_teachingID`),
  ADD KEY `tbl_set_attend_day_fk2` (`attend_class_week_listID`);

--
-- Indexes for table `tbl_set_count_adttend_class`
--
ALTER TABLE `tbl_set_count_adttend_class`
  ADD PRIMARY KEY (`DataID`),
  ADD KEY `tbl_set_count_adttend_class_fk1` (`registed_courseID`);

--
-- Indexes for table `tbl_set_term_year`
--
ALTER TABLE `tbl_set_term_year`
  ADD PRIMARY KEY (`DataID`);

--
-- Indexes for table `tbl_std_class_room`
--
ALTER TABLE `tbl_std_class_room`
  ADD PRIMARY KEY (`DataID`),
  ADD KEY `tbl_std_class_room_fk1` (`std_ID`);

--
-- Indexes for table `tbl_student`
--
ALTER TABLE `tbl_student`
  ADD PRIMARY KEY (`std_ID`);

--
-- Indexes for table `tbl_sub_pp6`
--
ALTER TABLE `tbl_sub_pp6`
  ADD PRIMARY KEY (`DataID`),
  ADD KEY `tbl_sub_pp6_fk1` (`pp6_ID`);

--
-- Indexes for table `tbl_think_score`
--
ALTER TABLE `tbl_think_score`
  ADD PRIMARY KEY (`DataID`),
  ADD KEY `tbl_think_score_fk1` (`course_teachingID`),
  ADD KEY `tbl_think_score_fk2` (`stdID`);

--
-- Indexes for table `tbl_write_score`
--
ALTER TABLE `tbl_write_score`
  ADD PRIMARY KEY (`DataID`),
  ADD KEY `tbl_write_score_fk1` (`course_teachingID`),
  ADD KEY `tbl_write_score_fk2` (`stdID`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `ath_role_reletion_tasks`
--
ALTER TABLE `ath_role_reletion_tasks`
  MODIFY `rel_id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=30;
--
-- AUTO_INCREMENT for table `ath_tasks`
--
ALTER TABLE `ath_tasks`
  MODIFY `task_id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;
--
-- AUTO_INCREMENT for table `ath_users`
--
ALTER TABLE `ath_users`
  MODIFY `user_id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8;
--
-- AUTO_INCREMENT for table `tbl_add_delete_course`
--
ALTER TABLE `tbl_add_delete_course`
  MODIFY `DataID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=431;
--
-- AUTO_INCREMENT for table `tbl_attend_class`
--
ALTER TABLE `tbl_attend_class`
  MODIFY `DataID` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `tbl_attend_class_std`
--
ALTER TABLE `tbl_attend_class_std`
  MODIFY `DataID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8;
--
-- AUTO_INCREMENT for table `tbl_course_teacher`
--
ALTER TABLE `tbl_course_teacher`
  MODIFY `DataID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=256;
--
-- AUTO_INCREMENT for table `tbl_course_teaching_std`
--
ALTER TABLE `tbl_course_teaching_std`
  MODIFY `DataID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=17928;
--
-- AUTO_INCREMENT for table `tbl_desirable_1`
--
ALTER TABLE `tbl_desirable_1`
  MODIFY `DataID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=159;
--
-- AUTO_INCREMENT for table `tbl_desirable_2`
--
ALTER TABLE `tbl_desirable_2`
  MODIFY `DataID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=159;
--
-- AUTO_INCREMENT for table `tbl_desirable_3`
--
ALTER TABLE `tbl_desirable_3`
  MODIFY `DataID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=159;
--
-- AUTO_INCREMENT for table `tbl_desirable_4`
--
ALTER TABLE `tbl_desirable_4`
  MODIFY `DataID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=159;
--
-- AUTO_INCREMENT for table `tbl_desirable_5`
--
ALTER TABLE `tbl_desirable_5`
  MODIFY `DataID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=159;
--
-- AUTO_INCREMENT for table `tbl_desirable_6`
--
ALTER TABLE `tbl_desirable_6`
  MODIFY `DataID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=159;
--
-- AUTO_INCREMENT for table `tbl_desirable_7`
--
ALTER TABLE `tbl_desirable_7`
  MODIFY `DataID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=159;
--
-- AUTO_INCREMENT for table `tbl_desirable_8`
--
ALTER TABLE `tbl_desirable_8`
  MODIFY `DataID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=159;
--
-- AUTO_INCREMENT for table `tbl_exam_final_object`
--
ALTER TABLE `tbl_exam_final_object`
  MODIFY `DataID` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `tbl_exam_mid_object`
--
ALTER TABLE `tbl_exam_mid_object`
  MODIFY `DataID` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `tbl_final_exam_score`
--
ALTER TABLE `tbl_final_exam_score`
  MODIFY `DataID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=258;
--
-- AUTO_INCREMENT for table `tbl_log`
--
ALTER TABLE `tbl_log`
  MODIFY `log_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=715;
--
-- AUTO_INCREMENT for table `tbl_log_upclass`
--
ALTER TABLE `tbl_log_upclass`
  MODIFY `DataID` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT for table `tbl_mid_exam_score`
--
ALTER TABLE `tbl_mid_exam_score`
  MODIFY `DataID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=258;
--
-- AUTO_INCREMENT for table `tbl_news`
--
ALTER TABLE `tbl_news`
  MODIFY `DataID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=52;
--
-- AUTO_INCREMENT for table `tbl_news_gallery`
--
ALTER TABLE `tbl_news_gallery`
  MODIFY `DataID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=18;
--
-- AUTO_INCREMENT for table `tbl_news_gallery_sub`
--
ALTER TABLE `tbl_news_gallery_sub`
  MODIFY `DataID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=43;
--
-- AUTO_INCREMENT for table `tbl_objective_conclude`
--
ALTER TABLE `tbl_objective_conclude`
  MODIFY `DataID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=49;
--
-- AUTO_INCREMENT for table `tbl_objective_score_std`
--
ALTER TABLE `tbl_objective_score_std`
  MODIFY `DataID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=515;
--
-- AUTO_INCREMENT for table `tbl_pp6`
--
ALTER TABLE `tbl_pp6`
  MODIFY `DataID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=1753;
--
-- AUTO_INCREMENT for table `tbl_pp6_mid`
--
ALTER TABLE `tbl_pp6_mid`
  MODIFY `DataID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=552;
--
-- AUTO_INCREMENT for table `tbl_proportion`
--
ALTER TABLE `tbl_proportion`
  MODIFY `DataID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=1779;
--
-- AUTO_INCREMENT for table `tbl_read_score`
--
ALTER TABLE `tbl_read_score`
  MODIFY `DataID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=159;
--
-- AUTO_INCREMENT for table `tbl_registed_course`
--
ALTER TABLE `tbl_registed_course`
  MODIFY `DataID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=712;
--
-- AUTO_INCREMENT for table `tbl_registed_course_teaching`
--
ALTER TABLE `tbl_registed_course_teaching`
  MODIFY `DataID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=484;
--
-- AUTO_INCREMENT for table `tbl_regis_teacher`
--
ALTER TABLE `tbl_regis_teacher`
  MODIFY `DataID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=328;
--
-- AUTO_INCREMENT for table `tbl_report_mid`
--
ALTER TABLE `tbl_report_mid`
  MODIFY `DataID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=1636;
--
-- AUTO_INCREMENT for table `tbl_room_export`
--
ALTER TABLE `tbl_room_export`
  MODIFY `DataID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=241;
--
-- AUTO_INCREMENT for table `tbl_room_teacher`
--
ALTER TABLE `tbl_room_teacher`
  MODIFY `DataID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=213;
--
-- AUTO_INCREMENT for table `tbl_rtw_4_score`
--
ALTER TABLE `tbl_rtw_4_score`
  MODIFY `DataID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=157;
--
-- AUTO_INCREMENT for table `tbl_rtw_5_score`
--
ALTER TABLE `tbl_rtw_5_score`
  MODIFY `DataID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=157;
--
-- AUTO_INCREMENT for table `tbl_set_attend_day`
--
ALTER TABLE `tbl_set_attend_day`
  MODIFY `DataID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=696;
--
-- AUTO_INCREMENT for table `tbl_std_class_room`
--
ALTER TABLE `tbl_std_class_room`
  MODIFY `DataID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=34;
--
-- AUTO_INCREMENT for table `tbl_sub_pp6`
--
ALTER TABLE `tbl_sub_pp6`
  MODIFY `DataID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4320;
--
-- AUTO_INCREMENT for table `tbl_think_score`
--
ALTER TABLE `tbl_think_score`
  MODIFY `DataID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=157;
--
-- AUTO_INCREMENT for table `tbl_write_score`
--
ALTER TABLE `tbl_write_score`
  MODIFY `DataID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=157;COMMIT;

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
<file_sep>/modules/authen_user/index.php
<?php
    $create_user_ath = $role->ath_user_reletion_tasks('create_user_ath',$user_role_id); //สามารถแก้ไข ข้อมูลการสั่งซื้อได้
    $edit_user_ath = $role->ath_user_reletion_tasks('edit_user_ath',$user_role_id); //สามารถแก้ไข ข้อมูลการสั่งซื้อได้
    $del_user_ath = $role->ath_user_reletion_tasks('del_user_ath',$user_role_id); //สามารถแก้ไข ข้อมูลการสั่งซื้อได้
   
?>
<!-- START CONTAINER FLUID -->
<div class="container-fluid container-fixed-lg m-t-20">
  <div class="row">
    <div class="col-md-12">
      <!-- START PANEL -->
      <form id="frm_search">
        <div class="panel panel-default">
          <div class="panel-heading">
            <div class="panel-title">Authentication Search</div>
          </div>
          <div class="panel-body">
              <div class="row">
                <div class="col-sm-6">
                  <div class="form-group form-group-default ">
                    <label>USER Name</label>
                    <input name="data_name" type="text" class="form-control" placeholder="">
                  </div>
                </div>
                
                <div class="col-sm-4">
                  <div class="form-group form-group-default form-group-default-select2 ">
                    <label class="">STATUS</label>
                    <select class="full-width" name="data_status"  data-placeholder="Select Status" data-init-plugin="select2">
                      <option value="">All status</option>
                      <option value="1">Published </option>
                      <option value="0">Save Draft </option>
                    </select>
                  </div>              
                </div>

                <div class="col-sm-2 text-right m-t-10">
                  <a href="javascript:;" id="btn__search" class="btn btn-complete btn-cons"> <i class="pg-search p-r-5"></i> Search</a>
                  <!-- <a href="javascript:;" id="btn__insert" class="btn btn-success btn-cons"><i class="fa fa-plus p-r-5"></i> CREATE BRAND</a> -->
                </div>
              </div>

          </div>
        </div>
      </form>
      <!-- END PANEL -->
    </div>
  </div>
</div>
<!-- END CONTAINER FLUID -->

<!-- START CONTAINER FLUID -->
<div class="container-fluid container-fixed-lg">
  <div class="row">
    <div class="col-md-12">
      <!-- START PANEL -->
      <div class="panel panel-default">
        <div class="panel-heading">
          <div class="col-md-6"><div class="panel-title">USER Authentication LIST</div></div>
          <div class="col-md-6 text-right">

            <div class="btn-group">
              <?php if($create_user_ath){ ?><button id="btn__insert" type="button" class="btn btn-success"><i class="fa fa-plus"></i></button><?php } ?>
              <?php if($del_user_ath){ ?><button id="btn__remove" type="button" class="btn btn-danger"><i class="fa fa-trash-o"></i></button><?php } ?>
            </div>

          </div>
        </div>
        <div class="panel-body">
          <div id="tb_data_list" class="table-responsive">
            <table class="table table-hover table-condensed " id="detailedTable">
              <thead>
                <tr>
                  <th style="width:7%" >
                    <div class="checkbox check-success" style="padding-left:2px !important;">
                      <input type="checkbox" id="checkbox_all">
                      <label for="checkbox_all">&nbsp;</label>
                    </div>
                  </th>
                  <th style="">USER NAME</th>
                  <th style="">ROLES</th>
                  <th style="width:15%">STATUS</th>
                </tr>
              </thead>
              <tbody>
                
              </tbody>
            </table>

            <div class="col-md-6"></div>

            <div id="data_pagination" class="col-md-6 text-right m-t-0" >
              <ul  class="pagination m-t-0">
                <!-- <li><a href="#">&laquo;</a></li>
                <li class="active"><a href="#">1</a></li>
                <li class="disabled"><a href="#">2</a></li>
                <li><a href="#">3</a></li>
                <li><a href="#">4</a></li>
                <li><a href="#">5</a></li>
                <li><a href="#">&raquo;</a></li> -->
              </ul>  
            </div> 

          </div>
        </div>
      </div>
      <!-- END PANEL -->
    </div>
  </div>
</div>  
<!-- END CONTAINER FLUID -->


<!-- Modal -->
  <div class="modal fade slide-up disable-scroll" id="modal_msg" tabindex="-1" role="dialog" aria-hidden="false">
    <div class="modal-dialog modal-sm">
      <div class="modal-content-wrapper">
        <div class="modal-content">
          <div class="modal-body text-center m-t-20">
            <div id="popup_msg"></div>
            <button type="button" class="btn btn-primary btn-cons" data-dismiss="modal">Continue</button>
          </div>
        </div>
      </div>
      <!-- /.modal-content -->
    </div>
  </div>
  <!-- /.modal-dialog -->

<!-- Modal -->
  <div class="modal fade slide-up disable-scroll" id="modal_cancel" tabindex="-1" role="dialog" aria-hidden="false">
    <div class="modal-dialog modal-me">
      <div class="modal-content-wrapper">
        <div class="modal-content">
          <div class="modal-body text-center m-t-20">
            <h4 class="no-margin p-b-10">Are you sure you want to delete?</h4>
            <button type="button" class="btn btn-cons" data-dismiss="modal">Cancel</button>
            <button type="button" class="btn btn-danger" id="btn__conf_remove" >Delete</button>
          </div>
        </div>
      </div>
      <!-- /.modal-content -->
    </div>
  </div>
  <!-- /.modal-dialog -->
<file_sep>/src/lang.php
<?php
    session_start();             
    if (isset($_GET['ss_lang']) && $_GET['ss_lang']=='en' || $_GET['ss_lang']=='th') {
        $_SESSION['ss_lang']=$_GET['ss_lang'];              
    }    
                                     
?><file_sep>/includes/left-tab.php
<?php
  $op=$_GET['op'];
?>
<div class="col-sm-3 logo-tab" >   
  <div class="row" >      
    <nav class="navbar-default">
      <div class="btn-mobile">
        <button type="button" class="navbar-toggle" onclick="addTopMenu()">
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span> 
        </button>
      </div>    
      <div class="col-md-3 col-sm-3 col-xs-3">
        <img class="logo-nav" src="assets/images/logo_bg_white.png" >
      </div>
      <div class="col-md-9 col-sm-9 col-xs-7">
        <h4 class="title-text">ระบบวัดและประเมินผล</h4>
        <h5 class="title-sub-text"> โรงเรียนเทศบาลวัดสระทอง</h5>
      </div>
    </nav>           
  </div>        
  <div class="row">
    <div class="left-menu">
      <ul class="nav nav-pills nav-stacked left-text-set" >
        <?php
          if (isset($_SESSION['ss_status_std']) && $_SESSION['ss_status_std']==1) {
        ?>
         <li role="presentation" class="active-menu"><a href="index.php?op=chk_grade-index"><img class="img-icon-left" src="assets/images/03.png">ผลการศึกษา</a></li>
         <?php }else{ ?>
        <?php if($_SESSION['ss_status']==1){ ?>
        <li role="presentation" class="<?php if(!isset($op)){echo "active-menu";} ?>"><a href="index.php"><img class="img-icon-left" src="assets/images/01.png">หน้าแรก</a></li>
        <li role="presentation" class="<?php if($op=='profile-index' || $op=='profile-edit'){echo "active-menu";} ?>"><a href="index.php?op=profile-index"><img class="img-icon-left" src="assets/images/02.png">ข้อมูลส่วนตัว</a></li>
       
        <li role="presentation" class="<?php if($op=='summary-index'){echo "active-menu";} ?>"><a href="index.php?op=summary-index"><img class="img-icon-left" src="assets/images/03.png">แก้ไขผลการเรียน</a></li>
        <li role="presentation" class="<?php if($op=='print-index'){echo "active-menu";} ?>"><a href="index.php?op=print-index"><img class="img-icon-left" src="assets/images/04.png">พิมพ์ใบ ปพ.5</a></li>
        <li role="presentation"><a target="_blank" href="file_managers/manual/manual_teacher.pdf"><img class="img-icon-left" src="assets/images/05.png">ดาวน์โหลดคู่มือ</a></li>
      <?php }elseif($_SESSION['ss_status']==2){ ?>
        <li role="presentation" class="<?php if(!isset($op)){echo "active-menu";} ?>"><a href="index.php"><img class="img-icon-left" src="assets/images/01.png">หน้าแรก</a></li>
        <li role="presentation" class="<?php if($op=='profile-index' || $op=='profile-edit'){echo "active-menu";} ?>"><a href="index.php?op=profile-index"><img class="img-icon-left" src="assets/images/02.png">ข้อมูลส่วนตัว</a></li>
        <li role="presentation" class="<?php if($op=='summary-index'){echo "active-menu";} ?>"><a href="index.php?op=summary-index"><img class="img-icon-left" src="assets/images/03.png">แก้ไขผลการเรียน</a></li>
        <li role="presentation" class="<?php if($op=='report_std_personal-index'){echo "active-menu";} ?>"><a href="index.php?op=report_std_personal-index"><img class="img-icon-left" src="assets/images/pp6.png">พิมพ์ใบ ปพ.6</a></li>
        <li role="presentation"><a target="_blank" href="file_managers/manual/admin_eva.pdf"><img class="img-icon-left" src="assets/images/05.png">ดาวน์โหลดคู่มือ</a></li>
      <?php }elseif($_SESSION['ss_status']==3){ ?>
        <li role="presentation" class="<?php if(!isset($op)){echo "active-menu";} ?>"><a href="index.php"><img class="img-icon-left" src="assets/images/01.png">หน้าแรก</a></li>
        <li role="presentation" class="<?php if($op=='profile-index' || $op=='profile-edit'){echo "active-menu";} ?>"><a href="index.php?op=profile-index"><img class="img-icon-left" src="assets/images/02.png">ข้อมูลส่วนตัว</a></li>
       
        <li role="presentation"><a target="_blank" href="file_managers/manual/admin_news.pdf"><img class="img-icon-left" src="assets/images/05.png">ดาวน์โหลดคู่มือ</a></li>
     <?php }elseif($_SESSION['ss_status']==4){ ?>
        
        <li role="presentation" class="<?php if(!isset($op)){echo "active-menu";} ?>"><a href="index.php"><img class="img-icon-left" src="assets/images/01.png">หน้าแรก</a></li>
        <li role="presentation" class="<?php if($op=='profile-index' || $op=='profile-edit'){echo "active-menu";} ?>"><a href="index.php?op=profile-index"><img class="img-icon-left" src="assets/images/02.png">ข้อมูลส่วนตัว</a></li>
       <li role="presentation" class="<?php if($op=='report_std_personal-index'){echo "active-menu";} ?>"><a href="index.php?op=report_std_personal-index"><img class="img-icon-left" src="assets/images/pp6.png">พิมพ์ใบ ปพ.6</a></li>
        <li role="presentation"><a target="_blank" href="file_managers/manual/admin_grade_level.pdf"><img class="img-icon-left" src="assets/images/05.png">ดาวน์โหลดคู่มือ</a></li>
      <?php } ?>
        <?php } ?>

      </ul>
      <a href="modules/logout/process.php">
      <div class="logout-box">
              <div class="logout-first-box">
                <img class="img-power" src="assets/images/power.png">
              </div>
              <div class="logout-sec-box">
                <p>ออกจากระบบ</p>
              </div>
          </div>  
        </a>         
    </div>
  </div>
  </div><file_sep>/modules/chk_grade/index.js
var opPage = 'chk_grade';
$(document).ready(function() {
	get_grade();
}); 


function get_grade() {
	var coures_id_list_val =$("#coures_id_list").val();
	var formData = new Array();
	formData.push({ "name": "acc_action", "value": "get_grade" });
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {

		$("#menu_year_list").html(data.menu_year_list);
		$("#table_place").html(data.table_list);

		$("#std_ID").html(data.std_ID);
		$("#full_name").html(data.full_name);
		$("#class_level").html(data.class_level);
		$("#room").html(data.room);
	}); 
}<file_sep>/modules/conclusion/class_modules/learing_resualt_mid.php
<?php 
class ClassData extends Databases {
	
	public function get_mid_head($class_level,$room,$year){
		$this->sql ="SELECT DISTINCT(sub_ID),courseID,department
						FROM tbl_report_mid
						WHERE pp6_mid_ID in(
							SELECT DataID
							FROM tbl_pp6_mid
							WHERE class_level='$class_level'
							AND room='$room'
							AND term='1,2'
							AND year='$year'

						)
						ORDER BY sub_ID ASC

							";
		$this->select();
		$this->setRows();
		foreach($this->rows as $key => $value) {
			$courseID=  $value['courseID'];
			$department_data=$value['department'];
			$department=$this->get_department($department_data);
			$data_response['head_list'].='
					<th  style="height: 70px;line-height: 1;width: 1%;text-align: center;">
		                <div style="transform: rotate(-90deg);white-space: nowrap;">
		                  '.$department.'
		                </div>
		             </th>
			';
			$data_response['sum_100_list'].='
				<th style="text-align: center;">100</th>
			';
		}
		$data_response['head_list'].='
					<th  style="height: 70px;line-height: 1;width: 1%;text-align: center;">
		                <div style="transform: rotate(-90deg);white-space: nowrap;">
		                  คะแนนรวม
		                </div>
		              </th>
		              <th  style="height: 70px;line-height: 1;width: 1%;text-align: center;">
		                <div style="transform: rotate(-90deg);white-space: nowrap;">
		                  ร้อยละ
		                </div>
		              </th>
		              <th  style="height: 70px;line-height: 1;width: 1%;text-align: center;">
		                <div style="transform: rotate(-90deg);white-space: nowrap;">
		                  อันดับที่
		                </div>
		              </th>
		';
		return $data_response;
	}
	public function get_course_list($pp6_mid_id,$i,$year_data,$room,$class_level_data,$std_ID){
		$this->sql ="SELECT *
						FROM tbl_report_mid
						WHERE pp6_mid_ID=$pp6_mid_id
						AND status=1
						ORDER BY sub_ID ASC

							";
		$this->select();
		$this->setRows();
		$score_total_count=0;
		$score_by_unit_row=0;
		$fully_score_count=0;
		foreach($this->rows as $key => $value) {
			$DataID=  $value['DataID'];
			$score_total=  $value['score_total'];
			if($score_total==-1){
				$grade_set='ร';
			}else{
				$grade_set=$score_total;
				$grade_set_dec=$this->get_grade($score_total);
				$score_total_count=$score_total_count+$score_total;

			}
				
			if ($i==1) {
				$data_response.='
						<td style="width: 1%;">'.$grade_set.'</td>
			';
			}elseif($i>1){
				$data_response.='
						<td style="width: 1%;">'.$grade_set.'</td>
			';
			}
			$fully_score_count=$fully_score_count+50;
		}

		$find_percentage=($score_total_count*100)/$fully_score_count;
		$find_position=$this->find_position($year_data,$class_level_data,$room);
		arsort($find_position);
		$arrayValuePosition=$this->arrayValuePositionNew($find_position,$std_ID);
		$data_response.='
						<td style="width: 1%;">'.$score_total_count.'</td>
						<td style="width: 1%;">'.number_format($find_percentage,2).'</td>
						<td style="width: 1%;">'.$arrayValuePosition.'</td>
			';

		return $data_response;
	}
	public function find_position($year_data,$class_level_data,$room){
		$data_response = array();	
		$this->sql ="SELECT distinct(tbl_pp6_mid.std_ID) as std_pp6_id,tbl_pp6_mid.DataID as pp6_id
					FROM tbl_pp6_mid,tbl_report_mid
					WHERE tbl_pp6_mid.DataID=tbl_report_mid.pp6_mid_ID
					AND tbl_pp6_mid.year='$year_data'
					AND tbl_pp6_mid.room='$room'
					AND tbl_pp6_mid.class_level='$class_level_data'
					AND tbl_report_mid.status=1
		";
		$this->select();
		$this->setRows();
		$find_gpa_sum=0;	
		$score_final_count=0;
		foreach($this->rows as $key => $value) {
			 $std_pp6_id=$value['std_pp6_id'];
			 $pp6_id=$value['pp6_id'];
			 $data_big_std= $this->get_data_big_std($std_pp6_id,$pp6_id);
			 $test[$std_pp6_id] = $data_big_std;
		}

		return $test;
	}
	public function get_data_big_std($std_pp6_id,$pp6_id){
		$this->sql ="SELECT sum(score_total) as sumed
					FROM tbl_pp6_mid,tbl_report_mid
					WHERE tbl_pp6_mid.DataID=tbl_report_mid.pp6_mid_ID
					AND tbl_report_mid.pp6_mid_ID=$pp6_id
					AND score_total!=-1
		";
		$this->select();
		$this->setRows();
		return $this->rows[0]['sumed'];
	}
	public function arrayValuePositionNew($find_position,$std_ID){	
		$result = array();
		$pos = $real_pos = 0;
		$prev_score = -1;
		foreach ($find_position as $exam_n => $score) {
			$real_pos += 1;// Natural position.
			$pos = ($prev_score != $score) ? $real_pos : $pos;// If I have same score, I have same position in ranking, otherwise, natural position.
			$result[$exam_n] = array(
							 "score" => $score, 
							 "position" => $pos, 
							 "exam_no" => $exam_n
							 );
			$prev_score = $score;// update last score.
		}

		return $result[$std_ID]["position"];
}
	public function get_grade($total){
		if ($total<50) {
			$grade='0.0';
		}elseif($total<55){
			$grade='1.0';
		}elseif($total<60){
			$grade='1.5';
		}elseif($total<65){
			$grade='2.0';
		}elseif($total<70){
			$grade='2.5';
		}elseif($total<75){
			$grade='3.0';
		}elseif($total<80){
			$grade='3.5';
		}elseif($total>=80){
			$grade='4.0';
		}
		return $grade;
	}
	public function get_count_std($class_level,$room,$year){
		$this->sql ="SELECT COUNT(*) AS num_row
						FROM tbl_pp6_mid
						WHERE class_level='$class_level'
						AND room='$room'
						AND term='1,2'
						AND year='$year'
						
							";
			$this->select();
			$this->setRows();
			return $this->rows[0]['num_row'];
	}
	public function get_mid_data($class_level,$room,$year,$image_logo,$footer_text){
		$mid_head=$this->get_mid_head($class_level,$room,$year);

		$count_std=$this->get_count_std($class_level,$room,$year);
		if ($count_std<=38) {
			$set_loop_html=2;
		}else{
			$set_loop_html=3;
		}
		
		if ($set_loop_html==1) {
			$loop_data=$this->get_loop_data($class_level,$room,$year);
			$data_response['std_list'].='
						<div style="page-break-after:always;">
					      <page >
					        <div style="text-align: center;line-height: 0.6;font-weight: bold;padding-top: 20px;font-size:16px">
					          <img class="logo-print-size" src="'.$image_logo.'">
					          <p >แบบประกาศผลการเรียนแยกตามระดับชั้น</p>
					          <p >โรงเรียนเทศบาลวัดสระทอง สังกัดเทศบาลเมืองร้อยเอ็ด อ.เมือง จ.ร้อยเอ็ด</p>
					          <p>
					            <span style="margin-right: 30px;">ระดับชั้น 
					              <span style="font-weight: normal;">ประถมศึกษาปีที่ '.substr($class_level,1).'</span>
					            </span> 
					            <span style="margin-right: 20px;">กลางปี</span>  
					            <span>ปีการศึกษา <span style="font-weight: normal;">'.$year.'</span> </span>
					          </p>
					          <p style="margin-top: 10px;">
					            <span style="margin-right: 40px;">ครูประจำชั้น 
					              <span style="font-weight: normal;">.........................................................................................</span>
					            </span>
					            <span>ครูประจำชั้น 
					              <span style="font-weight: normal;">.........................................................................................</span>
					            </span>

					          </p>
					        </div>
					        <table cellspacing="0"  style=" text-align: center; font-size: 16px;width:100%;margin-top: 15px;">
					          <thead>
					            <tr class="text-middle">
					              <th rowspan="2" class="rotate" style="width: 1%;height: 0px;text-align: center;">
					                <div >เลขที่</div>
					              </th>
					              <th rowspan="2" class="rotate" style="width: 1%;height: 0px;text-align: center;">
					                <div >รหัส</div>
					              </th>
					              <th rowspan="2" style="width: 20%;vertical-align: middle;text-align: center;">ชื่อ-สกุล</th>
					               '.$mid_head['head_list'].'
					            </tr> 
					            <tr>
					            	'.$mid_head['sum_100_list'].'
					              <th></th>
					              <th></th>
					              <th></th>
					            </tr>

					          </thead>
					          <tbody >
					            '.$loop_data.'
					          </tbody>
					        </table>
					      </page>
					    </div>
					    <div style="page-break-after:always;">
					      <page >
					      	'.$footer_text.'
					      </page>
					     </div>
			';
		}else{
				if ($set_loop_html==2) {
					for ($i=1; $i <=$set_loop_html ; $i++) {
					$loop_data=$this->get_loop_data($class_level,$room,$year,$i,$set_loop_html);
					if ($i==1) {
						$data_response['std_list'].='
							<div style="page-break-after:always;">
						      <page >
						        <div style="text-align: center;line-height: 0.6;font-weight: bold;padding-top: 20px;font-size:16px">
						          <img class="logo-print-size" src="'.$image_logo.'">
						          <p >แบบประกาศผลการเรียนแยกตามระดับชั้น</p>
						          <p >โรงเรียนเทศบาลวัดสระทอง สังกัดเทศบาลเมืองร้อยเอ็ด อ.เมือง จ.ร้อยเอ็ด</p>
						          <p>
						            <span style="margin-right: 30px;">ระดับชั้น 
						              <span style="font-weight: normal;">ประถมศึกษาปีที่ '.substr($class_level,1).'</span>
						            </span> 
						            <span style="margin-right: 20px;">กลางปี</span>  
						            <span>ปีการศึกษา <span style="font-weight: normal;">'.$year.'</span> </span>
						          </p>
						          <p style="margin-top: 10px;">
						            <span style="margin-right: 40px;">ครูประจำชั้น 
						              <span style="font-weight: normal;">.........................................................................................</span>
						            </span>
						            <span>ครูประจำชั้น 
						              <span style="font-weight: normal;">.........................................................................................</span>
						            </span>

						          </p>
						        </div>
						        <table cellspacing="0"  style=" text-align: center; font-size: 16px;width:100%;margin-top: 15px;">
						          <thead>
						            <tr class="text-middle">
						              <th rowspan="2" class="rotate" style="width: 1%;height: 0px;text-align: center;">
						                <div >เลขที่</div>
						              </th>
						              <th rowspan="2" class="rotate" style="width: 1%;height: 0px;text-align: center;">
						                <div >รหัส</div>
						              </th>
						              <th rowspan="2" style="width: 20%;vertical-align: middle;text-align: center;">ชื่อ-สกุล</th>
						               '.$mid_head['head_list'].'
						            </tr> 
						            <tr>
						            	'.$mid_head['sum_100_list'].'
						              <th></th>
						              <th></th>
						              <th></th>
						            </tr>

						          </thead>
						          <tbody >
						            '.$loop_data.'
						          </tbody>
						        </table>
						      </page>
						    </div>
						   
				';
					}else{
						$data_response['std_list'].='
							 <div style="page-break-after:always;">
						      <page >

						      	<table cellspacing="0"  style=" text-align: center; font-size: 16px;width:100%;margin-top: 15px;">
						      	<thead>
						            <tr class="text-middle">
						              <th rowspan="2" class="rotate" style="width: 1%;height: 0px;text-align: center;">
						                <div >เลขที่</div>
						              </th>
						              <th rowspan="2" class="rotate" style="width: 1%;height: 0px;text-align: center;">
						                <div >รหัส</div>
						              </th>
						              <th rowspan="2" style="width: 20%;vertical-align: middle;text-align: center;">ชื่อ-สกุล</th>
						               '.$mid_head['head_list'].'
						            </tr> 
						            <tr>
						            	'.$mid_head['sum_100_list'].'
						              <th></th>
						              <th></th>
						              <th></th>
						            </tr>

						          </thead>
						      	 <tbody >
						            '.$loop_data.'
						          </tbody>
						          </table>
						          	'.$footer_text.'
						      </page>
						     </div>

						';
					}
					
				}
			}else{
				for ($i=1; $i <=$set_loop_html ; $i++) {
					$loop_data=$this->get_loop_data($class_level,$room,$year,$i,$set_loop_html);
					if ($i==1) {
						$data_response['std_list'].='
							<div style="page-break-after:always;">
						      <page >
						        <div style="text-align: center;line-height: 0.6;font-weight: bold;padding-top: 20px;font-size:16px">
						          <img class="logo-print-size" src="'.$image_logo.'">
						          <p >แบบประกาศผลการเรียนแยกตามระดับชั้น</p>
						          <p >โรงเรียนเทศบาลวัดสระทอง สังกัดเทศบาลเมืองร้อยเอ็ด อ.เมือง จ.ร้อยเอ็ด</p>
						          <p>
						            <span style="margin-right: 30px;">ระดับชั้น 
						              <span style="font-weight: normal;">ประถมศึกษาปีที่ '.substr($class_level,1).'</span>
						            </span> 
						            <span style="margin-right: 20px;">กลางปี</span>  
						            <span>ปีการศึกษา <span style="font-weight: normal;">'.$year.'</span> </span>
						          </p>
						          <p style="margin-top: 10px;">
						            <span style="margin-right: 40px;">ครูประจำชั้น 
						              <span style="font-weight: normal;">.........................................................................................</span>
						            </span>
						            <span>ครูประจำชั้น 
						              <span style="font-weight: normal;">.........................................................................................</span>
						            </span>

						          </p>
						        </div>
						        <table cellspacing="0"  style=" text-align: center; font-size: 16px;width:100%;margin-top: 15px;">
						          <thead>
						            <tr class="text-middle">
						              <th rowspan="2" class="rotate" style="width: 1%;height: 0px;text-align: center;">
						                <div >เลขที่</div>
						              </th>
						              <th rowspan="2" class="rotate" style="width: 1%;height: 0px;text-align: center;">
						                <div >รหัส</div>
						              </th>
						              <th rowspan="2" style="width: 20%;vertical-align: middle;text-align: center;">ชื่อ-สกุล</th>
						               '.$mid_head['head_list'].'
						            </tr> 
						            <tr>
						            	'.$mid_head['sum_100_list'].'
						              <th></th>
						              <th></th>
						              <th></th>
						            </tr>

						          </thead>
						          <tbody >
						            '.$loop_data.'
						          </tbody>
						        </table>
						      </page>
						    </div>
						   
				';
					}elseif($i==2){
						$data_response['std_list'].='
							 <div style="page-break-after:always;">
						      <page >
						      	<table cellspacing="0"  style=" text-align: center; font-size: 16px;width:100%;margin-top: 15px;">
						      	 <tbody >
						            '.$loop_data.'
						          </tbody>
						          </table>   
						      </page>
						     </div>

						';
					}elseif($i==3){
						$data_response['std_list'].='
							 <div style="page-break-after:always;">
						      <page >
						      	<table cellspacing="0"  style=" text-align: center; font-size: 16px;width:100%;margin-top: 15px;">
						      	 <tbody >
						            '.$loop_data.'
						          </tbody>
						          </table>   
						          '.$footer_text.'
						      </page>
						     </div>

						';
					}
					
				}
			}

		}
		
		return $data_response;
	}
	public function get_loop_data($class_level,$room,$year,$i,$set_loop_html){
		if ($i!='') {
			if ($set_loop_html<3) {
				if ($i==1) {
					$find_start=0;
					$find_end=19;
				}elseif($i==2){
					$find_start=19;
					$find_end=19;
				}
			}else{
				if ($i==1) {
					$find_start=0;
					$find_end=19;
				}elseif($i==2){
					$find_start=19;
					$find_end=25;
				}else{
					$find_start=44;
					$find_end=25;
				}
			}
			$this->sql ="SELECT *
						FROM tbl_pp6_mid
						WHERE class_level='$class_level'
						AND room='$room'
						AND term='1,2'
						AND year='$year'
						ORDER BY room ASC,
						CASE
							WHEN name_title LIKE '%dekchai%' THEN 0
					        WHEN name_title LIKE '%nai%' THEN 1
					        WHEN name_title LIKE '%dekying%' THEN 2
					        WHEN name_title LIKE '%nangsaw%'THEN 3
					        WHEN std_ID THEN 4      
					    END
					    LIMIT $find_start,$find_end
							";
			$this->select();
			$this->setRows();
			$number=$find_start+1;
			foreach($this->rows as $key => $value) {
				$DataID=  $value['DataID'];	
				$std_ID=  $value['std_ID'];	
				$name_title_set=  $value['name_title'];	
				$name_title=$this->get_name_title($name_title_set);
				$fname=$value['fname'];	
				$lname=$value['lname'];	
				$class_level=$value['class_level'];	
				
				$name=$name_title.$fname.' '.$lname;
				$course_list=$this->get_course_list($DataID,$i,$year,$room,$class_level,$std_ID);
				$data_response.='
								<tr>
					              <td style="width: 3%;">'.$number.'</td>
					              <td style="width: 5%;">'.$std_ID.'</td>
					              <td style="text-align:left;padding-left:10px;width: 28%;">'.$name.'</td>
					              '.$course_list.'
					            </tr>
				';
				$number++;
			}
		}else{
			$this->sql ="SELECT *
						FROM tbl_pp6_mid
						WHERE class_level='$class_level'
						AND room='$room'
						AND term='1,2'
						AND year='$year'
						ORDER BY room ASC,
						CASE
							WHEN name_title LIKE '%dekchai%' THEN 0
					        WHEN name_title LIKE '%nai%' THEN 1
					        WHEN name_title LIKE '%dekying%' THEN 2
					        WHEN name_title LIKE '%nangsaw%'THEN 3
					        WHEN std_ID THEN 4      
					    END
							";
			$this->select();
			$this->setRows();
			$number=1;
			foreach($this->rows as $key => $value) {
				$DataID=  $value['DataID'];	
				$std_ID=  $value['std_ID'];	
				$name_title_set=  $value['name_title'];	
				$name_title=$this->get_name_title($name_title_set);
				$fname=$value['fname'];	
				$lname=$value['lname'];	
				$class_level=$value['class_level'];	
				$name=$name_title.$fname.' '.$lname;
				$course_list=$this->get_course_list($DataID,-1,$year,$room,$class_level,$std_ID);
				$data_response.='
								<tr>
					              <td>'.$number.'</td>
					              <td>'.$std_ID.'</td>
					              <td style="text-align:left;padding-left:10px;">'.$name.'</td>
					              '.$course_list.'
					            </tr>
				';
				$number++;
			}
		}
		
			return $data_response;
	}
	public function get_data_list($class_level,$room_data,$term_data,$year_data){
		if ($term_data=='mid') {
			$this->sql ="SELECT DISTINCT(room) as room,class_level,year
						FROM tbl_pp6_mid
						WHERE class_level='$class_level'
						AND room='$room_data'
							";
			$this->select();
			$this->setRows();
			foreach($this->rows as $key => $value) {
				$room=  $value['room'];	
				$class_level=  $value['class_level'];
				$class_label=$this->get_class_level($class_level);
				$term=  'กลางปี';	
				$year=  $value['year'];		
				$data_response.='
						 <tr class="text-table-center">
							
							<td>'.$class_label.'</td>
							<td>'.$room.'</td>
							<td>'.$term.'</td>
							<td>'.$year.'</td>
							<td>
								<a target="_blank" 
									href="modules/conclusion/form/learning_result_mid.php?class_level='.$class_level.'&room='.$room.'&term=mid&year='.$year.'" style="color: #ac68cc;">
			                  		<span class="glyphicon glyphicon-print" aria-hidden="true"></span>
			                  	</a>
							</td>
						</tr>
				';
			}
		}else{
			$this->sql ="SELECT DISTINCT(room) as room,class_level,term,year
						FROM tbl_pp6
						WHERE class_level='$class_level'
						AND room='$room_data'
							";
			$this->select();
			$this->setRows();
			foreach($this->rows as $key => $value) {
				$room=  $value['room'];	
				$class_level=  $value['class_level'];
				$class_label=$this->get_class_level($class_level);
				if ($class_level=='p1' || $class_level=='p2' || $class_level=='p3' || $class_level=='p4' || $class_level=='p5' || $class_level=='p6') {
						$term='ปลายปี';
				}else{
					$term=  $value['term'];
				}
				$year=  $value['year'];		
				$data_response.='
						 <tr class="text-table-center">
							<td><input id="checkbox_all" type="checkbox"></td>
							<td>'.$class_label.'</td>
							<td>'.$room.'</td>
							<td>'.$term.'</td>
							<td>'.$year.'</td>
							<td>
								<a target="_blank" href="modules/conclusion/form/learning_result_final.php?class_level='.$class_level.'&room='.$room.'&term=mid&year='.$year.'" style="color: #ac68cc;">
			                  		<span class="glyphicon glyphicon-print" aria-hidden="true"></span>
			                  	</a>
							</td>
						</tr>
				';
			}
		}
		
		return json_encode($data_response);
	}
	public function get_year(){
		$this->sql ="SELECT  distinct(year) as year
					FROM tbl_registed_course
					ORDER BY year DESC
							";
		$this->select();
		$this->setRows();
		foreach($this->rows as $key => $value) {
			$year=  $value['year'];	
			$data_response.='
					 <option value="'.$year.'">'.$year.'</option>
			';
		}
		return json_encode($data_response);
	}
	public function get_name_title($name_title_data){
		if ($name_title_data=="dekchai") {
			$name_title="เด็กชาย";
		}elseif($name_title_data=="dekying"){
			$name_title="เด็กหญิง";
		}elseif($name_title_data=="nai"){
			$name_title="นาย";
		}else{
			$name_title="นางสาว";
		}
		return $name_title;
	}
	public function get_class_level($class_level_data){
		if ($class_level_data=="p1") {
			$class_level="ป.1";
		}elseif($class_level_data=="p2"){
			$class_level="ป.2";	
		}elseif($class_level_data=="p3"){
			$class_level="ป.3";	
		}elseif($class_level_data=="p4"){
			$class_level="ป.4";	
		}elseif($class_level_data=="p5"){
			$class_level="ป.5";	
		}elseif($class_level_data=="p6"){
			$class_level="ป.6";	
		}elseif($class_level_data=="m1"){
			$class_level="ม.1";	
		}elseif($class_level_data=="m2"){
			$class_level="ม.2";	
		}elseif($class_level_data=="m3"){
			$class_level="ม.3";	
		}elseif($class_level_data=="m4"){
			$class_level="ม.4";	
		}elseif($class_level_data=="m5"){
			$class_level="ม.5";	
		}elseif($class_level_data=="m6"){
			$class_level="ม.6";	
		}
		return $class_level;
	}
	public function get_department($data){
		
		switch ($data) {
		    case 1:
		       	$department='ภาษาไทย';
		        break;
		    case 2:
		        $department='คณิตศาสตร์';
		        break;
		    case 3:
		        $department='วิทยาศาสตร์';
		        break;
		    case 31:
		        $department='วิทยาศาสตร์และเทคโนโลยี';
		        break;    
		    case 4:
		        $department='สังคมศึกษา ศาสนาและวัฒนธรรม';
		        break;
		    case 41:
		        $department='สังคมศึกษา';
		        break;
		    case 42:
		        $department='ภูมิศาสตร์';
		        break;
		    case 43:
		        $department='ประวัติศาสตร์';
		        break;
		    case 5:
		        $department='สุขศึกษาและพลศึกษา';
		        break;
		    case 6:
		        $department='ศิลปะ';
		        break;
		    case 7:
		        $department='การงานอาชีพฯ';
		        break; 
		    case 71:
		        $department='การงานอาชีพ';
		        break; 
		    case 8:
		        $department='ภาษาต่างประเทศ';
		        break;  
		    case 9:
		        $department='หน้าที่พลเมือง';
		        break;     
		    case 10:
		        $department='ศิลปะพื้นบ้าน';
		        break;     
		    case 11:
		        $department='ศักยภาพ';
		        break;     
		    case 12:
		        $department='ภาษาจีน';
		        break;        
		    default:
		     	$department='';
		}
		return $department;
	}
}<file_sep>/modules/authen_user/index.js
var opPage = 'authen_user';
var sort_column = 'cdate';
var sort_by = 'desc';
var cur_parent_id = '0';
var pages_sec = 1;

$(document).ready(function() {
    get_data_list(pages_sec,'cdate','desc');

	if (_get.data == 'success') {
		$('#popup_msg').html('<h4 class="no-margin p-b-10">The changes have been saved.</h4>');
	    $('#modal_msg').modal('show');
	}
	
}); 


function get_data_list(pages_current,sort_column,sort_by){ // POST
	var formData = $( "#frm_search" ).serializeArray();
	formData.push({ "name": "acc_action", "value": "get_data_list" }); 
	formData.push({ "name": "sort_column", "value": sort_column}); 
	formData.push({ "name": "sort_by", "value": sort_by}); 
	formData.push({ "name": "pages_current", "value": pages_current });

	// console.log($.param(formData));
	$.ajax({ url: 'modules/' + opPage + '/process.php',type: 'GET',data: formData}).done(function(data) {console.log(data);});

	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus) {
		console.log(data.data_list);
		$('#tb_data_list').find('tbody').html(data.data_list);
		$('#data_pagination').find('ul').html(data.data_pagination);
	});
} 

$(document).delegate('.chg_pagination', 'click', function(event) {
	pages_sec = $(this).attr('data-id');
	get_data_list(pages_sec,sort_column,sort_by);
});

$(document).delegate('#btn__search', 'click', function(event) {
	pages_sec = 1;
	get_data_list(pages_sec,sort_column,sort_by);
});

$(document).delegate('#btn__insert', 'click', function(event) {
	window.location = 'index.php?op='+opPage+'-from';
});

$(document).delegate('#btn__remove', 'click', function(event) {
	$('#modal_cancel').modal('show');
});

$(document).delegate('#btn__conf_remove', 'click', function(event) {
	var tempValue=$("input[name='checkbox_delete[]']:checked").map(function(n){ if(this.checked){return  this.value;}; }).get().join(',');

	var formData = new Array();
	formData.push({ "name": "acc_action", "value": "data_remove" }); 
	formData.push({ "name": "data_val", "value": tempValue}); 
	$.post('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {
		get_data_list('1','cdate','desc');
		$('#modal_cancel').modal('hide');
	});

});

$(document).delegate('#checkbox_all', 'click', function(event) {
	if(this.checked) { // check select status
        $('.checkbox_data').each(function() { //loop through each checkbox
            this.checked = true;  //select all checkboxes with class "checkbox1"               
        });
    }else{
        $('.checkbox_data').each(function() { //loop through each checkbox
            this.checked = false; //deselect all checkboxes with class "checkbox1"                       
        });         
    }
});



// $(document).delegate('#btn_edit_changes', 'click', function(event) {
// 	var cat_id = $(this).attr('data-id');
// 	var parent_id = $('#parent_id').val();
// 	$("#frm_data").attr("action", 'modules/' + opPage + '/process.php?kno_action=edit_post&id='+cat_id+'&cid='+parent_id);
// 	$("#frm_data").attr("target", '_self');
// 	$('#frm_data').submit();	
// });

// $(document).delegate('#btn_new_post', 'click', function(event) {
// 	window.location = 'index.php?op=' + opPage + '-form'+'&cid='+cur_parent_id;
// });

// $(document).delegate('.btn_edit', 'click', function(event) {
// 	var cat_id = $(this).attr('data-id');
// 	window.location = 'index.php?op=' + opPage + '-form&id='+cat_id+'&cid='+cur_parent_id;
// });


// $(document).delegate('.btn_sequence', 'click', function(event) {
// 	var data_id = $(this).attr('data-id');
// 	var sequence = $('#sequence_'+data_id).val();
// 	var sequence_old = $('#sequence_'+data_id).attr('data-id');
// 	if(confirm("Are you sure you want to move ?")) {
// 		$.post('modules/' + opPage + '/process.php', {
// 			'kno_action' : 'sequence_data',
// 			'parent_id' : cur_parent_id,
// 			'data_id' : data_id,
// 			'sequence_old' : sequence_old,
// 			'sequence' : sequence
// 		}, function(response) {
// 			// alert(response);
// 			window.location.reload();
// 		});
// 	}

// });

// $(document).delegate('.bt_delete', 'click', function(event) {
// 	var par_id = $(this).attr('data-id');
// 	if(confirm("Are you sure you want to delete")) {
// 		$.post('modules/' + opPage + '/process.php', {
// 			'kno_action' : 'del_kno_category',
// 			'par_id' : par_id
// 		}, function(response) {
// 			window.location.reload();
// 		});
// 	}
// 	return false;
// });<file_sep>/assets/js/modal-alert.js
/*Get the modal
var modal = document.getElementById('myModal-alert');
var modalRegistedEdit = document.getElementById('myModal-alert-registed-edit');
// Get the button that opens the modal
var btn = document.getElementById("myBtn");
var btnRegistedEdit = document.getElementById("myBtn-registed-edit");

// Get the <span> element that closes the modal
var span = document.getElementsByClassName("close-modal")[0];
var closeBtn = document.getElementsByClassName("close-modal-alert")[0];
// When the user clicks the button, open the modal 
btn.onclick = function() {
    modal.style.display = "block";
}
btnRegistedEdit.onclick = function() {
    modalRegistedEdit.style.display = "block";
}
// When the user clicks on <span> (x), close the modal
closeBtn.onclick = function() {
    modal.style.display = "none";
}
span.onclick = function() {
    modal.style.display = "none";
}

// When the user clicks anywhere outside of the modal, close it
window.onclick = function(event) {
    if (event.target == modal) {
        modal.style.display = "none";
    }
}*/

<file_sep>/modules/report_std_personal/index.js
var opPage = 'report_std_personal';
$(document).ready(function() {
	get_year();
	get_std_list();
});
function get_year(){
	var formData = new Array();
	formData.push({ "name": "acc_action", "value": "get_year" });
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {
		$("#year_data").html(data);
	})
}
 $(document).delegate('#btn_search_name_id', 'click', function(event) {
	var formData = $( "#form_search_name_id" ).serializeArray();
	formData.push({ "name": "acc_action", "value": "get_std_list" }); 
	formData.push({ "name": "search_status", "value": "name_id" }); 
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {
		$("#table_list").html(data);
	})
});
 $(document).delegate('#btn_search_class_room', 'click', function(event) {
 	get_std_list();
 });
function get_std_list(){
	var formData = $( "#frm_search_class_room" ).serializeArray();
	formData.push({ "name": "acc_action", "value": "get_std_list" }); 
	formData.push({ "name": "search_status", "value": "class_room" });  
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {
		$("#table_list").html(data);
	})
}

 $(document).delegate('#chk_value_select', 'click', function(event) {
 	var tempValue=$("input[name='checkbox_print[]']:checked").map(function(n){ if(this.checked){return  this.value;}; }).get().join(',');
	var term =$("#term_data").val();
	var year =$("#year_data").val();
	var class_level_set =$(".class_level_set").val();
	if (class_level_set=='p1' || class_level_set=='p2' || class_level_set=='p3' || class_level_set=='p4' || class_level_set=='p5' || class_level_set=='p6') {
		window.open(
		  'modules/report_std_personal/report_form_p.php?std_ID='+tempValue+'&term='+term+'&year='+year,
		  '_blank' // <- This is what makes it open in a new window.
		);	
	}else{
		window.open(
		  'modules/report_std_personal/report_form_m.php?std_ID='+tempValue+'&term='+term+'&year='+year,
		  '_blank' // <- This is what makes it open in a new window.
		);	
	}
	
	
});  
 $(document).delegate('#checkbox_all', 'click', function(event) {

	if(this.checked) { // check select status
        $('.checkbox_data').each(function() { //loop through each checkbox
            this.checked = true;  //select all checkboxes with class "checkbox1"               
        });
    }else{
        $('.checkbox_data').each(function() { //loop through each checkbox
            this.checked = false; //deselect all checkboxes with class "checkbox1"                       
        });         
    }
});<file_sep>/modules/up_class/view.js
var opPage = 'up_class';
$(document).ready(function() {
	data_year_search_student();
}); 
$(document).delegate('#btn_name_id_search', 'click', function(event) {
	get_data();
});

function data_year_search_student() {
	var formData = new Array();
	formData.push({ "name": "acc_action", "value": "data_year_search_student" });
	formData.push({ "name": "data_class_search", "value": _get.class_level }); 

	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {

		$("#table_list").html(data.table_list);
	});
}


 <file_sep>/modules/attend_class/backup2/index.js
var opPage = 'attend_class';
$(document).ready(function() {
	get_coures_id_list();
	//$(".course_detal_box").hide();
}); 

function save_attend(value,attend_id,course_teaching_stdID,set_attend_day_id,week){
		
	var formData = new Array();
	formData.push({ "name": "acc_action", "value": "save_attend" });
	formData.push({ "name": "status", "value": value.value });
	formData.push({ "name": "attend_id", "value": attend_id });
	formData.push({ "name": "course_teaching_stdID", "value": course_teaching_stdID });
	formData.push({ "name": "set_attend_day_id", "value": set_attend_day_id });
	formData.push({ "name": "week", "value": week });
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {

		get_week_list_data();
	})
}
function set_day(value_day){
	var hr_set=$(".hr_set_"+value_day.value).val();
	var registed_course_id=$("#registed_course_id").val();
	var value_day=value_day.value;
	
	var formData = new Array();
	formData.push({ "name": "acc_action", "value": "set_day" });
	formData.push({ "name": "registed_course_id", "value": registed_course_id });
	formData.push({ "name": "value_day", "value": value_day });
	formData.push({ "name": "hr_set", "value": hr_set });
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {
		get_day_list();
		get_day_set();
	})
}
function get_day_set() {
	var registed_course_id=$("#registed_course_id").val();
	var formData = new Array();
	formData.push({ "name": "acc_action", "value": "get_day_set" });
	formData.push({ "name": "registed_course_id", "value": registed_course_id });

	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {
		$("#get_day_set").html(data);
	})
}
function get_week_list_data() {	
	var registed_course_teaching_id=$("#registed_course_id").val();
	var room_search=$("#room_search").val();
	var length_list_val=$("#length_list_val").val();
	var coures_id_list_val =$("#coures_id_list").val();
	var formData = new Array();
	formData.push({ "name": "acc_action", "value": "get_week_list_data" }); 
	
	formData.push({ "name": "room_search", "value": room_search}); 
	formData.push({ "name": "length_list_val", "value": length_list_val}); 
	formData.push({ "name": "coures_id_list_val", "value": coures_id_list_val}); 
	formData.push({ "name": "registed_course_teaching_id", "value": registed_course_teaching_id}); 
	
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {	
		$("#header_sum_score").html(data.num_day);
		$("#all_attendID").val(data.all_attendID);
		$("#std_id_all").val(data.std_id_all);

		$("#detail_std").html(data.detail_std);
		//open_edit_attend();
		
	})
}
function get_day_list() {

	var registed_course_id=$("#registed_course_id").val();
	var length_list_val=$("#length_list_val").val();
	var formData = new Array();
	formData.push({ "name": "acc_action", "value": "get_day_list" }); 
	formData.push({ "name": "registed_course_id", "value": registed_course_id}); 
	formData.push({ "name": "length_list_val", "value": length_list_val}); 
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {	
		//alert(data)
		if (parseInt(data.num_attend_day)==0) {		
			$(".num_attend_day_chk").css('display','none');
			$(".alert_attend_day_chk").css('display','block');
			
		}else{
			$(".num_attend_day_chk").css('display','block');
			$(".alert_attend_day_chk").css('display','none');
		}
		$("#set_colspan_save_score_title").attr("colspan",data.data_count+2);
		$("#week_title").attr("colspan",data.data_count);

		$("#week_title").html(data.week_title);
		$("#week_header").html(data.week_header);
		$(".set_header_width").attr("width",400/data.data_count);
		get_week_list_data();

	})
}

$(document).delegate('#btn_search_course_detail', 'click', function(event) {
	var formData = $( "#frm_data_room" ).serializeArray();
	formData.push({ "name": "acc_action", "value": "search_course_detail" }); 
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {	
		$("#length_list_val").html(data.week_menu_data);
		$("#place_detail_courseID").html(data.courseID);
		$("#place_detail_name").html(data.name);
		$("#place_detail_unit").html(data.unit);
		$("#place_detail_hr_learn").html(data.hr_learn);
		$("#place_detail_class_level").html(data.class_level_co);
		
		$("#hr-co-text-depart_course").show();
		$(".course_detal_box").show();
		$("#registed_course_id").val(data.registed_course_id);
		get_day_set();
		get_day_list();
		//get_config();	
	})
})
function get_class_level() {
	var coures_id_list_val =$("#coures_id_list").val();

	var formData = new Array();
	formData.push({ "name": "acc_action", "value": "get_class_level" });
	formData.push({ "name": "coures_id_list_val", "value": coures_id_list_val });
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {
		$("#place_class_level").html(data.class_level);
		$("#room_search").html(data.room);
	})
}
function get_coures_id_list() {
	var formData = new Array();
	formData.push({ "name": "acc_action", "value": "get_coures_id_list" });
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {

		$("#coures_id_list").html(data.coures_id_list);
		get_class_level();

	})
}<file_sep>/modules/regis_course_teaching/back/process.php
<?php
@ob_start();
@session_start();

require_once('../../init.php');
include('../../src/class.pagination.php');
include('../../src/class.inputfilter.php');
$InputFilter = new InputFilter();

##CLASS_DB_CONNECT##
include('class_modules.php');
$class_data = new ClassData();
##CLASS_DB_CONNECT##

if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_term_year_now"){	
	echo $class_data->get_term_year_now();
}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_teaching_student_only"){	
	$data_id=$_GET['data_id'];
	$data_room=$_GET['data_room'];
	
	echo $class_data->get_teaching_student_only($data_id,$data_room);
}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_course_teaching_student"){	
	$data_id=$_GET['data_id'];
	echo $class_data->get_course_teaching_student($data_id);
}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_propotion_objective"){	
	$data_id_first=$_GET['data_id_first'];
	echo $class_data->get_propotion_objective($data_id_first);
}

if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_objective_place_plus"){
	$data_responds='
		<div class="set-line pl-20 object-mb-set mt-nega-10">
                    <p class=" text-inline">ข้อที่</p>
                    <div class="input-group form-serch-width-small">
                      <input name="no_order_new[]"  type="text" class="form-control form-set"  aria-describedby="basic-addon1" value="">
                    </div> 
                    <p class=" text-inline">ตัวชี้วัด</p>
                    <div class="input-group form-serch-width-large">
                      <input name="detail_new[]" type="text" class="form-control form-set"  aria-describedby="basic-addon1" value="">
                    </div> 
                    <div id="btn_plus_objective" class="btn-search">
                      <span class="text-icon">+</span>
                    </div>  
                  </div>
	';	
	echo json_encode($data_responds);
}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "plus_objective"){	
		$no_order_new=$_GET['no_order_new'];
		$detail_new=$_GET['detail_new'];
		$user_id=$_SESSION['ss_user_id'];

		for ($i=0; $i < count($no_order_new) ; $i++) {
		$data_responds.='
							 <div class="set-line pl-20 object-mb-set mt-10">
                                  <p class=" text-inline">ข้อที่</p>
                                  <div class="input-group form-serch-width-small">
                                    <input  name="no_order_new[]" type="text" class="form-control form-set"  aria-describedby="basic-addon1" value="'.$no_order_new[$i].'">
                                  </div> 
                                  <p class=" text-inline">ตัวชี้วัด</p>
                                  <div class="input-group form-serch-width-large">
                                    <input name="detail_new[]" type="text" class="form-control form-set"  aria-describedby="basic-addon1" value="'.$detail_new[$i].'">
                                  </div>                                                       
                                </div>
		';
		}
	$data_responds.='
					<div class="set-line pl-20 object-mb-set ">
                                  <p class=" text-inline">ข้อที่</p>
                                  <div class="input-group form-serch-width-small">
                                    <input  name="no_order_new[]"  type="text" class="form-control form-set"  aria-describedby="basic-addon1" value=" ">
                                  </div> 
                                  <p class=" text-inline">ตัวชี้วัด</p>
                                  <div class="input-group form-serch-width-large">
                                    <input name="detail_new[]" type="text" class="form-control form-set"  aria-describedby="basic-addon1" value=" ">
                                  </div> 
                                  <div id="btn_plus_objective" class="btn-search">
                                    <span class="text-icon">+</span>
                                  </div>  
                                </div>
	';

	echo json_encode($data_responds);
}
if(isset($_POST['acc_action']) and $_POST['acc_action'] == "add_data_proportion"){
	$course_id=$_POST['course_id'];
		$arr_sql["courseID"]="'".chkhtmlspecialchars($InputFilter->clean_script(trim($course_id)))."'";		
		$arr_sql["comulative"]="'".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['comulative'])))."'";	
		$arr_sql["mid_exam"]="'".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['mid_exam'])))."'";	
		$arr_sql["final_exam"]="'".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['final_exam'])))."'";	
		echo $class_data->insert_data_proportion($arr_sql,$course_id);	
}
if(isset($_POST['acc_action']) and $_POST['acc_action'] == "add_objective_conclude"){
	$course_id=$_POST['course_id'];
	$no_order_new=$_POST['no_order_new'];
	$detail_new=$_POST['detail_new'];
	for ($i=0; $i < count($no_order_new) ; $i++) {
			if ($no_order_new[$i]=="" || $detail_new[$i]=="") {			
			}else{
				$class_data->sql ="INSERT INTO tbl_objective_conclude(courseID,no_order,detail) VALUES($course_id,$no_order_new[$i],'$detail_new[$i]')";
	       		echo $class_data->query();		
			}			
		}
}
if(isset($_POST['acc_action']) and $_POST['acc_action'] == "update_objective_conclude"){
	$course_id=$_POST['course_id'];
	$objective_data_all_id=$_POST['objective_data_all_id'];	
	$no_order=$_POST['no_order'];
	$detail=$_POST['detail'];
	$arr_id = explode("-", $objective_data_all_id);
			$class_data->sql ="SELECT  *
					FROM tbl_objective_conclude 
					WHERE courseID=$course_id
							";
			$class_data->select();
			$class_data->setRows();	
			foreach($class_data->rows as $key => $value) {
				$DataID=$value['DataID'];
				for ($i=0; $i < count($arr_id) ; $i++) { 
					if ($DataID==$arr_id[$i]) {
						$sql="UPDATE tbl_objective_conclude SET no_order=$no_order[$i],detail='$detail[$i]' WHERE DataID={$arr_id[$i]}";
						$class_data->sql =$sql;
	    			    $class_data->query();    			
					}
				}
				
			}

}
if(isset($_POST['acc_action']) and $_POST['acc_action'] == "add_teaching"){	
		$course_id=$_POST['course_id'];
		$term_search=$_POST['term_search'];
		$year_search=$_POST['year_search'];
		
		echo $class_data->insert_data_teaching($course_id,$term_search,$year_search);

}
if(isset($_POST['acc_action']) and $_POST['acc_action'] == "data_remove_std"){
	$data_val = $_POST['data_val'];
	echo $class_data->data_remove_std($data_val);
}
if(isset($_POST['acc_action']) and $_POST['acc_action'] == "data_remove_objective"){
	$data_val = $_POST['data_val'];
	echo $class_data->data_remove_objective($data_val);
}
if(isset($_POST['acc_action']) and $_POST['acc_action'] == "data_remove"){
	$data_val = $_POST['data_val'];
	echo $class_data->get_data_delete($data_val);
}

if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_registed_course_teaching"){	
		echo $class_data->get_registed_course_teaching();

}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_std_list_new"){	
		$id_std_search=$_GET['id_std_search'];
		$search_class_modal=$_GET['search_class_modal'];
		$search_room_modal=$_GET['search_room_modal'];
		$course_id=$_GET['course_id'];
		$term_search=$_GET['term_search'];
		$year_search=$_GET['year_search'];
		
		echo $class_data->get_std_list($id_std_search,$search_class_modal,$search_room_modal,$course_id,$term_search,$year_search);

}
if(isset($_POST['acc_action']) and $_POST['acc_action'] == "data_add_std"){	
		$data_val = $_POST['data_val'];
		$course_id = $_POST['course_id'];
		$term_search = $_POST['term_search'];
		$year_search = $_POST['year_search'];
		echo $class_data->data_add_std($data_val,$course_id,$term_search,$year_search);

}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_std_list"){	
		$id_std_search=$_GET['id_std_search'];
		$search_class_modal=$_GET['search_class_modal'];
		$search_room_modal=$_GET['search_room_modal'];
		$course_id=$_GET['course_id'];
		
		echo $class_data->get_std_list($id_std_search,$search_class_modal,$search_room_modal,$course_id);

}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_name_to_add_std"){	
		$data_id_first=$_GET['data_id_first'];
		$registed_course_id=$_GET['registed_course_id'];
		$term_search=$_GET['term_search'];
		$year_search=$_GET['year_search'];
		
		echo $class_data->get_name_to_add_std($data_id_first,$registed_course_id,$term_search,$year_search);

}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "search_course_class"){	
		$department_search=$_GET['department_search'];
		$class_level_search=$_GET['class_level_search'];
		$term_search=$_GET['term_search'];
		$year_search=$_GET['year_search'];
		echo $class_data->search_course_class($department_search,$class_level_search,$term_search,$year_search);

}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "hide_class_std"){	
		$data_id_first=$_GET['data_id_first'];
		echo $class_data->hide_class_std($data_id_first);

}
<file_sep>/modules/conclusion/learning_result_report_p.php
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="../../assets/css/bootstrap.css" rel="stylesheet" type="text/css">
<link href="../../assets/css/margin-padding.css" rel="stylesheet" type="text/css">
<link href="../../assets/css/responsive.css" rel="stylesheet" type="text/css">
<link href="../../assets/css/print_conclusion.css?<?php echo date('l jS \of F Y h:i:s A'); ?>" rel="stylesheet" type="text/css">

<script type="text/javascript" src="../../assets/js/jquery.js"></script>
<style type="text/css">
<!--
 table {
    border-collapse: collapse;
}
td, th {
    border: 1px solid black;
    padding: 2px;
}
-->
</style>
<?php

 @session_start();

require_once('../../init.php');
include('class_modules.php');
$class_data = new ClassData();

$std_ID=$_GET['std_ID'];

$term=$_GET['term'];
$year=$_GET['year'];

?>
<div style="background-color: rgb(82, 86, 89);min-height: 100%">
<div style="font-size: 10%;background-color: white;min-height: 100%;padding-right: 15px; padding-left: 15px;margin-right: auto;margin-left: auto;width: 80%">    
<div style="page-break-after:always;">
                 <page >
                   <div >
                    <table cellspacing="0"  style=" text-align: center; font-size: 22px;width:142%;">
                      <caption style="font-size:28px ;margin-left: 30px;margin-top: 0px;">บันทึกเวลาเข้าเรียน</caption>
                              <thead>
                                  <tr class="text-middle">
                                  <td rowspan="3" class="rotate" style="width: 0.1%;font-size: 22px;height: 0px;"><div >เลขที่</div></td>
                                  <td rowspan="3" class="rotate" style="width: 0.1%;font-size: 22px;height: 0px;"><div >รหัส</div></td>
                                  <td rowspan="3" style="width: 10%;vertical-align: middle;font-size: 22px;">ชื่อ-สกุล</td>
                                  <td colspan="40" style="width: 50%;padding: 5px;font-size: 22px;">'.$num_day.' ชั่วโมง/สัปดาห์</td>      
                                  <td rowspan="3" class="rotate" style="width: 0.1%;height: 0px;"><div style="margin-top: 30px;">รวม '.$total_hr.' ชั่วโมง</div></td>
                                  <td rowspan="3" class="rotate" style="width: 0.1%;height: 0px;"><div style="margin-top: 30px;">ร้อยละ</div></td>
                            
                                </tr>
                                <tr>
                                  <td colspan="40" style="width: 60%;padding: 5px;border-left:none;font-size: 22px;">สัปดาห์ที่</td>      
                                </tr> 
                                 <tr>
                                  <td style="border-left: none;width: 0.5%;">1</td>
                                  <td style="width: 0.5%;">2</td>
                                  <td style="width: 0.5%;">3</td>
                                  <td style="width: 0.5%;">4</td>
                                  <td style="width: 0.5%;">5</td>
                                  <td style="width: 0.5%;">6</td>
                                  <td style="width: 0.5%;">7</td>
                                  <td style="width: 0.5%;">8</td>
                                  <td style="width: 0.5%;">9</td>
                                  <td style="width: 0.5%;">10</td>
                                  <td style="width: 0.5%;">11</td>
                                  <td style="width: 0.5%;">12</td>
                                  <td style="width: 0.5%;">13</td>
                                  <td style="width: 0.5%;">14</td>
                                  <td style="width: 0.5%;">15</td>
                                  <td style="width: 0.5%;">16</td>
                                  <td style="width: 0.5%;">17</td>
                                  <td style="width: 0.5%;">18</td>
                                  <td style="width: 0.5%;">19</td>
                                  <td style="width: 0.5%;">20</td>  
                                  <td style="width: 0.5%;">21</td>  
                                  <td style="width: 0.5%;">22</td>  
                                  <td style="width: 0.5%;">23</td>  
                                  <td style="width: 0.5%;">24</td>  
                                  <td style="width: 0.5%;">25</td>  
                                  <td style="width: 0.5%;">26</td>  
                                  <td style="width: 0.5%;">27</td>  
                                  <td style="width: 0.5%;">28</td>  
                                  <td style="width: 0.5%;">29</td>  
                                  <td style="width: 0.5%;">30</td>  
                                  <td style="width: 0.5%;">31</td>  
                                  <td style="width: 0.5%;">32</td>  
                                  <td style="width: 0.5%;">33</td>  
                                  <td style="width: 0.5%;">34</td>  
                                  <td style="width: 0.5%;">35</td>  
                                  <td style="width: 0.5%;">36</td>  
                                  <td style="width: 0.5%;">37</td>  
                                  <td style="width: 0.5%;">38</td>  
                                  <td style="width: 0.5%;">39</td>  
                                  <td style="width: 0.5%;">40</td>               
                                </tr>      
                              </thead>
                              <tbody >
                                
                               '.$detail_std_attend_p['detail_std'].'
                                
                              </tbody>
                            </table>
                          </div>
                 </page>
                </div>

</div>
</div>
<script>
 /*$(document).ready(function() {
    get_print();
    setTimeout(window.close, 0);
  });
  function get_print() {
    window.print();
  }*/
  var css = '@page { size: landscape; }',
    head = document.head || document.getElementsByTagName('head')[0],
    style = document.createElement('style');
    style.type = 'text/css';
    style.media = 'print';

    if (style.styleSheet){
      style.styleSheet.cssText = css;
    } else {
      style.appendChild(document.createTextNode(css));
    }
    head.appendChild(style);
    window.print();
</script><file_sep>/modules/mobile_api/host/newssubboxhome.php
<?php	
	@session_start();
    
    require_once('config.php');
    require_once('src/database.php');
	include('class_modules.php');
	$class_data = new ClassData();
	##CLASS_DB_CONNECT##
	$condition = false;
	$num=  $class_data->rows[0]['num'];		
	$json = json_decode(file_get_contents('php://input'), true);
	$newsheighlight=1;


	if (!empty($newsheighlight) ) {
        $products_arr=array();
        $products_arr["records"]=array();
        $sql = "SELECT DataID,title,detail,date FROM tbl_news WHERE DataID not in(SELECT MAX(date) FROM tbl_news) ORDER BY date DESC";
		$class_data->sql = $sql;
		$class_data->select();
        $class_data->setRows();
        
        foreach($class_data->rows as $key => $value) {
            $DataID= $value['DataID'];	
            $title= strip_tags(htmlspecialchars_decode($value['title']));
            $detail= $value['detail'];
            $detail= htmlspecialchars_decode($detail);
            //if(strlen($detail) > 80) $detail = substr($detail, 0, 80).'...';
            if(strlen($detail) > 40) {
                $detail = iconv_substr($detail, 0, 40).'...';
            }
            $detail= strip_tags(htmlspecialchars_decode($detail));
            $date_set= $value['date'];
            $old_form_date = strtotime($date_set);
            $date=date('d-m-Y', $old_form_date); 
            
            $class_data->sql = "SELECT file_name FROM tbl_news_gallery WHERE newsID=$DataID";
            $class_data->select();
            $class_data->setRows();
            $img_url='/sratong-app/file_managers/news/'.$class_data->rows[0]['file_name'];
            $data_res['status']=1;

            $product_item=array(
                "key" => $key,
                "DataID" => $DataID,
                "title" => $title,
                "detail" => $detail,
                "date" => $date,
                "img_url" => $img_url,

            );
            array_push($products_arr["records"], $product_item);
        }
        
        echo json_encode($products_arr,JSON_UNESCAPED_UNICODE);
	}else{
        $data_res['status']=0;
    }
	
	

   

 ?>
<file_sep>/modules/maneger_student/process.php
<?php
@ob_start();
@session_start();

require_once('../../init.php');
include('../../src/class.pagination.php');
include('../../src/class.inputfilter.php');
$InputFilter = new InputFilter();

##CLASS_DB_CONNECT##
include('class_modules.php');
$class_data = new ClassData();
##CLASS_DB_CONNECT##
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "chk_id"){
	$std_ID=$_GET['std_ID'];
	$card_ID=$_GET['card_ID'];
	echo $class_data->chk_id($std_ID,$card_ID);
}
if(isset($_POST['acc_action']) and $_POST['acc_action'] == "save_data"){
		$data_id=$_POST['data_id'];
		$day=$_POST['day'];
		$mouth=$_POST['mouth'];
		$years=$_POST['years']-543;
		$birthday=$years.'-'.$mouth.'-'.$day;

		$arr_sql[]="std_ID='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['std_ID'])))."'";
		$arr_sql[]="card_ID='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['card_ID'])))."'";
		/*$arr_sql[]="class_level='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['class_level'])))."'";
		$arr_sql[]="room='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['room'])))."'";*/
		$arr_sql[]="name_title='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['name_title'])))."'";
		$arr_sql[]="fname='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['fname'])))."'";
		$arr_sql[]="lname='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['lname'])))."'";
		$arr_sql[]="birthday='".chkhtmlspecialchars($InputFilter->clean_script(trim($birthday)))."'";
		$arr_sql[]="blood_group='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['blood_group'])))."'";
		$arr_sql[]="address='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['address'])))."'";
		$arr_sql[]="parent_name_title='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['parent_name_title'])))."'";
		$arr_sql[]="parent_fname='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['parent_fname'])))."'";	
		$arr_sql[]="parent_lname='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['parent_lname'])))."'";	
		$arr_sql[]="tell='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['tell'])))."'";	
		$arr_sql[]="parent_address='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['parent_address'])))."'";
		$arr_sql[]="status_alive='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['status_alive'])))."'";	

		$arr_sql_class_room[]="std_ID='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['std_ID'])))."'";
		/*$arr_sql_class_room[]="class_level='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['class_level'])))."'";
		$arr_sql_class_room[]="room='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['room'])))."'";*/
		$arr_sql_class_room[]="status='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['status_alive'])))."'";
		$class_data->update_data($arr_sql,$arr_sql_class_room,$data_id);
	}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_data_form"){
	$data_id=$_GET['data_id'];
	$new_data_id=$_GET['new_data_id'];
	
	echo $class_data->get_data_form($data_id,$new_data_id);
}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_years"){
	echo $class_data->get_years();
}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_day"){
	$mouth=$_GET['mouth'];
	echo $class_data->get_day($mouth);
}
if(isset($_POST['acc_action']) and $_POST['acc_action'] == "data_remove"){
	$data_val = $_POST['data_val'];
	echo $class_data->get_data_delete($data_val);
}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "data_year_search_student"){	
	$arr_search_val['data_class_search'] = $_GET['data_class_search'];
	$arr_search_val['data_room_search'] = $_GET['data_room_search'];
	echo $class_data->data_year_search_student($arr_search_val);
}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_data"){	
	$arr_search_val['name_id_search'] = $_GET['name_id_search'];
	
	echo $class_data->get_data($arr_search_val);
}<file_sep>/modules/regis_student/upload_one.php
<?php
@ob_start();
@session_start();

require_once('../../init.php');
include('../../src/class.pagination.php');
include('../../src/class.inputfilter.php');
$InputFilter = new InputFilter();

##CLASS_DB_CONNECT##
include('class_modules.php');
$class_data = new ClassData();
##CLASS_DB_CONNECT##


		$file = $_FILES['file']['tmp_name'];
		$year_main = $_POST['year_main'];
		
		$handle = fopen($file, "r");
		fgetcsv($handle);
		while(($filesop = fgetcsv($handle, 1000, ",")) !== false)		
		{	
				$std_ID = trim($filesop[0]);
				$card_ID = trim($filesop[1]);
				$name_title_set = trim($filesop[2]);
				$fname = trim($filesop[3]);
				$lname = trim($filesop[4]);
				$birthday_set = trim($filesop[5]);
				$class_level = trim($filesop[6]);
				$room = trim($filesop[7]);
				if ($name_title_set=='เด็กชาย') {
					$name_title='dekchai';
				}elseif($name_title_set=='เด็กหญิง'){
					$name_title='dekying';
				}elseif($name_title_set=='นาย'){
					$name_title='nai';
				}elseif($name_title_set=='นางสาว'){
					$name_title='nangsaw';
				}
				list($day,$month,$year_set) = split('[/]', $birthday_set);
				$year=$year_set-543;
				$birthday=$year.'-'.$month.'-'.$day;
				$password_show=$day.$month.$year_set;
				$password=MD5($day.$month.$year_set);

				$class_data->sql = "SELECT count(*) as num_data
										FROM tbl_student,tbl_std_class_room
										WHERE tbl_student.std_ID=tbl_std_class_room.std_ID
										AND tbl_student.std_ID='$std_ID'
										AND tbl_std_class_room.std_ID='$std_ID'
									";
				$class_data->select();
				$class_data->setRows();
				$num_data=$class_data->rows[0]['num_data'];
				if ($num_data==0) {
					$class_data->sql = "INSERT INTO tbl_student(std_ID,card_ID,password,name_title,fname,lname,birthday) VALUES ('$std_ID','$card_ID','$password','$name_title','$fname','$lname','$birthday')";
						$class_data->query();
						$class_data->sql = "INSERT INTO tbl_std_class_room(std_ID,class_level,room,year,status) 
											VALUES ('$std_ID','$class_level','$room','$year_main',1)";
						$class_data->query();
	
					$data_res.='
					 <tr>
		                  <td>'.$std_ID.'</td>
		                  <td>'.$password_show.'</td>
		                  <td>'.$class_level.'</td>
		                  <td>'.$room.'</td>
		                  <td>'.$name_title_set.'</td>
		                  <td>'.$fname.'</td>
		                  <td>'.$lname.'</td>
		                  <td>'.$birthday_set.'</td>
	               	</tr>    
				';
				
				}else{
					$class_data->sql = "SELECT COUNT(*) as num_data_finish
										FROM tbl_std_class_room
										WHERE std_ID='$std_ID'
										AND status=2
									";
					$class_data->select();
					$class_data->setRows();
					$num_data_finish=$class_data->rows[0]['num_data_finish'];
					if ($num_data_finish>0) {
						$class_data->sql = "INSERT INTO tbl_std_class_room(std_ID,class_level,room,year,status) 
											VALUES ('$std_ID','$class_level','$room','$year_main',1)";
						$class_data->query();
						$data_res.='
							 <tr>
				                  <td>'.$std_ID.'</td>
				                  <td>'.$password_show.'</td>
				                  <td>'.$class_level.'</td>
				                  <td>'.$room.'</td>
				                  <td>'.$name_title_set.'</td>
				                  <td>'.$fname.'</td>
				                  <td>'.$lname.'</td>
				                  <td>'.$birthday_set.'</td>
			               	</tr>    
						';
					}
				}
			
			$c = $c + 1;
		}
	    echo $data_res;  



?><file_sep>/modules/send_midterm/class_modules.php
<?php 
class ClassData extends Databases {
	public function get_dev_summary($coures_id_list_val,$room_search){
		$data_response = array();	
		$this->sql ="SELECT  count(*) as num_row_std FROM tbl_student 
					WHERE std_ID in(
						SELECT stdID
						FROM tbl_course_teaching_std
						WHERE registed_courseID in(
							SELECT DataID
							FROM tbl_registed_course
							WHERE courseID=$coures_id_list_val
						)
					)
					
					";
		$this->select();
		$this->setRows();	
		$data_response['num_all_std']=$this->rows[0]['num_row_std'];
		$this->sql ="SELECT  *
					FROM tbl_student 
					WHERE std_ID in(
						SELECT stdID
						FROM tbl_course_teaching_std
						WHERE registed_courseID in(
							SELECT DataID
							FROM tbl_registed_course
							WHERE courseID=$coures_id_list_val
						)
					)
					ORDER BY 
					CASE
						WHEN name_title LIKE '%dekchai%' THEN 0
				        WHEN name_title LIKE '%nai%' THEN 1
				        WHEN name_title LIKE '%dekying%' THEN 2
				        WHEN name_title LIKE '%nangsaw%'THEN 3
				        WHEN std_ID THEN 4      
				    END
					";
		$this->select();
		$this->setRows();	
		$data_atte_nopass=0;
		$data_atte_pass=0;
		$data_desirable_nopass=0;
		$data_desirable_pass=0;
		$data_desirable_good=0;
		$data_desirable_verygood=0;

		$data_read_think_write_nopass=0;
		$data_read_think_write_pass=0;
		$data_read_think_write_good=0;
		$data_read_think_write_verygood=0;

		$number=1;
		foreach($this->rows as $key => $value) {
			$std_ID=$value['std_ID'];
			$name_title_data=$value['name_title'];
			$name_title=$this->get_name_title($name_title_data);
			$fname=$value['fname'];
			$lname=$value['lname'];
			
			$score_attend_class=$this->get_score_attend_class($std_ID,$coures_id_list_val,$room_search);
			if ($score_attend_class=='nopass') {
				$data_atte_nopass++;
			}else{
				$data_atte_pass++;
			}
			$desirable=$this->get_desirable($std_ID,$coures_id_list_val);	
				if ($desirable=='nopass') {
					$data_desirable_nopass++;
				}elseif($desirable=='pass'){
					$data_desirable_pass++;
				}elseif($desirable=='good'){
					$data_desirable_good++;
				}elseif($desirable=='verygood'){
					$data_desirable_verygood++;
				}
			$read_think_write=$this->get_read_think_write($std_ID,$coures_id_list_val);
			if ($read_think_write=='nopass') {
				$data_read_think_write_nopass++;
			}elseif($read_think_write=='pass'){
				$data_read_think_write_pass++;
			}elseif($read_think_write=='good'){
				$data_read_think_write_good++;
			}elseif($read_think_write=='verygood'){
				$data_read_think_write_verygood++;
			}
			if ($score_attend_class=='pass') {
				$pass_status='<td><span class="glyphicon glyphicon-ok text-violet" aria-hidden="true"></span></td>
                              <td></td>';
			}else{
				$pass_status='<td></td>
                              <td><span class="glyphicon glyphicon-ok text-violet" aria-hidden="true"></span></td>';

			}
			$data_response['std_list'].='
								<tr>
                                  <td>'.$number.'</td>
                                  <td style="text-align:left;padding-left:20%;">'.$name_title.$fname.' '.$lname.'</td>
                                   '.$pass_status.'               
                                </tr>
			';
		$number++;
		}
		$data_response['data_atte_nopass']=$data_atte_nopass;	
		$data_response['data_atte_pass']=$data_atte_pass;

		$data_response['data_desirable_nopass']=$data_desirable_nopass;
		$data_response['data_desirable_pass']=$data_desirable_pass;
		$data_response['data_desirable_good']=$data_desirable_good;
		$data_response['data_desirable_verygood']=$data_desirable_verygood;	

		$data_response['data_read_think_write_nopass']=$data_read_think_write_nopass;
		$data_response['data_read_think_write_pass']=$data_read_think_write_pass;
		$data_response['data_read_think_write_good']=$data_read_think_write_good;
		$data_response['data_read_think_write_verygood']=$data_read_think_write_verygood;
		echo json_encode($data_response);
	}
	public function get_registed_courseID($coures_id_list_val){
		$this->sql ="SELECT  *
					FROM tbl_set_term_year 			
							";
		$this->select();
		$this->setRows();
		$term_set=$this->rows[0]['term'];
		$year_set=$this->rows[0]['year'];

		$data_response = array();
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 	
					WHERE DataID=$coures_id_list_val					
					";
		$this->select();
		$this->setRows();
		$class_level=$this->rows[0]['class_level'];
		$status=$this->rows[0]['status'];
		if ($class_level=='p1' || $class_level=='p2' || $class_level=='p3' || $class_level=='p4' || $class_level=='p5' || $class_level=='p6' ) {
			$term_set='1,2';
		}
			
		$this->sql ="SELECT  *
					FROM tbl_registed_course 	
					WHERE courseID=$coures_id_list_val
					AND term='$term_set'
					AND year='$year_set'

					";
		$this->select();
		$this->setRows();		
		return $this->rows[0]['DataID'];	
	}
	public function get_score_pick($std_ID,$coures_id_list_val){
		$registed_courseID=$this->get_registed_courseID($coures_id_list_val);
		$num_of_i=0;
		$this->sql ="SELECT  COUNT(score) as num_of_i
					FROM tbl_objective_score_std 	
					WHERE staID='$std_ID'
					AND registed_courseID=$registed_courseID
					AND score=-1
					";
		$this->select();
		$this->setRows();
		$num_of_i=$this->rows[0]['num_of_i'];			
		$this->sql ="SELECT  SUM(score) as score_total
					FROM tbl_objective_score_std 	
					WHERE staID='$std_ID'
					AND registed_courseID=$registed_courseID
					";
		$this->select();
		$this->setRows();	
		$score_total_data=$this->rows[0]['score_total'];
		if ($num_of_i>0) {
			$total='i';
		}else{
			$total=$score_total_data;
		}
			return $total;
	}
	public function get_score_exam($std_ID,$coures_id_list_val){	
	$this->sql ="SELECT  *
					FROM tbl_set_term_year 			
							";
		$this->select();
		$this->setRows();
		$term_set=$this->rows[0]['term'];
		$year_set=$this->rows[0]['year'];
		$data_response = array();	
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 	
					WHERE DataID=$coures_id_list_val
					
					";
		$this->select();
		$this->setRows();		
		$class_level_data=$this->rows[0]['class_level'];	
		$data_response['class_level']=$this->get_class_level_new($class_level_data);
		if ($class_level_data=='p1' || $class_level_data=='p2' || $class_level_data=='p3' || $class_level_data=='p4' || $class_level_data=='p5' || $class_level_data=='p6' ) {
			$term_set='1,2';
		}	
		$mid_status=0;
		$final_status=0;
		$this->sql ="SELECT  COUNT(score) as num_of_i_mid
					FROM tbl_mid_exam_score
					WHERE stdID='$std_ID'
					AND score=-1
					AND course_teachingID in(
						SELECT DataID
						FROM tbl_registed_course_teaching
						WHERE registed_courseID in(
							SELECT DataID
							FROM tbl_registed_course
							WHERE courseID=$coures_id_list_val
							AND term='$term_set'
							AND year='$year_set'
						)
					)
					";
		$this->select();
		$this->setRows();	
		$num_of_i_mid=$this->rows[0]['num_of_i_mid'];
		if ($num_of_i_mid>0) {
			$mid_status=-1;
		}
		$this->sql ="SELECT  *
					FROM tbl_mid_exam_score
					WHERE stdID='$std_ID'
					AND course_teachingID in(
						SELECT DataID
						FROM tbl_registed_course_teaching
						WHERE registed_courseID in(
							SELECT DataID
							FROM tbl_registed_course
							WHERE courseID=$coures_id_list_val
							AND term='$term_set'
							AND year='$year_set'
						)
					)
					";
		$this->select();
		$this->setRows();	
		$mid_exam_score=$this->rows[0]['score'];
		$this->sql ="SELECT  COUNT(score) as num_of_i_final
					FROM tbl_final_exam_score
					WHERE stdID='$std_ID'
					AND score=-1
					AND course_teachingID in(
						SELECT DataID
						FROM tbl_registed_course_teaching
						WHERE registed_courseID in(
							SELECT DataID
							FROM tbl_registed_course
							WHERE courseID=$coures_id_list_val
							AND term='$term_set'
							AND year='$year_set'
						)
					)
					";
		$this->select();
		$this->setRows();	
		$num_of_i_final=$this->rows[0]['num_of_i_final'];

		if ($num_of_i_final>0) {
			$final_status=-1;
		}
		$this->sql ="SELECT  *
					FROM tbl_final_exam_score 
					WHERE stdID='$std_ID'
					AND course_teachingID in(
						SELECT DataID
						FROM tbl_registed_course_teaching
						WHERE registed_courseID in(
							SELECT DataID
							FROM tbl_registed_course
							WHERE courseID=$coures_id_list_val
							AND term='$term_set'
							AND year='$year_set'
						)
					)
					";
		$this->select();
		$this->setRows();	
		$final_exam_score=$this->rows[0]['score'];
		if ($mid_status==-1 || $final_status==-1) {
			$total='i';
		}else{
			$total=$mid_exam_score+$final_exam_score;
		}
		return $total;
	}
	public function get_grade($score_exam,$score_pick){
		$total=$score_exam+$score_pick;
		if ($total<50) {
			$grade='0.0';
		}elseif($total<55){
			$grade='1.0';
		}elseif($total<60){
			$grade='1.5';
		}elseif($total<65){
			$grade='2.0';
		}elseif($total<70){
			$grade='2.5';
		}elseif($total<75){
			$grade='3.0';
		}elseif($total<80){
			$grade='3.5';
		}elseif($total>=80){
			$grade='4.0';
		}
		return $grade;
	}
	public function get_registed_course_id($coures_id_list){
		$this->sql ="SELECT  *
					FROM tbl_set_term_year 			
							";
		$this->select();
		$this->setRows();
		$term_set=$this->rows[0]['term'];
		$year_set=$this->rows[0]['year'];
		/*$this->sql ="SELECT  *
					FROM tbl_add_delete_course 	
					WHERE DataID=$coures_id_list
					AND DataID in(
                    	SELECT courseID
                        FROM tbl_registed_course 
                        WHERE term='$term_set'  
                        OR term='1,2'
                        AND year='$year_set'
                         AND DataID IN(
                            SELECT registed_courseID
                        	FROM tbl_registed_course_teaching
                        )
                    )
					";
		$this->select();
		$this->setRows();	*/
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 	
					WHERE DataID=$coures_id_list
					
					";
		$this->select();
		$this->setRows();	
		$class_level_data=$this->rows[0]['class_level'];
		$status=$this->rows[0]['status'];		
		if ($class_level_data=='p1' || $class_level_data=='p2' || $class_level_data=='p3' || $class_level_data=='p4' || $class_level_data=='p5' || $class_level_data=='p6' ) {
			$term_set='1,2';
		}

		$this->sql ="SELECT  *
					FROM tbl_registed_course_teaching 	
					WHERE registed_courseID in(
						SELECT DataID
						FROM tbl_registed_course 
						WHERE term='$term_set'
						AND year='$year_set'
						AND courseID=$coures_id_list
					)
					";
		$this->select();
		$this->setRows();
		return $this->rows[0]['DataID'];	
	}
	public function get_class_level_status($coures_id_list_val){
		$data_response = array();	
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 	
					WHERE DataID=$coures_id_list_val
					";
		$this->select();
		$this->setRows();		
		$class_level=$this->rows[0]['class_level'];	
		$data_response['status']=$this->rows[0]['status'];	
		if ($class_level=='p1' || $class_level=='p2' || $class_level=='p3' || $class_level=='p4' || $class_level=='p5' || $class_level=='p6') {
			$data_response['class_data']='p';
		}else{
			$data_response['class_data']='m';
		}
		return $data_response;
	}
	public function get_score_attend_class($std_ID,$coures_id_list_val,$room_search){
		$registed_courseID=$this->get_registed_courseID($coures_id_list_val);
		$registed_course_teaching_id=$this->get_registed_course_id($coures_id_list_val);
		$this->sql ="SELECT  status
					FROM tbl_add_delete_course 	
					WHERE DataID=$coures_id_list_val
					";
		$this->select();
		$this->setRows();
		$status=$this->rows[0]['status'];

		$this->sql ="SELECT COUNT(course_teaching_std_id) as sum_no_come
					FROM tbl_attend_class_std 
					WHERE course_teaching_std_id IN(
						SELECT DataID
						FROM tbl_course_teaching_std
						WHERE registed_courseID=$registed_courseID
						AND stdID='$std_ID'
					)	
					AND set_attend_day_id IN(
						SELECT DataID
						FROM tbl_set_attend_day
						WHERE registed_course_teachingID IN(
							SELECT DataID
							FROM tbl_registed_course_teaching
							WHERE registed_courseID=$registed_courseID
						)
					)
					";
		$this->select();
		$this->setRows();	
		$sum_no_come=$this->rows[0]['sum_no_come'];
		
		$registed_course_teaching_id=$this->get_registed_course_id($coures_id_list_val);
		$class_level_status=$this->get_class_level_status($coures_id_list_val);
		if ($class_level_status['status']==1) {
			$condition="AND room='$room_search'";
		}else{
			$condition="";
		}
		$this->sql ="SELECT  SUM(hr) as num_hr
					FROM tbl_set_attend_day 	
					WHERE registed_course_teachingID=$registed_course_teaching_id
					$condition
					";
		$this->select();
		$this->setRows();
		$num_hr=$this->rows[0]['num_hr'];	
		
		if ($class_level_status['class_data']=='p') {
			$week_all=40;
		}else{
			$week_all=20;
		}
		$total_day=$num_hr*$week_all;
		$total_attend_per=round((($total_day-$sum_no_come)*100)/$total_day);

		if ($total_attend_per>=80) {
			$find_80_per='pass';
		}else{
			$find_80_per='nopass';
		}
		/*
		$this->sql ="SELECT *
					FROM tbl_set_count_adttend_class 
					WHERE registed_courseID=$registed_courseID		
					";
		$this->select();
		$this->setRows();	
		$week_name=$this->rows[0]['week_name'];

		$this->sql ="SELECT  SUM(score_status) as sum_score
					FROM tbl_attend_class 
					WHERE week BETWEEN 1 AND $week_name
					AND course_teaching_stdID in(
						SELECT DataID
						FROM tbl_course_teaching_std
						WHERE registed_courseID=$registed_courseID
						AND stdID='$std_ID'
					)					
					";
		$this->select();
		$this->setRows();	
		$sum_score=$this->rows[0]['sum_score'];
		$data_must_pass=floor((80*$week_name)/100);
		if ($sum_score>=$data_must_pass) {
			$find_80_per='pass';
		}else{
			$find_80_per='nopass';
		}*/
		return $find_80_per;
	}
	public function get_desirable_number($std_ID,$coures_id_list_val){
		$registed_courseID=$this->get_registed_courseID($coures_id_list_val);
		$score_total=0;
		for ($i=1; $i <= 8 ; $i++) { 
				$this->sql ="SELECT  *
					FROM tbl_desirable_$i 
					WHERE stdID='$std_ID'
					AND course_teachingID in(
						SELECT DataID
						FROM tbl_registed_course_teaching 	
						WHERE registed_courseID=$registed_courseID
					)
					";
			$this->select();
			$this->setRows();
			$score=$this->rows[0]['score'];
			$score_total=$score_total+$score;
		}	
		$evaluation_score=number_format($score_total/8,1);
		return $evaluation_score;
	}
	public function get_desirable($std_ID,$coures_id_list_val){
		$registed_courseID=$this->get_registed_courseID($coures_id_list_val);
		$score_total=0;
		for ($i=1; $i <= 8 ; $i++) { 
				$this->sql ="SELECT  *
					FROM tbl_desirable_$i 
					WHERE stdID='$std_ID'
					AND course_teachingID in(
						SELECT DataID
						FROM tbl_registed_course_teaching 	
						WHERE registed_courseID=$registed_courseID
					)
					";
			$this->select();
			$this->setRows();
			$score=$this->rows[0]['score'];
			$score_total=$score_total+$score;
			}	
			$evaluation_score=$score_total/8;
			if ($evaluation_score<1) {
				$data='nopass';
			}elseif($evaluation_score<1.5){
				$data='pass';
			}elseif($evaluation_score<2.5){
				$data='good';
			}elseif($evaluation_score>=2.5){
				$data='verygood';
			}
		return $data;
	}
	public function get_read_think_write_number($std_ID,$coures_id_list_val){
		$registed_courseID=$this->get_registed_courseID($coures_id_list_val);
		$score_total=0;

		$score_read=0;
		$score_think=0;
		$score_write=0;
		$this->sql ="SELECT  *
					FROM tbl_read_score
					WHERE stdID='$std_ID'
					AND course_teachingID in(
						SELECT DataID
						FROM tbl_registed_course_teaching 	
						WHERE registed_courseID=$registed_courseID
					)
					";
		$this->select();
		$this->setRows();
		$score_read=$this->rows[0]['score'];

		$this->sql ="SELECT  *
					FROM tbl_think_score
					WHERE stdID='$std_ID'
					AND course_teachingID in(
						SELECT DataID
						FROM tbl_registed_course_teaching 	
						WHERE registed_courseID=$registed_courseID
					)
					";
		$this->select();
		$this->setRows();
		$score_think=$this->rows[0]['score'];

		$this->sql ="SELECT  *
					FROM tbl_write_score
					WHERE stdID='$std_ID'
					AND course_teachingID in(
						SELECT DataID
						FROM tbl_registed_course_teaching 	
						WHERE registed_courseID=$registed_courseID
					)
					";
		$this->select();
		$this->setRows();
		$score_write=$this->rows[0]['score'];

		$this->sql ="SELECT  *
					FROM tbl_rtw_4_score
					WHERE stdID='$std_ID'
					AND course_teachingID in(
						SELECT DataID
						FROM tbl_registed_course_teaching 	
						WHERE registed_courseID=$registed_courseID
					)
					";
		$this->select();
		$this->setRows();
		$score_rtw_4=$this->rows[0]['score'];

		$this->sql ="SELECT  *
					FROM tbl_rtw_5_score
					WHERE stdID='$std_ID'
					AND course_teachingID in(
						SELECT DataID
						FROM tbl_registed_course_teaching 	
						WHERE registed_courseID=$registed_courseID
					)
					";
		$this->select();
		$this->setRows();
		$score_rtw_5=$this->rows[0]['score'];


		$score_total=number_format(($score_read+$score_think+$score_write+$score_rtw_4+$score_rtw_5)/5,1);
		return $score_total;
	}
	public function get_read_think_write($std_ID,$coures_id_list_val){
		$registed_courseID=$this->get_registed_courseID($coures_id_list_val);
		$score_total=0;

		$score_read=0;
		$score_think=0;
		$score_write=0;
		$this->sql ="SELECT  *
					FROM tbl_read_score
					WHERE stdID='$std_ID'
					AND course_teachingID in(
						SELECT DataID
						FROM tbl_registed_course_teaching 	
						WHERE registed_courseID=$registed_courseID
					)
					";
		$this->select();
		$this->setRows();
		$score_read=$this->rows[0]['score'];

		$this->sql ="SELECT  *
					FROM tbl_think_score
					WHERE stdID='$std_ID'
					AND course_teachingID in(
						SELECT DataID
						FROM tbl_registed_course_teaching 	
						WHERE registed_courseID=$registed_courseID
					)
					";
		$this->select();
		$this->setRows();
		$score_think=$this->rows[0]['score'];

		$this->sql ="SELECT  *
					FROM tbl_write_score
					WHERE stdID='$std_ID'
					AND course_teachingID in(
						SELECT DataID
						FROM tbl_registed_course_teaching 	
						WHERE registed_courseID=$registed_courseID
					)
					";
		$this->select();
		$this->setRows();
		$score_write=$this->rows[0]['score'];

		$this->sql ="SELECT  *
					FROM tbl_rtw_4_score
					WHERE stdID='$std_ID'
					AND course_teachingID in(
						SELECT DataID
						FROM tbl_registed_course_teaching 	
						WHERE registed_courseID=$registed_courseID
					)
					";
		$this->select();
		$this->setRows();
		$score_rtw_4=$this->rows[0]['score'];

		$this->sql ="SELECT  *
					FROM tbl_rtw_5_score
					WHERE stdID='$std_ID'
					AND course_teachingID in(
						SELECT DataID
						FROM tbl_registed_course_teaching 	
						WHERE registed_courseID=$registed_courseID
					)
					";
		$this->select();
		$this->setRows();
		$score_rtw_5=$this->rows[0]['score'];


		$score_total=($score_read+$score_think+$score_write+$score_rtw_4+$score_rtw_5)/5;
			if ($score_total<1) {
				$data='nopass';
			}elseif($score_total<1.5){
				$data='pass';
			}elseif($score_total<2.5){
				$data='good';
			}elseif($score_total>=2.5){
				$data='verygood';
			}
		return $data;
	}

	public function get_propotion_total($coures_id_list_val){
		$data_response = array();	
		$this->sql ="SELECT  *
					FROM tbl_proportion 			
					WHERE courseID=$coures_id_list_val";
		$this->select();
		$this->setRows();
		$data_response['cumulative_before_mid']=$this->rows[0]['cumulative_before_mid'];
		$data_response['cumulative_after_mid']=$this->rows[0]['cumulative_after_mid'];
		
		$data_response['mid_exam']=$this->rows[0]['mid_exam'];
		$data_response['final_exam']=$this->rows[0]['final_exam'];
		$mid_exam=$this->rows[0]['mid_exam'];
		$final_exam=$this->rows[0]['final_exam'];
		$data_response['total']=$mid_exam+$final_exam;
		return $data_response;
	}
	public function get_comulative_score($std_ID,$coures_id_list_val){
		$data_response = array();	
		$registed_courseID=$this->get_registed_courseID($coures_id_list_val);
		$this->sql ="SELECT  SUM(score) as sum_score_total_before
					FROM tbl_objective_score_std 			
					WHERE registed_courseID=$registed_courseID
					AND staID='$std_ID'
					AND objectiveID IN(
						SELECT DataID
						FROM tbl_objective_conclude
						WHERE proportion_status=1
					)
					";

		$this->select();
		$this->setRows();
		$data_response['sum_score_total_before']=$this->rows[0]['sum_score_total_before'];

		$this->sql ="SELECT  SUM(score) as sum_score_total_after
					FROM tbl_objective_score_std 			
					WHERE registed_courseID=$registed_courseID
					AND staID='$std_ID'
					AND objectiveID IN(
						SELECT DataID
						FROM tbl_objective_conclude
						WHERE proportion_status=2
					)
					";

		$this->select();
		$this->setRows();
		$data_response['sum_score_total_after']=$this->rows[0]['sum_score_total_after'];
		return $data_response;
	}
	public function get_mid_exam_score($std_ID,$coures_id_list_val){
		$registed_courseID=$this->get_registed_courseID($coures_id_list_val);
		$this->sql ="SELECT  *
					FROM tbl_mid_exam_score 			
					WHERE stdID='$std_ID'
					AND course_teachingID in(
						SELECT DataID
						FROM tbl_registed_course_teaching
						WHERE registed_courseID=$registed_courseID
					)
					";

		$this->select();
		$this->setRows();
		return $this->rows[0]['score'];
	}
	public function get_final_exam_score($std_ID,$coures_id_list_val){
		$registed_courseID=$this->get_registed_courseID($coures_id_list_val);
		$this->sql ="SELECT  *
					FROM tbl_final_exam_score 			
					WHERE stdID='$std_ID'
					AND course_teachingID in(
						SELECT DataID
						FROM tbl_registed_course_teaching
						WHERE registed_courseID=$registed_courseID
					)
					";

		$this->select();
		$this->setRows();
		return $this->rows[0]['score'];
	}
	public function un_export($data_id,$data_term,$data_year,$data_room,$data_class){
		$this->sql ="SELECT status
					FROM tbl_add_delete_course 
					WHERE DataID=$data_id
					";
		$this->select();
		$this->setRows();	
		$status=$this->rows[0]['status'];
		if ($status==2) {
			$condition_sql_1="";
		}else{
			$condition_sql_1="AND room='$data_room'";
		}

		$this->sql = "
					  DELETE FROM tbl_sub_pp6 
					  WHERE sub_ID=$data_id
					  AND pp6_ID in(
					  	SELECT DataID
					  	FROM tbl_pp6
					  	WHERE term='$data_term'
					 	AND year='$data_year'
					  	AND class_level='$data_class'
					  	$condition_sql_1
					  )

					  ";
		$this->query();

		if ($status==2) {
			$condition_sql_2="WHERE room='0' ";
		}else{
			$condition_sql_2="WHERE room='$data_room' ";
		}
		
		$this->sql = " UPDATE tbl_room_export SET status=1  
					   $condition_sql_2
					   AND registed_courseID in(
					   		SELECT DataID
					   		FROM tbl_registed_course
					   		WHERE courseID=$data_id
					   		AND term='$data_term'
					 		AND year='$data_year'
					   )  	 			  
					  ";
		$this->query();
		return json_encode(1);
	}	
	public function export_data($data_val,$data_term_set){
		$data_response = array();	
		$arr_id = explode(",", $data_val);
		for ($i=0; $i < count($arr_id) ; $i++) { 
			$divider=explode("-", $arr_id[$i]);
			$data_func.=$this->export_data_func($divider[0],$divider[1],$divider[2]);
		}
		return $data_func;
	}
	public function export_data_func($coures_id_list_val,$room_search,$room_exportID){
		$ss_status=$_SESSION['ss_status'];
		$cdate = date("Y-m-d");
		if ($ss_status==2){
			$this->sql = " UPDATE tbl_room_export SET status=0 ,sended_status=1 ,cdate='$cdate'
					   WHERE DataID=$room_exportID			     
					  ";
			$this->query();
		}
		$this->sql ="SELECT class_level,status
					FROM tbl_add_delete_course 
					WHERE DataID=$coures_id_list_val
							
					";
		$this->select();
		$this->setRows();	
		$status=$this->rows[0]['status'];
		$class_level=$this->rows[0]['class_level'];
		if ($status==1) {
			$condition="WHERE room='$room_search' AND";
		}else{
			$condition="WHERE";
		}
		$this->sql ="SELECT  *
					FROM tbl_set_term_year 			
							";
		$this->select();
		$this->setRows();
		$term_set=$this->rows[0]['term'];
		$year_set=$this->rows[0]['year'];
		if ($class_level=='p1' || $class_level=='p2' || $class_level=='p3' || $class_level=='p4' || $class_level=='p5' || $class_level=='p6') {
				$term_set='1,2';
			}
		$registed_courseID=$this->get_registed_courseID($coures_id_list_val);
		$this->sql ="SELECT  COUNT(*) as num_row_room
					FROM tbl_room_export
					WHERE registed_courseID=$registed_courseID
					AND room=$room_search	
					";
		$this->select();
		$this->setRows();	
		$num_row_room=$this->rows[0]['num_row_room'];
		if ($num_row_room==0) {
			$this->sql = "INSERT INTO tbl_room_export(registed_courseID,room,cdate) VALUES ($registed_courseID,$room_search,'$cdate')";
			$this->query();
		}
		$this->sql ="SELECT  *
					FROM tbl_student
					$condition
					std_ID in(
						SELECT stdID
						FROM tbl_course_teaching_std
						WHERE registed_courseID =$registed_courseID
					)			
					";
		$this->select();
		$this->setRows();	
		$data_i=0;
		$data_atte=0;
		$data_00=0;
		$data_10=0;
		$data_15=0;
		$data_20=0;
		$data_25=0;
		$data_30=0;
		$data_35=0;
		$data_40=0;

		$data_desirable_nopass=0;
		$data_desirable_pass=0;
		$data_desirable_good=0;
		$data_desirable_verygood=0;

		$data_read_think_write_nopass=0;
		$data_read_think_write_pass=0;
		$data_read_think_write_good=0;
		$data_read_think_write_verygood=0;

		foreach($this->rows as $key => $value) {
			$std_ID=$value['std_ID'];
			$card_ID=$value['card_ID'];
			
			$name_title_data=$value['name_title'];
			$name_title=$this->get_name_title($name_title_data);
			$fname=$value['fname'];
			$lname=$value['lname'];
			$class_level=$value['class_level'];
			$room=$value['room'];

			$comulative_score=$this->get_comulative_score($std_ID,$coures_id_list_val);
			$mid_exam_score=$this->get_mid_exam_score($std_ID,$coures_id_list_val);
			$final_exam_score=$this->get_final_exam_score($std_ID,$coures_id_list_val);

			$total_before_mide=$comulative_score['sum_score_total_before']+$mid_exam_score;//mid
			$total_after_mide=$comulative_score['sum_score_total_after']+$final_exam_score;//afer_mid
			$total_score_data=$total_before_mide+$total_after_mide;//total
			
			$score_exam=$this->get_score_exam($std_ID,$coures_id_list_val);		
			$score_pick=$this->get_score_pick($std_ID,$coures_id_list_val);	
			$score_attend_class=$this->get_score_attend_class($std_ID,$coures_id_list_val,$room_search);	

			if($score_exam=='i' || $score_pick=='i'){
				$total_score_data=-1;
			}
			if($score_attend_class=='nopass'){
				$score_attend=-1;
			}else{
				$score_attend=1;
			}

		$desirable=$this->get_desirable_number($std_ID,$coures_id_list_val);//score_desirable	
		$read_think_write=$this->get_read_think_write_number($std_ID,$coures_id_list_val);//score_rtw
		

		$this->sql ="SELECT  COUNT(*) as number_std,DataID as pp6_id
					FROM tbl_pp6 	
					WHERE std_ID='$std_ID'	
					AND term='$term_set'
					AND year='$year_set'
							";
		$this->select();
		$this->setRows();
		$number_std=$this->rows[0]['number_std'];
		if($number_std>0){
			$new_id=$this->rows[0]['pp6_id'];
		}else{		
			$this->sql = "INSERT INTO tbl_pp6(std_ID,card_ID,name_title,fname,lname,class_level,room,term,year) VALUES ('$std_ID','$card_ID','$name_title_data','$fname','$lname','$class_level','$room','$term_set','$year_set')";
			$this->query();
			$new_id = $this->insertID();
		}
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 
					WHERE DataID=$coures_id_list_val
					
					";
		$this->select();
		$this->setRows();	
		$courseID_in=$this->rows[0]['courseID'];
		$name_in=$this->rows[0]['name'];
		$unit_in=$this->rows[0]['unit'];
		$department_in=$this->rows[0]['department'];
		$status_in=$this->rows[0]['status'];
		$status_form_in=$this->rows[0]['status_form'];

		$this->sql = "INSERT INTO tbl_sub_pp6(pp6_ID,sub_ID,courseID,name,unit,department,status,status_form,score_mid,score_final,score_total,score_desirable,score_rtw,score_attend) 
			VALUES ($new_id,$coures_id_list_val,'$courseID_in','$name_in',$unit_in,'$department_in',$status_in,$status_form_in,$total_before_mide,$total_after_mide,$total_score_data,$desirable,$read_think_write,$score_attend)";
		$this->query();
		}

		return $room_search;
	}
	public function get_grade_summary($coures_id_list_val,$room_search){
		$data_response = array();	
		$registed_courseID=$this->get_registed_courseID($coures_id_list_val);
		$this->sql ="SELECT  count(*) as num_row_std
					FROM tbl_student 
					WHERE room='$room_search'
					AND std_ID in(
						SELECT stdID
						FROM tbl_course_teaching_std
						WHERE registed_courseID =$registed_courseID
					)
					";
		$this->select();
		$this->setRows();	
		$data_response['num_all_std']=$this->rows[0]['num_row_std'];	
		$this->sql ="SELECT  *
					FROM tbl_student 
					WHERE room='$room_search'
					AND std_ID in(
						SELECT stdID
						FROM tbl_course_teaching_std
						WHERE registed_courseID =$registed_courseID
					)
					ORDER BY 
					CASE
						WHEN name_title LIKE '%dekchai%' THEN 0
				        WHEN name_title LIKE '%nai%' THEN 1
				        WHEN name_title LIKE '%dekying%' THEN 2
				        WHEN name_title LIKE '%nangsaw%'THEN 3
				        WHEN std_ID THEN 4      
				    END
					";
		$this->select();
		$this->setRows();	
		$data_i=0;
		$data_atte=0;
		$data_00=0;
		$data_10=0;
		$data_15=0;
		$data_20=0;
		$data_25=0;
		$data_30=0;
		$data_35=0;
		$data_40=0;

		$data_desirable_nopass=0;
		$data_desirable_pass=0;
		$data_desirable_good=0;
		$data_desirable_verygood=0;

		$data_read_think_write_nopass=0;
		$data_read_think_write_pass=0;
		$data_read_think_write_good=0;
		$data_read_think_write_verygood=0;

		$number=1;
		foreach($this->rows as $key => $value) {
			$std_ID=$value['std_ID'];
			$name_title_data=$value['name_title'];
			$name_title=$this->get_name_title($name_title_data);
			$fname=$value['fname'];
			$lname=$value['lname'];

			$comulative_score=$this->get_comulative_score($std_ID,$coures_id_list_val);
			$mid_exam_score=$this->get_mid_exam_score($std_ID,$coures_id_list_val);
			$final_exam_score=$this->get_final_exam_score($std_ID,$coures_id_list_val);
			$total_score_std=$comulative_score['sum_score_total_before']+$comulative_score['sum_score_total_after']+$mid_exam_score+$final_exam_score;
			$comulative_score_sum=$comulative_score['sum_score_total_before']+$comulative_score['sum_score_total_after'];
			$score_exam=$mid_exam_score+$final_exam_score;
			$grade_data=$this->get_grade($score_exam,$comulative_score_sum);

			$data_response['std_list'].='
					 <tr>
                  		<td>'.$number.'</td>
                  		<td style="text-align:left;padding-left:4%;">'.$name_title.$fname.' '.$lname.'</td>
                  		<td>'.$comulative_score['sum_score_total_before'].'</td>                		
                  		<td>'.$mid_exam_score.'</td>
                  		<td>'.$comulative_score['sum_score_total_after'].'</td>
                  		<td>'.$final_exam_score.'</td>
                 		<td>'.$total_score_std.'</td>
                  		<td>'.$grade_data.'</td>
                </tr>
			';
			$score_exam=$this->get_score_exam($std_ID,$coures_id_list_val);		
			$score_pick=$this->get_score_pick($std_ID,$coures_id_list_val);	
			$score_attend_class=$this->get_score_attend_class($std_ID,$coures_id_list_val,$room_search);	
			//$data_response['score_attend_class']=$score_attend_class;
			if ($score_exam=='i' || $score_pick=='i' || $score_attend_class=='nopass') {
				if ($score_exam=='i' || $score_pick=='i') {
					$data_i++;
				}
				if ($score_attend_class=='nopass') {
					$data_atte++;
				}
				
			}else{
				$grade=$this->get_grade($score_exam,$score_pick);	
				$data_response['exam'].=$grade.'-';
				if ($grade=='0.0') {
					$data_00++;
				}elseif($grade=='1.0'){
					$data_10++;
				}elseif($grade=='1.5'){
					$data_15++;
				}elseif($grade=='2.0'){
					$data_20++;
				}elseif($grade=='2.5'){
					$data_25++;
				}elseif($grade=='3.0'){
					$data_30++;
				}elseif($grade=='3.5'){
					$data_35++;
				}elseif($grade=='4.0'){
					$data_40++;
				}		
			}	

		$desirable=$this->get_desirable($std_ID,$coures_id_list_val);	
			if ($desirable=='nopass') {
				$data_desirable_nopass++;
			}elseif($desirable=='pass'){
				$data_desirable_pass++;
			}elseif($desirable=='good'){
				$data_desirable_good++;
			}elseif($desirable=='verygood'){
				$data_desirable_verygood++;
			}
		$read_think_write=$this->get_read_think_write($std_ID,$coures_id_list_val);
			if ($read_think_write=='nopass') {
				$data_read_think_write_nopass++;
			}elseif($read_think_write=='pass'){
				$data_read_think_write_pass++;
			}elseif($read_think_write=='good'){
				$data_read_think_write_good++;
			}elseif($read_think_write=='verygood'){
				$data_read_think_write_verygood++;
			}
		$number++;
		}
		$data_response['data_read_think_write_nopass']=$data_read_think_write_nopass;
		$data_response['data_read_think_write_pass']=$data_read_think_write_pass;
		$data_response['data_read_think_write_good']=$data_read_think_write_good;
		$data_response['data_read_think_write_verygood']=$data_read_think_write_verygood;

		$data_response['data_desirable_nopass']=$data_desirable_nopass;
		$data_response['data_desirable_pass']=$data_desirable_pass;
		$data_response['data_desirable_good']=$data_desirable_good;
		$data_response['data_desirable_verygood']=$data_desirable_verygood;

		$data_response['data_i']=$data_i;
		$data_response['data_atte']=$data_atte;
		
		$data_response['data_00']=$data_00;
		$data_response['data_10']=$data_10;
		$data_response['data_15']=$data_15;
		$data_response['data_20']=$data_20;
		$data_response['data_25']=$data_25;
		$data_response['data_30']=$data_30;
		$data_response['data_35']=$data_35;
		$data_response['data_40']=$data_40;

		$propotion_total=$this->get_propotion_total($coures_id_list_val);
		
		$comulative_before_mid_title=$propotion_total['cumulative_before_mid'];
		$comulative_after_mid_title=$propotion_total['cumulative_after_mid'];
		$mid_exam_title=$propotion_total['mid_exam'];
		$final_exam_title=$propotion_total['final_exam'];

		$data_response['total_title']=$comulative_before_mid_title+$comulative_after_mid_title+$mid_exam_title+$final_exam_title;
		$data_response['comulative_before_mid_title']=$comulative_before_mid_title;
		$data_response['comulative_after_mid_title']=$comulative_after_mid_title;
		$data_response['mid_exam_title']=$mid_exam_title;
		$data_response['final_exam_title']=$final_exam_title;
		echo json_encode($data_response);
	}
	public function search_course_detail($coures_id_list,$room_search){
		$data_response = array();	
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 	
					WHERE DataID=$coures_id_list
					";
		$this->select();
		$this->setRows();		
		$data_response['courseID']=$this->rows[0]['courseID'];	
		$data_response['name']=$this->rows[0]['name'];	
		$data_response['unit']=$this->rows[0]['unit'];	
		$data_response['hr_learn']=$this->rows[0]['hr_learn'];	
		$data_response['status']=$this->rows[0]['status'];	
		$class_level_data=$this->rows[0]['class_level'];
		$class_level=$this->get_class_level_new($class_level_data);
		$data_response['class_level']=$class_level_data;
		$data_response['class_level_co']=$class_level.'/'.$room_search;
		return json_encode($data_response);
	}
	public function get_class_level($coures_id_list_val){
		$this->sql ="SELECT  *
					FROM tbl_set_term_year 			
							";
		$this->select();
		$this->setRows();
		$term_set=$this->rows[0]['term'];
		$year_set=$this->rows[0]['year'];
		$data_response = array();	
		/*$this->sql ="SELECT  *
					FROM tbl_add_delete_course 	
					WHERE DataID=$coures_id_list_val
					AND DataID in(
                    	SELECT courseID
                        FROM tbl_registed_course 
                        WHERE term='$term_set'  
                        OR term='1,2'
                        AND year='$year_set'
                         AND DataID IN(
                            SELECT registed_courseID
                        	FROM tbl_registed_course_teaching
                        )
                    )
					";
		$this->select();
		$this->setRows();	*/	
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 	
					WHERE DataID=$coures_id_list_val
					
					";
		$this->select();
		$this->setRows();
		$class_level_data=$this->rows[0]['class_level'];	
		$status=$this->rows[0]['status'];
		$data_response['status']=$status;
		$data_response['class_level']=$this->get_class_level_new($class_level_data);
		if ($class_level_data=='p1' || $class_level_data=='p2' || $class_level_data=='p3' || $class_level_data=='p4' || $class_level_data=='p5' || $class_level_data=='p6' ) {
			$term_set='1,2';
		}

		$this->sql ="SELECT distinct room
						FROM tbl_student 
						WHERE std_ID in(
							SELECT stdID
							FROM tbl_course_teaching_std
							WHERE registed_courseID in(
								SELECT DataID
								FROM tbl_registed_course
								WHERE courseID=$coures_id_list_val
                                AND term='$term_set'
                                AND year='$year_set'
								)
						)
						ORDER BY room ASC
							";
			$this->select();
			$this->setRows();
			foreach($this->rows as $key => $value) {
				$room=$value['room'];
				$data_response['room'].=' <option>'.$room.'</option>';
			}
		return json_encode($data_response);
	}
	public function get_data_dicision_edit($DataID,$courseID_long,$class_level,$name,$term_set,$year_set,$status,$room_export){
		if ($class_level=='p1' || $class_level=='p2' || $class_level=='p3' || $class_level=='p4' || $class_level=='p5' || $class_level=='p6' ) {
			$term_set='1,2';
		}
		$class_level_new=$this->get_class_level_new($class_level);
		if ($status==1) {
			$this->sql ="SELECT distinct room
						FROM tbl_student 
						WHERE std_ID in(
							SELECT stdID
							FROM tbl_course_teaching_std
							WHERE registed_courseID in(
								SELECT DataID
								FROM tbl_registed_course
								WHERE courseID=$DataID
	                            AND term='$term_set'
	                            AND year='$year_set'
								)
						)
						ORDER BY room ASC
							";
			$this->select();
			$this->setRows();
			foreach($this->rows as $key => $value) {		
				$room=$value['room'];
				$find_in_pp6=$this->find_in_pp6($DataID,$room,$term_set,$year_set);
				if ($find_in_pp6!=0) {		
					$data_response.='
								<tr>
	                                  <td style="text-align:center;">      
	                                          
	                                  </td>
	                                  <td>'.$courseID_long.'</td>
	                                  <td><a style="color:#000;text-decoration-line: underline;" href="index.php?op=summary-view&id='.$DataID.'&room='.$room.'">'.$name.'</a></td>
	                                  <td style="text-align: center;">'.$class_level_new.'</td>
	                                  <td style="text-align: center;">'.$room.'</td>
	                                  <td style="text-align: center;">
	                                  	<div class="btn_un_export" data-term="'.$term_set.'" data-room='.$room.'  data-class='.$class_level.' data-year="'.$year_set.'" data-id="'.$DataID.'"  aria-hidden="true" data-toggle="modal" data-target="#modalCancelUnExport">
	                                      <span class="glyphicon glyphicon-refresh edit-icon-table"></span>
	                                    </div>

	                                  </td>
	                                  
	                                </tr>

					';
				}
				
			}
		}else{
			$data_response.='
								<tr>
	                                  <td style="text-align:center;">      
	                                          
	                                  </td>
	                                  <td>'.$courseID_long.'</td>
	                                  <td><a style="color:#000;text-decoration-line: underline;" href="index.php?op=summary-view&id='.$DataID.'&room=0">'.$name.'</a></td>
	                                  <td style="text-align: center;">'.$class_level_new.'</td>
	                                  <td style="text-align: center;">-</td>
	                                  <td style="text-align: center;">
	                                  	<div class="btn_un_export" data-term="'.$term_set.'" data-room="0"  data-class='.$class_level.' data-year="'.$year_set.'" data-id="'.$DataID.'"  aria-hidden="true" data-toggle="modal" data-target="#modalCancelUnExport">
	                                      <span class="glyphicon glyphicon-refresh edit-icon-table"></span>
	                                    </div>

	                                  </td>
	                                  
	                                </tr>

					';
		}
		
			
		return $data_response;
			
	}
	public function get_data_dicision_added($DataID,$courseID_long,$class_level,$name,$status){
		$this->sql ="SELECT  *
					FROM tbl_set_term_year 			
							";
		$this->select();
		$this->setRows();
		$term_set=$this->rows[0]['term'];
		$year_set=$this->rows[0]['year'];
		
		if ($class_level=='p1' || $class_level=='p2' || $class_level=='p3' || $class_level=='p4' || $class_level=='p5' || $class_level=='p6' ) {
			$term_set='1,2';
		}
		$ss_status=$_SESSION['ss_status'];
		if ($ss_status==2) {
			$condition_sql="				
			";
			$condition_date='
				<td style="text-align: center;">'.$find_in_pp6['cdate'].'</td>
				'
			;
		}else{
			$condition_sql="
					AND term='$term_set'
                    AND year='$year_set'
			";
		}
		$class_level_new=$this->get_class_level_new($class_level);
		if ($status==1) {
			$this->sql ="SELECT distinct room
						FROM tbl_student 
						WHERE std_ID in(
							SELECT stdID
							FROM tbl_course_teaching_std
							WHERE registed_courseID in(
								SELECT DataID
								FROM tbl_registed_course
								WHERE courseID=$DataID
								$condition_sql
								)
						)
						ORDER BY room ASC
							";
			$this->select();
			$this->setRows();
			foreach($this->rows as $key => $value) {		
				$room=$value['room'];
				$find_in_pp6=$this->find_in_pp6_added($DataID,$room,$term_set,$year_set);
				
				if ($find_in_pp6['num_row']>0) {	
					if ($ss_status==2) {
					
					$data_response.='
								<tr>
	                                  <td style="text-align:center;">                                                
	                                  </td>
	                                  <td>'.$courseID_long.'</td>
	                                  <td><a style="color:#000;text-decoration-line: underline;" href="index.php?op=summary-view&id='.$DataID.'&room='.$room.'">'.$name.'</a></td>
	                                  <td style="text-align: center;">'.$class_level_new.'</td>
	                                  <td style="text-align: center;">'.$room.'</td>
	                                  <td style="text-align: center;">'.$find_in_pp6['cdate'].'</td>
	                                </tr>
					';
					}else{
						$data_response.='
								<tr>
	                                  <td style="text-align:center;">                                                
	                                  </td>
	                                  <td>'.$courseID_long.'</td>
	                                  <td><a style="color:#000;text-decoration-line: underline;" href="index.php?op=summary-view&id='.$DataID.'&room='.$room.'">'.$name.'</a></td>
	                                  <td style="text-align: center;">'.$class_level_new.'</td>
	                                  <td style="text-align: center;">'.$room.'</td>
	                              
	                                </tr>
					';
					}
				}
				
			}
		}else{
			if ($ss_status==2) {
					$find_in_pp6=$this->find_in_pp6_added($DataID,0,$term_set,$year_set);
					$data_response.='
								<tr>
	                                  <td style="text-align:center;">                                                
	                                  </td>
	                                  <td>'.$courseID_long.'</td>
	                                  <td><a style="color:#000;text-decoration-line: underline;" href="index.php?op=summary-view&id='.$DataID.'">'.$name.'</a></td>
	                                  <td style="text-align: center;">'.$class_level_new.'</td>
	                                  <td style="text-align: center;">-</td>
	                                  <td style="text-align: center;">'.$find_in_pp6['cdate'].'</td>
	                                </tr>
					';
					}else{
						$data_response.='
								<tr>
	                                  <td style="text-align:center;">                                                
	                                  </td>
	                                  <td>'.$courseID_long.'</td>
	                                  <td><a style="color:#000;text-decoration-line: underline;" href="index.php?op=summary-view&id='.$DataID.'">'.$name.'</a></td>
	                                  <td style="text-align: center;">'.$class_level_new.'</td>
	                                  <td style="text-align: center;">-</td>
	                              
	                                </tr>
					';
					}
				}
		return $data_response;
	}
	public function get_data_dicision($DataID,$courseID_long,$class_level,$name,$status){
		$this->sql ="SELECT  *
					FROM tbl_set_term_year 			
							";
		$this->select();
		$this->setRows();
		$term_set=$this->rows[0]['term'];
		$year_set=$this->rows[0]['year'];

		if ($class_level=='p1' || $class_level=='p2' || $class_level=='p3' || $class_level=='p4' || $class_level=='p5' || $class_level=='p6' ) {
			$term_set='1,2';
		}
		$class_level_new=$this->get_class_level_new($class_level);
		if ($status==1) {
			$this->sql ="SELECT distinct room
						FROM tbl_student 
						WHERE std_ID in(
							SELECT stdID
							FROM tbl_course_teaching_std
							WHERE registed_courseID in(
								SELECT DataID
								FROM tbl_registed_course
								WHERE courseID=$DataID
	                            AND term='$term_set'
	                            AND year='$year_set'      
							)
						)
						ORDER BY room ASC
							";
			$this->select();
			$this->setRows();
			foreach($this->rows as $key => $value) {		
				$room=$value['room'];
				$find_in_pp6=$this->find_in_pp6_teacher($DataID,$room,$term_set,$year_set);
				if ($find_in_pp6==0) {
					$data_response.='
								<tr>
	                                  <td style="text-align:center;">      
	                                     <input class="checkbox_data" type="checkbox" value="'.$DataID.'-'.$room.'" name="checkbox_export[]" id="checkbox'.$DataID.'">         
	                                  </td>
	                                  <td>'.$courseID_long.'</td>
	                                  <td>	
	                                  	<a style="color:#000;text-decoration-line: underline;" href="index.php?op=summary-view&id='.$DataID.'&room='.$room.'">'.$name.'</a>
	                                  </td>
	                                  <td style="text-align: center;">'.$class_level_new.'</td>
	                                  <td style="text-align: center;">'.$room.'</td>
	                                </tr>

					';
				
				}		
				
			}
		}else{
			$data_response.='
								<tr>
	                                  <td style="text-align:center;">      
	                                     <input class="checkbox_data" type="checkbox" value="'.$DataID.'-0" name="checkbox_export[]" id="checkbox'.$DataID.'">         
	                                  </td>
	                                  <td>'.$courseID_long.'</td>
	                                  <td>	
	                                  	<a style="color:#000;text-decoration-line: underline;" href="index.php?op=summary-view&id='.$DataID.'">'.$name.'</a>
	                                  </td>
	                                  <td style="text-align: center;">'.$class_level_new.'</td>
	                                  <td style="text-align: center;">-</td>
	                                </tr>

					';
		}
			
		return $data_response;
	
			
	}
	public function get_data_dicision_admin($DataID,$courseID_long,$class_level,$name,$term_set,$year_set,$status){

		$class_level_new=$this->get_class_level_new($class_level);
		if ($status==1) {
			$this->sql ="SELECT distinct room
						FROM tbl_student 
						WHERE std_ID in(
							SELECT stdID
							FROM tbl_course_teaching_std
							WHERE registed_courseID in(
								SELECT DataID
								FROM tbl_registed_course
								WHERE courseID=$DataID
	                            AND term='$term_set'
	                            AND year='$year_set'      
							)
						)
						ORDER BY room ASC
							";
			$this->select();
			$this->setRows();
			foreach($this->rows as $key => $value) {		
				$room=$value['room'];
				$find_in_pp6=$this->find_in_pp6_admin($DataID,$room,$term_set,$year_set);
				if ($find_in_pp6['num_row']>0) {
					$data_response.='
								<tr>
	                                  <td style="text-align:center;">      
	                                     <input class="checkbox_data" type="checkbox" value="'.$DataID.'-'.$room.'-'.$find_in_pp6['room_export_ID'].'" name="checkbox_export[]" id="checkbox'.$DataID.'">         
	                                  </td>
	                                  <td>'.$courseID_long.'</td>
	                                  <td>	
	                                  	<a style="color:#000;text-decoration-line: underline;" href="index.php?op=summary-view&id='.$DataID.'&room='.$room.'">'.$name.'</a>
	                                  </td>
	                                  <td style="text-align: center;">'.$class_level_new.'</td>
	                                  <td style="text-align: center;">'.$room.'</td>
	                                </tr>

					';
				
				}		
				
			}

		}else{
				$find_in_pp6=$this->find_in_pp6_admin($DataID,0,$term_set,$year_set);
				$data_response.='
								<tr>
	                                  <td style="text-align:center;">      
	                                     <input class="checkbox_data" type="checkbox" value="'.$DataID.'-0-'.$find_in_pp6['room_export_ID'].'" name="checkbox_export[]" id="checkbox'.$DataID.'">         
	                                  </td>
	                                  <td>'.$courseID_long.'</td>
	                                  <td>	
	                                  	<a style="color:#000;text-decoration-line: underline;" href="index.php?op=summary-view&id='.$DataID.'">'.$name.'</a>
	                                  </td>
	                                  <td style="text-align: center;">'.$class_level_new.'</td>
	                                  <td style="text-align: center;">-</td>
	                                </tr>

					';
		}
			
		return $data_response;

			
	}
	public function find_in_pp6_admin($course_id,$room,$term_set,$year_set){
		$this->sql ="
					SELECT  COUNT(*) AS num_row,DataID as room_export_ID
					FROM tbl_room_export
					WHERE room=$room
					AND status=1
					AND registed_courseID in(
						SELECT DataID
						FROM tbl_registed_course
						WHERE year='$year_set'
						AND term='$term_set'
						AND courseID=$course_id
					)
							";
		$this->select();
		$this->setRows();
		$data_response['num_row']=$this->rows[0]['num_row'];
		$data_response['room_export_ID']=$this->rows[0]['room_export_ID'];
		return $data_response;
	}
	public function find_in_pp6_teacher($course_id,$room,$term_set,$year_set){
		$this->sql ="
					SELECT  COUNT(*) AS num_row
					FROM tbl_room_export
					WHERE room=$room
					AND registed_courseID in(
						SELECT DataID
						FROM tbl_registed_course
						WHERE year='$year_set'
						AND term='$term_set'
						AND courseID=$course_id
					)
							";
		$this->select();
		$this->setRows();
		return $this->rows[0]['num_row'];
	}
	public function find_in_pp6_added($course_id,$room,$term_set,$year_set){
		$ss_status=$_SESSION['ss_status'];
		$condition_1='';
		$condition_2='';
		if ($ss_status==2) {
			$condition_1="
					AND status=0
					AND sended_status=1								
			";
		}else{
			$condition_2="
					AND year='$year_set'
					AND term='$term_set'				
			";
		}
		$this->sql ="
					SELECT  COUNT(*) AS num_row,cdate
					FROM tbl_room_export
					WHERE room=$room
					$condition_1
					AND registed_courseID in(
						SELECT DataID
						FROM tbl_registed_course
						WHERE courseID=$course_id
						$condition_2				
					)
							";
		$this->select();
		$this->setRows();
		$cdate_data=$this->rows[0]['cdate'];
		$old_date_timestamp = strtotime($cdate_data);
		$cdate=date('d-m-Y', $old_date_timestamp);  

		$data_response['cdate']=$cdate;
		$data_response['num_row']=$this->rows[0]['num_row'];
		return $data_response;
	}
	public function find_in_pp6($course_id,$room,$term_set,$year_set){
		$this->sql ="
					SELECT  COUNT(*) AS num_row
					FROM tbl_pp6,tbl_sub_pp6
					WHERE tbl_pp6.DataID=tbl_sub_pp6.pp6_ID
					AND tbl_pp6.room='$room'
					AND tbl_sub_pp6.sub_ID=$course_id
					AND tbl_pp6.term='$term_set'
					AND tbl_pp6.year='$year_set'
							";
		$this->select();
		$this->setRows();
		return $this->rows[0]['num_row'];
	}
	public function get_year(){
		$this->sql ="SELECT  distinct(year) as year
					FROM tbl_pp6
					ORDER BY year DESC
							";
		$this->select();
		$this->setRows();
		foreach($this->rows as $key => $value) {
			$year=  $value['year'];	
			if($key==0){	
			$data_response.='
					 <option selected="selected" value="'.$year.'">'.$year.'</option>
			';
			}else{
				$data_response.='
					 <option  value="'.$year.'">'.$year.'</option>
			';
			}
			
		}
		return json_encode($data_response);
	}
	public function get_coures_id_list_edit($data_term_search,$data_year_search){
		$user_id=$_SESSION['ss_user_id'];
		$data_response = array();	
		
		$this->sql ="SELECT   DISTINCT(tbl_add_delete_course.DataID),tbl_add_delete_course.name,tbl_add_delete_course.courseID,tbl_add_delete_course.class_level,tbl_add_delete_course.status
					FROM tbl_add_delete_course,tbl_registed_course,tbl_sub_pp6
					WHERE tbl_registed_course.courseID=tbl_add_delete_course.DataID
					AND tbl_add_delete_course.DataID=tbl_sub_pp6.sub_ID
					AND tbl_registed_course.term='$data_term_search' 
					AND tbl_registed_course.year='$data_year_search'

							";
		$this->select();
		$this->setRows();
		foreach($this->rows as $key => $value) {
			$DataID=$value['DataID'];
			$name=$value['name'];
			$courseID_long=$value['courseID'];
			$status=$value['status'];
			$class_level=$value['class_level'];
			if ($status==2) {
				$room_export=$this->chk_room_export_edit($DataID,$data_year_search);
				if ($room_export>0) {
				$data_dicision=$this->get_data_dicision_edit($DataID,$courseID_long,$class_level,$name,$data_term_search,$data_year_search,$status);
				}
			}else{
				$data_dicision=$this->get_data_dicision_edit($DataID,$courseID_long,$class_level,$name,$data_term_search,$data_year_search,$status);
			}
			
			$data_response['coures_id_list'].=$data_dicision;
		}
		if ($data_response['coures_id_list']=='') {
			$data_response['coures_id_list']='';
		}
		return json_encode($data_response);
	}
	public function get_coures_id_list_added(){
		$ss_status=$_SESSION['ss_status'];
		$condition_sql_user="";
		$data_response = array();	
		$this->sql ="SELECT  *
					FROM tbl_set_term_year 			
							";
		$this->select();
		$this->setRows();
		$term_set=$this->rows[0]['term'];
		$year_set=$this->rows[0]['year'];
		if ($ss_status==2) {
			$condition_sql="WHERE";
		}else{
			$condition_sql="
			WHERE year='$year_set' AND
			";
			$user_id=$_SESSION['ss_user_id'];
			$condition_sql_user="
			WHERE teacher_id=$user_id
			";		
		}
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 		
                    WHERE DataID in(
                    	SELECT courseID
                        FROM tbl_registed_course
                        $condition_sql                  
                        DataID IN(
                        	SELECT registed_courseID
                            FROM tbl_registed_course_teaching
                        )
                        AND DataID in(
                            	SELECT regis_course_id
								FROM tbl_course_teacher
								$condition_sql_user
                            )
                    )
					ORDER BY courseID ASC	
							";
		$this->select();
		$this->setRows();
		foreach($this->rows as $key => $value) {
			$DataID=$value['DataID'];
			$name=$value['name'];
			$courseID_long=$value['courseID'];
			$status=$value['status'];
			$class_level=$value['class_level'];
			if ($status==2) {
				$room_export=$this->chk_room_export($DataID,$year_set,$ss_status);
				if ($room_export!=0) {
					$data_dicision=$this->get_data_dicision_added($DataID,$courseID_long,$class_level,$name,$status);
				}
			}else{
				$data_dicision=$this->get_data_dicision_added($DataID,$courseID_long,$class_level,$name,$status);
			}
		
			$data_response['coures_id_list'].=$data_dicision;
		}
		return json_encode($data_response);
	}
	
	public function get_coures_id_list($data_id,$data_room){
		$user_id=$_SESSION['ss_user_id'];
		$data_response = array();	
		$this->sql ="SELECT  *
					FROM tbl_set_term_year 			
							";
		$this->select();
		$this->setRows();
		$term_set=$this->rows[0]['term'];
		$year_set=$this->rows[0]['year'];
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 		
                    WHERE DataID in(
                    	SELECT courseID
                        FROM tbl_registed_course
                        WHERE year='$year_set'                                       
                        AND DataID IN(
                        	SELECT registed_courseID
                            FROM tbl_registed_course_teaching
                        )
                        AND DataID in(
                        	SELECT regis_course_id
							FROM tbl_course_teacher
							WHERE teacher_id=$user_id
                        )
                    )
					ORDER BY courseID ASC	
							";
		$this->select();
		$this->setRows();
		foreach($this->rows as $key => $value) {
			$DataID=$value['DataID'];
			
			$name=$value['name'];
			$courseID_long=$value['courseID'];
			$status=$value['status'];
			$class_level=$value['class_level'];
			if ($status==2) {
				$room_export=$this->chk_room_export($DataID,$year_set);
				if ($room_export==0) {
					$data_dicision=$this->get_data_dicision($DataID,$courseID_long,$class_level,$name,$status);
				}
			}else{
				$data_dicision=$this->get_data_dicision($DataID,$courseID_long,$class_level,$name,$status);
			}
			
			$data_response['coures_id_list'].=$data_dicision;
		}
		return json_encode($data_response);
	}
	
	public function chk_room_export_edit($course_id,$year_set){
		$this->sql ="SELECT  COUNT(*) AS num_row
					FROM tbl_add_delete_course
					WHERE DataID=$course_id
                    AND  DataID in(
                    	SELECT courseID
                    	FROM tbl_registed_course
                    	WHERE year='$year_set'
                    	AND DataID in(
                    		SELECT registed_courseID
                    		FROM tbl_room_export 
                    		WHERE status=0
                    		AND sended_status=0
                    		OR sended_status=1
                    	)
                    )
							";
		$this->select();
		$this->setRows();
		return $this->rows[0]['num_row'];
	}
	public function chk_room_export($course_id,$year_set,$ss_status){
		$condition="";
		if ($ss_status==2) {
			$condition="WHERE status=0 AND sended_status=1";
		}
		
		$this->sql ="SELECT  COUNT(*) AS num_row
					FROM tbl_add_delete_course
					WHERE DataID=$course_id
                    AND  DataID in(
                    	SELECT courseID
                    	FROM tbl_registed_course
                    	WHERE year='$year_set'
                    	AND DataID in(
                    		SELECT registed_courseID
                    		FROM tbl_room_export 
                    		$condition
                    	)
                    )
							";
		$this->select();
		$this->setRows();
		return $this->rows[0]['num_row'];
	}
	public function get_coures_id_list_admin($term_set,$year_set){
		$data_response = array();	

		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 		
                    WHERE DataID in(
                    	SELECT courseID
                        FROM tbl_registed_course
                        WHERE year='$year_set'                                       
                        AND DataID IN(
                        	SELECT registed_courseID
                            FROM tbl_registed_course_teaching
                        )              
                    )
					ORDER BY courseID ASC	
							";
		$this->select();
		$this->setRows();
		foreach($this->rows as $key => $value) {
			$DataID=$value['DataID'];
			
			$name=$value['name'];
			$courseID_long=$value['courseID'];
			$status=$value['status'];
			$class_level=$value['class_level'];
			if ($status==2) {	
				$room_export=$this->chk_room_export_admin($DataID,$year_set,$term_set);
				if ($room_export>0) {
					$data_dicision=$this->get_data_dicision_admin($DataID,$courseID_long,$class_level,$name,$term_set,$year_set,$status);
				}
			}else{
				$data_dicision=$this->get_data_dicision_admin($DataID,$courseID_long,$class_level,$name,$term_set,$year_set,$status);
			}
			$data_response['coures_id_list'].=$data_dicision;
		}
		return json_encode($data_response);
	}
	public function chk_room_export_admin($course_id,$year_set,$term_set){
		$this->sql ="SELECT  COUNT(*) AS num_row
					FROM tbl_add_delete_course
					WHERE DataID=$course_id
                    AND  DataID in(
                    	SELECT courseID
                    	FROM tbl_registed_course
                    	WHERE year='$year_set'
                    	AND term='$term_set'
                    	AND DataID in(
                    		SELECT registed_courseID
                    		FROM tbl_room_export 
                    		WHERE status=1
                    	
                    	)
                    )
							";
		$this->select();
		$this->setRows();
		return $this->rows[0]['num_row'];
	}
	public function get_class_level_new($class_level_data){
		if ($class_level_data=="p1") {
			$class_level="ป.1";
		}elseif($class_level_data=="p2"){
			$class_level="ป.2";	
		}elseif($class_level_data=="p3"){
			$class_level="ป.3";	
		}elseif($class_level_data=="p4"){
			$class_level="ป.4";	
		}elseif($class_level_data=="p5"){
			$class_level="ป.5";	
		}elseif($class_level_data=="p6"){
			$class_level="ป.6";	
		}elseif($class_level_data=="m1"){
			$class_level="ม.1";	
		}elseif($class_level_data=="m2"){
			$class_level="ม.2";	
		}elseif($class_level_data=="m3"){
			$class_level="ม.3";	
		}elseif($class_level_data=="m4"){
			$class_level="ม.4";	
		}elseif($class_level_data=="m5"){
			$class_level="ม.5";	
		}elseif($class_level_data=="m6"){
			$class_level="ม.6";	
		}
		return $class_level;
	}
	public function get_name_title($name_title_data){
		if ($name_title_data=="dekchai") {
			$name_title="เด็กชาย";
		}elseif($name_title_data=="dekying"){
			$name_title="เด็กหญิง";
		}elseif($name_title_data=="nai"){
			$name_title="นาย";
		}elseif($name_title_data=="nangsaw"){
			$name_title="นางสาว";
		}
		return $name_title;
	}

}<file_sep>/src/class.notification.php
<?php 

class Notification extends Databases {

	public function sap_date_format($strDate){
		$strYear = date("Y",strtotime($strDate));
		$strMonth= date("m",strtotime($strDate));
		$strDay= date("d",strtotime($strDate));
		return "{$strDay}.{$strMonth}.{$strYear}";
	}

/*************************************** API ACCOUNTING ****************************************/
	public function ex_not_membership($insert){
		$this->sql = "INSERT INTO not_membership(".implode(",",array_keys($insert)).") VALUES (".implode(",",array_values($insert)).")";
		$this->query();
		return $this->insertID();
	}

	public function ex_not_backoffice($insert){
		$this->sql = "INSERT INTO not_backoffice(".implode(",",array_keys($insert)).") VALUES (".implode(",",array_values($insert)).")";
		$this->query();
		return $this->insertID();
	}

	public function ex_not_message($msg_key){
		$this->sql = "SELECT msg_text FROM not_message WHERE msg_key = '{$msg_key}' ";
		$this->query();
		$this->setRows();
		return $this->rows[0]['msg_text'] ;
	}

	public function feed_not_backoffice($service_type){
		## DATA TBLE ##
		$item_no = 0;
		$sql = "SELECT *    
				FROM not_backoffice 
				WHERE service_type = {$service_type} 
				ORDER BY not_datetime DESC ";
		$this->sql = $sql;
		$this->select();
		$this->setRows();
		$data_response = "";
		foreach($this->rows as $key => $value) {
			$data_response[$item_no]['not_datetime'] = $value['not_datetime'];
			$data_response[$item_no]['not_message'] = $value['not_message'];
			$data_response[$item_no]['not_status'] = $value['not_status'];
			$data_response[$item_no]['user_id'] = $value['user_id'];
			$item_no++;
		}
		## DATA TBLE ##

		return $data_response;	
	}


	public function feed_not_membership($member_id=null)
	{
		## DATA TBLE ##
		$where = ' WHERE ';
		$where .= ' member_id='.$member_id.' AND '; 
		//if($account_id) $where .= ' account_id='.$account_id.' AND '; 
		$where = substr($where, 0, -4);

		$item_no = 0;
		$sql = "SELECT *    
				FROM not_membership 
				{$where}
				ORDER BY not_datetime DESC ";
		$this->sql = $sql;
		$this->select();
		$this->setRows();
		return $this->rows;
		/*$data_response = "";
		foreach($this->rows as $key => $value) {
			$data_response[$item_no]['not_datetime'] = $value['not_datetime'];
			$data_response[$item_no]['not_message'] = $value['not_message'];
			$data_response[$item_no]['not_status'] = $value['not_status'];
			$data_response[$item_no]['user_id'] = $value['user_id'];
			$item_no++;
		}
		## DATA TBLE ##
		
		return $data_response;	*/
	}	
/*************************************** API ACCOUNTING ****************************************/

// Aoo: 04/02/15
	// Insert Notification
	public function noti_member($message,$member_id,$account_id=0,$user_id=0,$settime="")
	{
		if( !$message ){
			$arr_response = array('status' => 'n', 'not_temp' => time(),'messages' => "Message Empty!");
			return json_encode($arr_response);	
		}

		// Get Memeber_id
		if(!$member_id){
			$where = ' WHERE account_id='.$account_id;
			$sql = "SELECT *    
					FROM mm_member_accounts 
					{$where}
					LIMIT 0,1 ";
			$this->sql = $sql;
			$this->select();
			$this->setRows();
			$member_id = $this->rows[0]['member_id'];
		}

		$not_mm = array();
		$not_mm["not_message"]= "'".$message."'";
		$not_mm["member_id"]= "'".$member_id."'";
		$not_mm["account_id"]= "'".$account_id."'";
		$not_mm["user_id"]= "'".$user_id."'";

		$not_mm["not_status"]= 1;
		$not_mm["not_datetime"]= ($settime)? "'".$settime."'":"now()";
		$not_mm["cdate"]= "now()"; 
		$not_id = self::ex_not_membership($not_mm);
		$arr_response = array('status' => 'y', 'not_temp' => time(),'messages' => "");
		return json_encode($arr_response);		
	}

	public function noti_backoffice($message,$role_id=0,$user_id=0,$settime="")
	{
		if( !$message ){
			$arr_response = array('status' => 'n', 'not_temp' => time(),'messages' => "Message Empty!");
			return json_encode($arr_response);	
		}

		$not_mm = array();
		$not_mm["not_message"]= "'".$message."'";
		$not_mm["role_id"]= "'".$role_id."'";
		$not_mm["user_id"]= "'".$user_id."'";

		$not_mm["not_status"]= 1;
		$not_mm["not_datetime"]= ($settime)? "'".$settime."'":"now()";
		$not_mm["cdate"]= "now()"; 
		$not_id = self::ex_not_backoffice($not_mm);
		$arr_response = array('status' => 'y', 'not_temp' => time(),'messages' => "");
		return json_encode($arr_response);		
	}

}


?><file_sep>/modules/report/class_modules.php
<?php 
set_time_limit(120);
class ClassData extends Databases {
	public function get_dev_summary($coures_id_list_val){
		$data_response = array();	
		$this->sql ="SELECT  count(*) as num_row_std
					FROM tbl_student 
					WHERE std_ID in(
						SELECT stdID
						FROM tbl_course_teaching_std
						WHERE registed_courseID in(
							SELECT DataID
							FROM tbl_registed_course
							WHERE courseID=$coures_id_list_val
						)
					)
					";
		$this->select();
		$this->setRows();	
		$data_response['num_all_std']=$this->rows[0]['num_row_std'];
		$this->sql ="SELECT  *
					FROM tbl_student 
					WHERE std_ID in(
						SELECT stdID
						FROM tbl_course_teaching_std
						WHERE registed_courseID in(
							SELECT DataID
							FROM tbl_registed_course
							WHERE courseID=$coures_id_list_val
						)
					)
					";
		$this->select();
		$this->setRows();	
		$data_atte_nopass=0;
		$data_atte_pass=0;
		$data_desirable_nopass=0;
		$data_desirable_pass=0;
		$data_desirable_good=0;
		$data_desirable_verygood=0;

		$data_read_think_write_nopass=0;
		$data_read_think_write_pass=0;
		$data_read_think_write_good=0;
		$data_read_think_write_verygood=0;

		$number=1;
		foreach($this->rows as $key => $value) {
			$std_ID=$value['std_ID'];
			$name_title_data=$value['name_title'];
			$name_title=$this->get_name_title($name_title_data);
			$fname=$value['fname'];
			$lname=$value['lname'];
			
			$score_attend_class=$this->get_score_attend_class($std_ID,$coures_id_list_val);
			if ($score_attend_class=='nopass') {
				$data_atte_nopass++;
			}else{
				$data_atte_pass++;
			}
			$desirable=$this->get_desirable($std_ID,$coures_id_list_val);	
				if ($desirable=='nopass') {
					$data_desirable_nopass++;
				}elseif($desirable=='pass'){
					$data_desirable_pass++;
				}elseif($desirable=='good'){
					$data_desirable_good++;
				}elseif($desirable=='verygood'){
					$data_desirable_verygood++;
				}
			$read_think_write=$this->get_read_think_write($std_ID,$coures_id_list_val);
			if ($read_think_write=='nopass') {
				$data_read_think_write_nopass++;
			}elseif($read_think_write=='pass'){
				$data_read_think_write_pass++;
			}elseif($read_think_write=='good'){
				$data_read_think_write_good++;
			}elseif($read_think_write=='verygood'){
				$data_read_think_write_verygood++;
			}
			include('checked.php');
			if ($score_attend_class=='pass') {
				$pass_status='<td>/</td>
                              <td></td>';
			}else{
				$pass_status='<td></td>
                              <td>/</td>';

			}
			$data_response['std_list'].='
								<tr>
                                  <td>'.$number.'</td>
                                  <td>'.$name_title.$fname.' '.$lname.'</td>
                                   '.$pass_status.'               
                                </tr>
			';
		$number++;
		}
		$data_response['data_atte_nopass']=$data_atte_nopass;	
		$data_response['data_atte_pass']=$data_atte_pass;

		$data_response['data_desirable_nopass']=$data_desirable_nopass;
		$data_response['data_desirable_pass']=$data_desirable_pass;
		$data_response['data_desirable_good']=$data_desirable_good;
		$data_response['data_desirable_verygood']=$data_desirable_verygood;	

		$data_response['data_read_think_write_nopass']=$data_read_think_write_nopass;
		$data_response['data_read_think_write_pass']=$data_read_think_write_pass;
		$data_response['data_read_think_write_good']=$data_read_think_write_good;
		$data_response['data_read_think_write_verygood']=$data_read_think_write_verygood;
		return $data_response;
	}
	public function get_std_desirable($coures_id_list_val,$room_search){
		$course_teachingID=$this->get_registed_course_id($coures_id_list_val);
		$this->sql ="SELECT  *
					FROM tbl_set_term_year 			
							";
		$this->select();
		$this->setRows();
		$term_set=$this->rows[0]['term'];
		$year_set=$this->rows[0]['year'];
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 	
					WHERE DataID=$coures_id_list_val					
					";
		$this->select();
		$this->setRows();
		$class_level=$this->rows[0]['class_level'];
		$status=$this->rows[0]['status'];
		if ($class_level=='p1' || $class_level=='p2' || $class_level=='p3' || $class_level=='p4' || $class_level=='p5' || $class_level=='p6' || $status==2) {
			$term_set='1,2';
		}
		if ($status!=2) {
			$sql_condition="WHERE room='$room_search' AND";
		}else{
			$sql_condition="WHERE";
		}

		$this->sql ="SELECT  COUNT(*) as num_row_std
					FROM tbl_student 	
					$sql_condition
					std_ID in(
						SELECT stdID
					    FROM tbl_course_teaching_std
					    WHERE registed_courseID IN(
					    	SELECT DataID
					        FROM tbl_registed_course
					        WHERE courseID=$coures_id_list_val
					        AND term='$term_set'
					        AND year='$year_set'
					    )
					)

					";
		$this->select();
		$this->setRows();
		$num_row_std=$this->rows[0]['num_row_std'];
		$this->sql ="SELECT  *
					FROM tbl_student 	
					$sql_condition
					std_ID in(
						SELECT stdID
					    FROM tbl_course_teaching_std
					    WHERE registed_courseID IN(
					    	SELECT DataID
					        FROM tbl_registed_course
					        WHERE courseID=$coures_id_list_val
					        AND term='$term_set'
					        AND year='$year_set'

					    )
					)
					";
		$this->select();
		$this->setRows();
		$num_set=1;
		$loo_no=1;
		foreach($this->rows as $key => $value) {
			$std_ID=$value['std_ID'];
			$name_title_data=$value['name_title'];
			$name_title=$this->get_name_title($name_title_data);
			$score_desirable_1=$this->get_score_desirable_1($std_ID,$course_teachingID);
			$score_desirable_2=$this->get_score_desirable_2($std_ID,$course_teachingID);
			$score_desirable_3=$this->get_score_desirable_3($std_ID,$course_teachingID);
			$score_desirable_4=$this->get_score_desirable_4($std_ID,$course_teachingID);
			$score_desirable_5=$this->get_score_desirable_5($std_ID,$course_teachingID);
			$score_desirable_6=$this->get_score_desirable_6($std_ID,$course_teachingID);
			$score_desirable_7=$this->get_score_desirable_7($std_ID,$course_teachingID);
			$score_desirable_8=$this->get_score_desirable_8($std_ID,$course_teachingID);
			$score_total_sum=$score_desirable_1['score']+$score_desirable_2['score']+$score_desirable_3['score']+$score_desirable_4['score']+$score_desirable_5['score']+$score_desirable_6['score']+$score_desirable_7['score']+$score_desirable_8['score'];
			$score_total=round(($score_total_sum)/8,2);

			$get_score_read=$this->get_score_read($std_ID,$course_teachingID);
			$get_score_write=$this->get_score_write($std_ID,$course_teachingID);
			$get_score_think=$this->get_score_think($std_ID,$course_teachingID);
			$get_score_rtw_4=$this->get_score_rtw_4($std_ID,$course_teachingID);
			$get_score_rtw_5=$this->get_score_rtw_5($std_ID,$course_teachingID);
			
			$score_total_rwt_sum=$get_score_read['score']+$get_score_write['score']+$get_score_think['score']+$get_score_rtw_4['score']+$get_score_rtw_5['score'];
			$score_total_rwt=round(($score_total_rwt_sum)/5,2);

			$fname=$value['fname'];
			$lname=$value['lname'];
		
			$data_response.='							
						 		<tr>
						 			<td>'.$num_set.'</td> 
						 			<td style="text-align:left;">'.$name_title.$fname.' '.$lname.'</td> 

                                  	<td>'.$score_desirable_1['score'].'</td> 
                                  	<td>'.$score_desirable_2['score'].'</td> 
                                  	<td>'.$score_desirable_3['score'].'</td> 
                                  	<td>'.$score_desirable_4['score'].'</td> 
                                  	<td>'.$score_desirable_5['score'].'</td> 
                                  	<td>'.$score_desirable_6['score'].'</td> 
                                  	<td>'.$score_desirable_7['score'].'</td> 
                                  	<td>'.$score_desirable_8['score'].'</td> 

                                  	<td>'.$score_total_sum.'</td> 
                                  	<td>'.$score_total.'</td>   

                                  	<td>'.$get_score_read['score'].'</td> 
                                  	<td>'.$get_score_write['score'].'</td> 
                                  	<td>'.$get_score_think['score'].'</td> 
                                  	<td>'.$get_score_rtw_4['score'].'</td> 
                                  	<td>'.$get_score_rtw_5['score'].'</td> 

                                  	<td>'.$score_total_rwt_sum.'</td> 
                                  	<td>'.$score_total_rwt.'</td> 

                                  	         
                                </tr>
			';
			$num_set++;
		}

		return $data_response;
	}
	public function get_score_read($std_ID,$course_teachingID){
		$data_response = array();
		$this->sql ="SELECT  *
					FROM tbl_read_score 			
					WHERE course_teachingID=$course_teachingID
					AND stdID='$std_ID'
					";
		$this->select();
		$this->setRows();
		$data_response['DataID']=$this->rows[0]['DataID'];
		$score=$this->rows[0]['score'];
		if ($score=='') {
			$data_response['score']=0;
		}else{
			$data_response['score']=$score;
		}
		return $data_response;
	}
	public function get_score_write($std_ID,$course_teachingID){
		$data_response = array();
		$this->sql ="SELECT  *
					FROM tbl_write_score 			
					WHERE course_teachingID=$course_teachingID
					AND stdID='$std_ID'
					";
		$this->select();
		$this->setRows();
		$data_response['DataID']=$this->rows[0]['DataID'];
		$score=$this->rows[0]['score'];
		if ($score=='') {
			$data_response['score']=0;
		}else{
			$data_response['score']=$score;
		}
		return $data_response;
	}
	public function get_score_think($std_ID,$course_teachingID){
		$data_response = array();
		$this->sql ="SELECT  *
					FROM tbl_think_score 			
					WHERE course_teachingID=$course_teachingID
					AND stdID='$std_ID'
					";
		$this->select();
		$this->setRows();
		$data_response['DataID']=$this->rows[0]['DataID'];
		$score=$this->rows[0]['score'];
		if ($score=='') {
			$data_response['score']=0;
		}else{
			$data_response['score']=$score;
		}
		return $data_response;
	}
	public function get_score_rtw_4($std_ID,$course_teachingID){
		$data_response = array();
		$this->sql ="SELECT  *
					FROM tbl_rtw_4_score 			
					WHERE course_teachingID=$course_teachingID
					AND stdID='$std_ID'
					";
		$this->select();
		$this->setRows();
		$data_response['DataID']=$this->rows[0]['DataID'];
		$score=$this->rows[0]['score'];
		if ($score=='') {
			$data_response['score']=0;
		}else{
			$data_response['score']=$score;
		}
		return $data_response;
	}
	public function get_score_rtw_5($std_ID,$course_teachingID){
		$data_response = array();
		$this->sql ="SELECT  *
					FROM tbl_rtw_5_score 			
					WHERE course_teachingID=$course_teachingID
					AND stdID='$std_ID'
					";
		$this->select();
		$this->setRows();
		$data_response['DataID']=$this->rows[0]['DataID'];
		$score=$this->rows[0]['score'];
		if ($score=='') {
			$data_response['score']=0;
		}else{
			$data_response['score']=$score;
		}
		return $data_response;
	}

	public function get_score_desirable_1($std_ID,$course_teachingID){
		$data_response = array();
		$this->sql ="SELECT  *
					FROM tbl_desirable_1 			
					WHERE course_teachingID=$course_teachingID
					AND stdID='$std_ID'
					";
		$this->select();
		$this->setRows();
		$data_response['DataID']=$this->rows[0]['DataID'];
		$score=$this->rows[0]['score'];
		if ($score=='') {
			$data_response['score']=0;
		}else{
			$data_response['score']=$score;
		}
		return $data_response;
	}
	public function get_score_desirable_2($std_ID,$course_teachingID){
		$data_response = array();
		$this->sql ="SELECT  *
					FROM tbl_desirable_2 			
					WHERE course_teachingID=$course_teachingID
					AND stdID='$std_ID'
					";
		$this->select();
		$this->setRows();
		$data_response['DataID']=$this->rows[0]['DataID'];
		$score=$this->rows[0]['score'];
		if ($score=='') {
			$data_response['score']=0;
		}else{
			$data_response['score']=$score;
		}
		return $data_response;
	}
	public function get_score_desirable_3($std_ID,$course_teachingID){
		$data_response = array();
		$this->sql ="SELECT  *
					FROM tbl_desirable_3 			
					WHERE course_teachingID=$course_teachingID
					AND stdID='$std_ID'
					";
		$this->select();
		$this->setRows();
		$data_response['DataID']=$this->rows[0]['DataID'];
		$score=$this->rows[0]['score'];
		if ($score=='') {
			$data_response['score']=0;
		}else{
			$data_response['score']=$score;
		}
		return $data_response;
	}
	public function get_score_desirable_4($std_ID,$course_teachingID){
		$data_response = array();
		$this->sql ="SELECT  *
					FROM tbl_desirable_4 			
					WHERE course_teachingID=$course_teachingID
					AND stdID='$std_ID'
					";
		$this->select();
		$this->setRows();
		$data_response['DataID']=$this->rows[0]['DataID'];
		$score=$this->rows[0]['score'];
		if ($score=='') {
			$data_response['score']=0;
		}else{
			$data_response['score']=$score;
		}
		return $data_response;
	}
	public function get_score_desirable_5($std_ID,$course_teachingID){
		$data_response = array();
		$this->sql ="SELECT  *
					FROM tbl_desirable_5 			
					WHERE course_teachingID=$course_teachingID
					AND stdID='$std_ID'
					";
		$this->select();
		$this->setRows();
		$data_response['DataID']=$this->rows[0]['DataID'];
		$score=$this->rows[0]['score'];
		if ($score=='') {
			$data_response['score']=0;
		}else{
			$data_response['score']=$score;
		}
		return $data_response;
	}
	public function get_score_desirable_6($std_ID,$course_teachingID){
		$data_response = array();
		$this->sql ="SELECT  *
					FROM tbl_desirable_6 			
					WHERE course_teachingID=$course_teachingID
					AND stdID='$std_ID'
					";
		$this->select();
		$this->setRows();
		$data_response['DataID']=$this->rows[0]['DataID'];
		$score=$this->rows[0]['score'];
		if ($score=='') {
			$data_response['score']=0;
		}else{
			$data_response['score']=$score;
		}
		return $data_response;
	}
	public function get_score_desirable_7($std_ID,$course_teachingID){
		$data_response = array();
		$this->sql ="SELECT  *
					FROM tbl_desirable_7 			
					WHERE course_teachingID=$course_teachingID
					AND stdID='$std_ID'
					";
		$this->select();
		$this->setRows();
		$data_response['DataID']=$this->rows[0]['DataID'];
		$score=$this->rows[0]['score'];
		if ($score=='') {
			$data_response['score']=0;
		}else{
			$data_response['score']=$score;
		}
		return $data_response;
	}
	public function get_score_desirable_8($std_ID,$course_teachingID){
		$data_response = array();
		$this->sql ="SELECT  *
					FROM tbl_desirable_8 			
					WHERE course_teachingID=$course_teachingID
					AND stdID='$std_ID'
					";
		$this->select();
		$this->setRows();
		$data_response['DataID']=$this->rows[0]['DataID'];
		$score=$this->rows[0]['score'];
		if ($score=='') {
			$data_response['score']=0;
		}else{
			$data_response['score']=$score;
		}
		return $data_response;
	}
	public function get_attend($coures_id_list,$status,$room_search){
		$data_response = array();
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 	
					WHERE DataID=$coures_id_list					
					";
		$this->select();
		$this->setRows();
		$class_level=$this->rows[0]['class_level'];
		if ($class_level=='p1' || $class_level=='p2' || $class_level=='p3' || $class_level=='p4' || $class_level=='p5' || $class_level=='p6') {
			$class_status='p';
		}else{
			$class_status='m';
		}

		$registed_course_id=$this->get_registed_course_id($coures_id_list);
		$this->sql ="SELECT  SUM(hr) as num_hr
					FROM tbl_set_attend_day 		
					WHERE registed_course_teachingID=$registed_course_id	
					ORDER BY attend_class_week_listID ASC
							";
		$this->select();
		$this->setRows();
		$num_day=$this->rows[0]['num_hr'];
		if ($status==1 && $class_status=='m') { //p and m
			$total_hr=20*$num_day;
			/*for ($i=1; $i <= 20; $i++) { 
				if ($i==1) {
					$data_response['num_day'].='<td style="border-left:none;">'.$num_day.'</td>';
				}else{
					$data_response['num_day'].='<td>'.$num_day.'</td>';
				}
			}*/
			$set_page='port';

		}elseif($status==2 || $class_status=='p'){
			$total_hr=40*$num_day;
			/*for ($i=1; $i <= 40; $i++) { 
				if ($i==1) {
					$data_response['num_day'].='<td style="border-left:none;">'.$num_day.'</td>';
				}else{
					$data_response['num_day'].='<td>'.$num_day.'</td>';
				}
			}*/
			$set_page='land';		
		}

		$detail_std=$this->get_detail_std_attend($coures_id_list,$room_search,$status,$num_day,$set_page);
		$data_response['detail_std']=$detail_std['detail_std'];
		$data_response['class_status']=$class_status;
		$data_response['set_page']=$set_page;
		$data_response['total_hr']=$total_hr;
		$data_response['num_day']=$num_day;
		return $data_response;
	}
public function get_detail_std_attend($coures_id_list_val,$room_search,$status,$num_day,$set_page){
		$this->sql ="SELECT  *
					FROM tbl_set_term_year 			
							";
		$this->select();
		$this->setRows();
		$term_set=$this->rows[0]['term'];
		$year_set=$this->rows[0]['year'];
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 	
					WHERE DataID=$coures_id_list_val					
					";
		$this->select();
		$this->setRows();
		$class_level=$this->rows[0]['class_level'];
		if ($class_level=='p1' || $class_level=='p2' || $class_level=='p3' || $class_level=='p4' || $class_level=='p5' || $class_level=='p6') {
			$term_set='1,2';
		}
		$registed_courseID=$this->get_registed_courseID($coures_id_list_val);
		if ($status!=2) {
			$sql_condition="WHERE room='$room_search' AND";
		}else{
			$sql_condition="WHERE";
		}
		$this->sql ="SELECT  *
					FROM tbl_student 	
					$sql_condition
					std_ID IN(
						SELECT stdID
						FROM tbl_course_teaching_std
						WHERE registed_courseID=$registed_courseID						
					)
					ORDER BY std_ID ASC
					";
		$this->select();
		$this->setRows();
		$no_std=1;
		foreach($this->rows as $key => $value) {
			$std_ID=$value['std_ID'];
			$fname=$value['fname'];
			$lname=$value['lname'];
			$name_title_data=$value['name_title'];
			$name_title=$this->get_name_title($name_title_data);
		//	$attend_data=$this->get_attend_data($registed_course_teaching_id,$std_ID,$registed_courseID,$length_list_val,$class_level_status);
			$attend_data=$this->get_attend_data($std_ID,$registed_courseID,$status,$num_day,$set_page);
			
			$data_response['detail_std'].='<tr>
										<td>'.$no_std.'</td>
						                  <td  style="text-align:left;">'.$name_title.$fname.' '.$lname.'</td>				                  
						                 
						                 '.$attend_data['total_attend_list'].' 
						                 <td>'.$attend_data['sum_attend'].'</td>
						                 <td>'.round($attend_data['sum_attend_per'],2).'</td>
						                            
						             </tr>
			';			
		$no_std++;				
		}
		
		return $data_response;
	}
	
	public function get_attend_data($std_ID,$registed_courseID,$status,$num_day,$set_page){
			
			if ($set_page=='port') {
				$count_no_attend=0;
				for ($i=1; $i <=20 ; $i++) { 
					$this->sql ="SELECT  COUNT(*) as num_no_attend
						FROM tbl_attend_class_std 	
						WHERE week=$i
						AND course_teaching_std_id in(
							SELECT DataID
							FROM tbl_course_teaching_std
							WHERE registed_courseID=$registed_courseID
							AND stdID='$std_ID'
						)
						";
					$this->select();
					$this->setRows();
					$num_no_attend=$this->rows[0]['num_no_attend'];
					$total_attend=$num_day-$num_no_attend;
					$data_response['total_attend_list'].='<td>'.$total_attend.'</td>';
					$count_no_attend=$count_no_attend+$num_no_attend;					
				}
				$all_day=$num_day*20;
				$sum_attend=$all_day-$count_no_attend;
				$data_response['sum_attend']=$sum_attend;
				$data_response['sum_attend_per']=($sum_attend*100)/$all_day;
			}else{
				$count_no_attend=0;
				for ($i=1; $i <=40 ; $i++) { 
					$this->sql ="SELECT  COUNT(*) as num_no_attend
						FROM tbl_attend_class_std 	
						WHERE week=$i
						AND course_teaching_std_id in(
							SELECT DataID
							FROM tbl_course_teaching_std
							WHERE registed_courseID=$registed_courseID
							AND stdID='$std_ID'
						)
						";
					$this->select();
					$this->setRows();
					$num_no_attend=$this->rows[0]['num_no_attend'];
					$total_attend=$num_day-$num_no_attend;
					$data_response['total_attend_list'].='<td>'.$total_attend.'</td>';
					$count_no_attend=$count_no_attend+$num_no_attend;					
				}
				$all_day=$num_day*40;
				$sum_attend=$all_day-$count_no_attend;
				$data_response['sum_attend']=$sum_attend;
				$data_response['sum_attend_per']=($sum_attend*100)/$all_day;
			}
			return $data_response;
	}
	public function get_objective_list($coures_id_list_val,$room_search){
		$data_response = array();	

		$this->sql ="SELECT  COUNT(*) as find_end
					FROM tbl_objective_conclude 	
					WHERE courseID=$coures_id_list_val

					";
		$this->select();
		$this->setRows();	
		$find_end=$this->rows[0]['find_end'];	
		$this->sql ="SELECT  *
					FROM tbl_objective_conclude 	
					WHERE courseID=$coures_id_list_val
					ORDER BY no_order ASC
					";
		$this->select();
		$this->setRows();	
		$chk_loop=1;	
		$sum_score_main=0;
		foreach($this->rows as $key => $value) {
			$DataID=$value['DataID'];
			$no_order=$value['no_order'];
			$detail=$value['detail'];
			$score=$value['score'];
			$objective_conclude_detail.='
								<tr>
					                <td style="border: none;">
					                  ตัวชี้วัดที่ '.$no_order.'
					                </td>
					                <td style="border: none;">
					                 	'.$detail.'
					                </td>
					              </tr>   
								';


			if ($chk_loop==1) {
				$data_response['ob_title_table_col'].='
				<td style="border-left:none;">'.$no_order.'</td>';
				$data_response['score_title_table_col'].='
				<td style="border-left:none;width: 4%;">'.$score.'</td>';
			}else{
				$data_response['ob_title_table_col'].='
				<td >'.$no_order.'</td>';
				$data_response['score_title_table_col'].='
				<td style="width: 4%;">'.$score.'</td>';
			}
					
			if ($find_end==$chk_loop) {
				$data_objective.=$DataID; 
			}else{
				$data_objective.=$DataID.'-'; 
			}
			$sum_score_main=$sum_score_main+$score;
			$chk_loop++;
		}

		$data_response['objective_conclude_detail']=$objective_conclude_detail;
		$data_response['chk_loop']=$chk_loop;

		$this->sql ="SELECT  *
					FROM tbl_proportion 	
					WHERE courseID=$coures_id_list_val
					
					";
		$this->select();
		$this->setRows();
		$data_response['mid_exam']=$this->rows[0]['mid_exam'];
		$data_response['final_exam']=$this->rows[0]['final_exam'];
		$data_response['sum_score_main']=$sum_score_main;
		$registed_courseID=$this->get_registed_courseID($coures_id_list_val);
		$data_response['detail_std']=$this->get_detail_std($coures_id_list_val,$registed_courseID,$data_objective,$room_search);


		return $data_response;
	}
	public function get_course_teachingID($DataID,$term_set,$year_set){
		$this->sql ="SELECT  *
					FROM tbl_registed_course_teaching 			
					WHERE registed_courseID in(
						SELECT DataID
						FROM tbl_registed_course
						WHERE courseID=$DataID
						AND term='$term_set'
						AND year='$year_set'
					)
							";
		$this->select();
		$this->setRows();
		return $this->rows[0]['DataID'];	
	}
	public function get_detail_std($coures_id_list_val,$registed_courseID,$data_objective,$room_search){
		$this->sql ="SELECT  *
					FROM tbl_set_term_year 			
							";
		$this->select();
		$this->setRows();
		$term_set=$this->rows[0]['term'];
		$year_set=$this->rows[0]['year'];	

		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 	
					WHERE DataID=$coures_id_list_val					
					";
		$this->select();
		$this->setRows();
		$class_level=$this->rows[0]['class_level'];
		if ($class_level=='p1' || $class_level=='p2' || $class_level=='p3' || $class_level=='p4' || $class_level=='p5' || $class_level=='p6') {
			$term_set='1,2';
		}
		$this->sql ="SELECT  *
					FROM tbl_student 	
					WHERE room='$room_search'
					AND std_ID in(
						SELECT stdID
					    FROM tbl_course_teaching_std
					    WHERE registed_courseID IN(
					    	SELECT DataID
					        FROM tbl_registed_course
					        WHERE courseID=$coures_id_list_val
					        AND term='$term_set'
					        AND year='$year_set'
					    )
					)
					ORDER BY std_ID ASC
					";
		$this->select();
		$this->setRows();		
		$no_std=1;
		foreach($this->rows as $key => $value) {
			$std_ID=$value['std_ID'];
			$fname=$value['fname'];
			$lname=$value['lname'];
			$name_title_data=$value['name_title'];
			$name_title=$this->get_name_title($name_title_data);
			$class_level_status=$this->get_class_level_status($coures_id_list_val);
			$score_col=$this->get_score_col($std_ID,$data_objective,$registed_courseID);
			$score_col_total=$this->get_score_col_total($std_ID,$registed_courseID);

			$course_teachingID=$this->get_course_teachingID($coures_id_list_val,$term_set,$year_set);
			$score_mid_exam=$this->get_score_mid_exam($std_ID,$course_teachingID);
			$score_final_exam=$this->get_score_final_exam($std_ID,$course_teachingID);
			$sum_score=$score_col_total+$score_mid_exam['score']+$score_final_exam['score'];
			$score_exam=$score_mid_exam['score']+$score_final_exam['score'];
			$grade=$this->get_grade($score_exam,$score_col_total);
		
			$data_response.='<tr>
										<td>'.$no_std.'</td>
						                  <td style="text-align:left;">'.$name_title.$fname.' '.$lname.'</td>
						                  '.$score_col.'
						                  <td>'.$score_mid_exam['score'].'</td>
						                  <td>'.$score_final_exam['score'].'</td>
						                 <td>'.$sum_score.'</td>
						                 <td>'.$grade.'</td>
						              
						             </tr>
			';
					
			$no_std++;
			
		}
		return $data_response;
	}
	public function get_score_final_exam($std_ID,$course_teachingID){
		$data_response = array();
		$this->sql ="SELECT  *
					FROM tbl_final_exam_score 			
					WHERE course_teachingID=$course_teachingID
					AND stdID='$std_ID'
					";
		$this->select();
		$this->setRows();
		$data_response['DataID']=$this->rows[0]['DataID'];
		$score=$this->rows[0]['score'];
		if ($score=='' || $score==0) {
				$data_response['score']=0;
			}else{
				if ($score==-1) {
					$data_response['score']='ร';
				}else{
					$data_response['score']=$score;
				}				
			}
		return $data_response;
	}
	public function get_score_mid_exam($std_ID,$course_teachingID){
		$data_response = array();
		$this->sql ="SELECT  *
					FROM tbl_mid_exam_score 			
					WHERE course_teachingID=$course_teachingID
					AND stdID='$std_ID'
					";
		$this->select();
		$this->setRows();
		$data_response['DataID']=$this->rows[0]['DataID'];
		$score=$this->rows[0]['score'];
		if ($score=='' || $score==0) {
				$data_response['score']=0;
			}else{
				if ($score==-1) {
					$data_response['score']='ร';
				}else{
					$data_response['score']=$score;
				}				
			}
		return $data_response;
	}
	public function get_score_col_total($std_ID,$registed_courseID){
		$num_of_i=0;
		$this->sql ="SELECT  count(score) as num_of_i
					FROM tbl_objective_score_std 	
					WHERE staID='$std_ID'
					AND registed_courseID=$registed_courseID
					AND score=-1;
					";
			$this->select();
			$this->setRows();	
			$num_of_i=$this->rows[0]['num_of_i'];
		$this->sql ="SELECT  SUM(score) as score_total
					FROM tbl_objective_score_std 	
					WHERE staID='$std_ID'
					AND registed_courseID=$registed_courseID
					";
			$this->select();
			$this->setRows();	
			$score_total_data=$this->rows[0]['score_total'];
			if ($score_total_data==0) {
				$score_total=0;	
			}else{
				$score_total=$score_total_data;	
			}
			return $score_total+$num_of_i;
	}
	public function get_score_col($std_ID,$data_objective,$registed_courseID){
		$arr_id = explode("-", $data_objective);	
		for ($i=0; $i < count($arr_id) ; $i++) { 
			if ($arr_id[$i]=='') {
				$arr_id[$i]=0;
			}else{
				$arr_id[$i]=$arr_id[$i];
			}
			$total_ob_conclude=$this->get_total_ob_conclude($arr_id[$i]);
			$this->sql ="SELECT  *
					FROM tbl_objective_score_std 	
					WHERE staID='$std_ID'
					AND objectiveID={$arr_id[$i]}
					AND registed_courseID=$registed_courseID
					";
			$this->select();
			$this->setRows();	
			$DataID=$this->rows[0]['DataID'];	
			$score=$this->rows[0]['score'];	
			if ($score=='' || $score==0) {
				$score=0;
			}else{
				if ($score==-1) {
					$score='ร';
				}else{
					$score=$score;
				}				
			}
			$data_response.='<td>'.$score.'</td>';
			$start_data++;
		}
		return $data_response;
	}
	public function get_total_ob_conclude($data_objective_ob){
		$this->sql ="SELECT  score
					FROM tbl_objective_conclude 	
					WHERE DataID=$data_objective_ob					
					";
			$this->select();
			$this->setRows();	
			return $this->rows[0]['score'];	
	}	
	public function get_grade_summary($coures_id_list_val,$room_search,$status){
		$data_response = array();	
		$registed_courseID=$this->get_registed_courseID($coures_id_list_val);

		if ($status!=2) {
			$sql_condition="WHERE room='$room_search' AND";
		}else{
			$sql_condition="WHERE";
		}
	
		$this->sql ="SELECT  count(*) as num_row_std
					FROM tbl_student 
					
					$sql_condition std_ID in(
						SELECT stdID
						FROM tbl_course_teaching_std
						WHERE registed_courseID =$registed_courseID
					)
					";
		$this->select();
		$this->setRows();	
		$data_response['num_all_std']=$this->rows[0]['num_row_std'];	
		$this->sql ="SELECT  *
					FROM tbl_student 
					
					$sql_condition std_ID in(
						SELECT stdID
						FROM tbl_course_teaching_std
						WHERE registed_courseID =$registed_courseID
					)
					ORDER BY std_ID ASC
					";
		$this->select();
		$this->setRows();	
		$data_i=0;
		$data_atte=0;
		$data_00=0;
		$data_10=0;
		$data_15=0;
		$data_20=0;
		$data_25=0;
		$data_30=0;
		$data_35=0;
		$data_40=0;

		$data_desirable_nopass=0;
		$data_desirable_pass=0;
		$data_desirable_good=0;
		$data_desirable_verygood=0;

		$data_read_think_write_nopass=0;
		$data_read_think_write_pass=0;
		$data_read_think_write_good=0;
		$data_read_think_write_verygood=0;

		$number=1;
		foreach($this->rows as $key => $value) {
			$std_ID=$value['std_ID'];
			$name_title_data=$value['name_title'];
			$name_title=$this->get_name_title($name_title_data);
			$fname=$value['fname'];
			$lname=$value['lname'];

			$comulative_score=$this->get_comulative_score($std_ID,$coures_id_list_val);
			$mid_exam_score=$this->get_mid_exam_score($std_ID,$coures_id_list_val);
			$final_exam_score=$this->get_final_exam_score($std_ID,$coures_id_list_val);
			$total_score_std=$comulative_score['sum_score_total_before']+$comulative_score['sum_score_total_after']+$mid_exam_score+$final_exam_score;
			$comulative_score_sum=$comulative_score['sum_score_total_before']+$comulative_score['sum_score_total_after'];
			$score_exam=$mid_exam_score+$final_exam_score;
			$grade_data=$this->get_grade($score_exam,$comulative_score_sum);

			$data_response['std_list'].='
					 <tr>
                  		<td>'.$number.'</td>
                  		<td>'.$name_title.$fname.' '.$lname.'</td>
                  		<td>'.$comulative_score['sum_score_total_before'].'</td>
                  		<td>'.$comulative_score['sum_score_total_after'].'</td>
                  		<td>'.$mid_exam_score.'</td>
                  		<td>'.$final_exam_score.'</td>
                 		<td>'.$total_score_std.'</td>
                  		<td>'.$grade_data.'</td>
                </tr>
			';
			$score_exam=$this->get_score_exam($std_ID,$coures_id_list_val);		
			$score_pick=$this->get_score_pick($std_ID,$coures_id_list_val);	
			$score_attend_class=$this->get_score_attend_class($std_ID,$coures_id_list_val);	
			//$data_response['score_attend_class']=$score_attend_class;
			if ($score_exam=='i' || $score_pick=='i' || $score_attend_class=='nopass') {
				if ($score_exam=='i' || $score_pick=='i') {
					$data_i++;
				}
				if ($score_attend_class=='nopass') {
					$data_atte++;
				}
				
			}else{
				$grade=$this->get_grade($score_exam,$score_pick);	
				$data_response['exam'].=$grade.'-';
				if ($grade=='0.0') {
					$data_00++;
				}elseif($grade=='1.0'){
					$data_10++;
				}elseif($grade=='1.5'){
					$data_15++;
				}elseif($grade=='2.0'){
					$data_20++;
				}elseif($grade=='2.5'){
					$data_25++;
				}elseif($grade=='3.0'){
					$data_30++;
				}elseif($grade=='3.5'){
					$data_35++;
				}elseif($grade=='4.0'){
					$data_40++;
				}		
			}	

		$desirable=$this->get_desirable($std_ID,$coures_id_list_val);	
			if ($desirable=='nopass') {
				$data_desirable_nopass++;
			}elseif($desirable=='pass'){
				$data_desirable_pass++;
			}elseif($desirable=='good'){
				$data_desirable_good++;
			}elseif($desirable=='verygood'){
				$data_desirable_verygood++;
			}
		$read_think_write=$this->get_read_think_write($std_ID,$coures_id_list_val);
			if ($read_think_write=='nopass') {
				$data_read_think_write_nopass++;
			}elseif($read_think_write=='pass'){
				$data_read_think_write_pass++;
			}elseif($read_think_write=='good'){
				$data_read_think_write_good++;
			}elseif($read_think_write=='verygood'){
				$data_read_think_write_verygood++;
			}
		$number++;
		}
		$data_response['data_read_think_write_nopass']=$data_read_think_write_nopass;
		$data_response['data_read_think_write_pass']=$data_read_think_write_pass;
		$data_response['data_read_think_write_good']=$data_read_think_write_good;
		$data_response['data_read_think_write_verygood']=$data_read_think_write_verygood;

		$data_response['data_desirable_nopass']=$data_desirable_nopass;
		$data_response['data_desirable_pass']=$data_desirable_pass;
		$data_response['data_desirable_good']=$data_desirable_good;
		$data_response['data_desirable_verygood']=$data_desirable_verygood;

		$data_response['data_i']=$data_i;
		$data_response['data_atte']=$data_atte;
		
		$data_response['data_00']=$data_00;
		$data_response['data_10']=$data_10;
		$data_response['data_15']=$data_15;
		$data_response['data_20']=$data_20;
		$data_response['data_25']=$data_25;
		$data_response['data_30']=$data_30;
		$data_response['data_35']=$data_35;
		$data_response['data_40']=$data_40;

		$propotion_total=$this->get_propotion_total($coures_id_list_val);
		
		$comulative_before_mid_title=$propotion_total['cumulative_before_mid'];
		$comulative_after_mid_title=$propotion_total['cumulative_after_mid'];
		$mid_exam_title=$propotion_total['mid_exam'];
		$final_exam_title=$propotion_total['final_exam'];

		$data_response['total_title']=$comulative_before_mid_title+$comulative_after_mid_title+$mid_exam_title+$final_exam_title;
		$data_response['comulative_before_mid_title']=$comulative_before_mid_title;
		$data_response['comulative_after_mid_title']=$comulative_after_mid_title;
		$data_response['mid_exam_title']=$mid_exam_title;
		$data_response['final_exam_title']=$final_exam_title;
		return $data_response;
	}
	public function get_name_title($name_title_data){
		if ($name_title_data=="dekchai") {
			$name_title="เด็กชาย";
		}elseif($name_title_data=="dekying"){
			$name_title="เด็กหญิง";
		}elseif($name_title_data=="nai"){
			$name_title="นาย";
		}elseif($name_title_data=="nangsaw"){
			$name_title="นางสาว";
		}
		return $name_title;
	}
	public function get_comulative_score($std_ID,$coures_id_list_val){
		$data_response = array();	
		$registed_courseID=$this->get_registed_courseID($coures_id_list_val);
		$this->sql ="SELECT  SUM(score) as sum_score_total_before
					FROM tbl_objective_score_std 			
					WHERE registed_courseID=$registed_courseID
					AND staID='$std_ID'
					AND objectiveID IN(
						SELECT DataID
						FROM tbl_objective_conclude
						WHERE proportion_status=1
					)
					";

		$this->select();
		$this->setRows();
		$data_response['sum_score_total_before']=$this->rows[0]['sum_score_total_before'];

		$this->sql ="SELECT  SUM(score) as sum_score_total_after
					FROM tbl_objective_score_std 			
					WHERE registed_courseID=$registed_courseID
					AND staID='$std_ID'
					AND objectiveID IN(
						SELECT DataID
						FROM tbl_objective_conclude
						WHERE proportion_status=2
					)
					";

		$this->select();
		$this->setRows();
		$data_response['sum_score_total_after']=$this->rows[0]['sum_score_total_after'];
		return $data_response;
	}
	public function get_mid_exam_score($std_ID,$coures_id_list_val){
		$registed_courseID=$this->get_registed_courseID($coures_id_list_val);
		$this->sql ="SELECT  *
					FROM tbl_mid_exam_score 			
					WHERE stdID='$std_ID'
					AND course_teachingID in(
						SELECT DataID
						FROM tbl_registed_course_teaching
						WHERE registed_courseID=$registed_courseID
					)
					";

		$this->select();
		$this->setRows();
		return $this->rows[0]['score'];
	}
	public function get_final_exam_score($std_ID,$coures_id_list_val){
		$registed_courseID=$this->get_registed_courseID($coures_id_list_val);
		$this->sql ="SELECT  *
					FROM tbl_final_exam_score 			
					WHERE stdID='$std_ID'
					AND course_teachingID in(
						SELECT DataID
						FROM tbl_registed_course_teaching
						WHERE registed_courseID=$registed_courseID
					)
					";

		$this->select();
		$this->setRows();
		return $this->rows[0]['score'];
	}
	public function get_propotion_total($coures_id_list_val){
		$data_response = array();	
		$this->sql ="SELECT  *
					FROM tbl_proportion 			
					WHERE courseID=$coures_id_list_val";
		$this->select();
		$this->setRows();
		$data_response['cumulative_before_mid']=$this->rows[0]['cumulative_before_mid'];
		$data_response['cumulative_after_mid']=$this->rows[0]['cumulative_after_mid'];
		
		$data_response['mid_exam']=$this->rows[0]['mid_exam'];
		$data_response['final_exam']=$this->rows[0]['final_exam'];
		$mid_exam=$this->rows[0]['mid_exam'];
		$final_exam=$this->rows[0]['final_exam'];
		$data_response['total']=$mid_exam+$final_exam;
		return $data_response;
	}
	public function search_course_detail($coures_id_list_val,$room_search){
		$data_response = array();	
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 	
					WHERE DataID=$coures_id_list_val
					";
		$this->select();
		$this->setRows();		
		$data_response['courseID']=$this->rows[0]['courseID'];	
		$data_response['name']=$this->rows[0]['name'];	
		$data_response['unit']=$this->rows[0]['unit'];	
		$data_response['hr_learn']=$this->rows[0]['hr_learn'];	
		$data_response['status']=$this->rows[0]['status'];	
		$class_level_data=$this->rows[0]['class_level'];
		$class_level=$this->get_class_level_new($class_level_data);
		$data_response['class_level_co']=$class_level.'/'.$room_search;

		$this->sql ="SELECT  count(*) as num_row_std
					FROM tbl_student 
					WHERE room='$room_search'
					AND std_ID in(
						SELECT stdID
						FROM tbl_course_teaching_std
						WHERE registed_courseID in(
							SELECT DataID
							FROM tbl_registed_course
							WHERE courseID=$coures_id_list_val
						)
					)
					";
		$this->select();
		$this->setRows();	
		$data_response['num_all_std']=$this->rows[0]['num_row_std'];	

		$this->sql ="SELECT  *
					FROM tbl_student 
					WHERE room='$room_search'
					AND std_ID in(
						SELECT stdID
						FROM tbl_course_teaching_std
						WHERE registed_courseID in(
							SELECT DataID
							FROM tbl_registed_course
							WHERE courseID=$coures_id_list_val
						)
					)
					ORDER BY std_ID ASC
					";
		$this->select();
		$this->setRows();	
		$data_i=0;
		$data_atte=0;
		$data_00=0;
		$data_10=0;
		$data_15=0;
		$data_20=0;
		$data_25=0;
		$data_30=0;
		$data_35=0;
		$data_40=0;

		$data_desirable_nopass=0;
		$data_desirable_pass=0;
		$data_desirable_good=0;
		$data_desirable_verygood=0;

		$data_read_think_write_nopass=0;
		$data_read_think_write_pass=0;
		$data_read_think_write_good=0;
		$data_read_think_write_verygood=0;

		$number=1;
		foreach($this->rows as $key => $value) {
			$std_ID=$value['std_ID'];

			//$attend_class_std_list=$this->get_attend_class_std_list($std_ID,$coures_id_list_val);

			$score_exam=$this->get_score_exam($std_ID,$coures_id_list_val);		
			$score_pick=$this->get_score_pick($std_ID,$coures_id_list_val);	
			$score_attend_class=$this->get_score_attend_class($std_ID,$coures_id_list_val);	
			//$data_response['score_attend_class']=$score_attend_class;
			if ($score_exam=='i' || $score_pick=='i' || $score_attend_class=='nopass') {
				if ($score_exam=='i' || $score_pick=='i') {
					$data_i++;
				}
				if ($score_attend_class=='nopass') {
					$data_atte++;
				}
				
			}else{
				$grade=$this->get_grade($score_exam,$score_pick);	
				$data_response['exam'].=$grade.'-';
				if ($grade=='0.0') {
					$data_00++;
				}elseif($grade=='1.0'){
					$data_10++;
				}elseif($grade=='1.5'){
					$data_15++;
				}elseif($grade=='2.0'){
					$data_20++;
				}elseif($grade=='2.5'){
					$data_25++;
				}elseif($grade=='3.0'){
					$data_30++;
				}elseif($grade=='3.5'){
					$data_35++;
				}elseif($grade=='4.0'){
					$data_40++;
				}		
			}	
			$desirable=$this->get_desirable($std_ID,$coures_id_list_val);	
			if ($desirable=='nopass') {
				$data_desirable_nopass++;
			}elseif($desirable=='pass'){
				$data_desirable_pass++;
			}elseif($desirable=='good'){
				$data_desirable_good++;
			}elseif($desirable=='verygood'){
				$data_desirable_verygood++;
			}
			$read_think_write=$this->get_read_think_write($std_ID,$coures_id_list_val);
			if ($read_think_write=='nopass') {
				$data_read_think_write_nopass++;
			}elseif($read_think_write=='pass'){
				$data_read_think_write_pass++;
			}elseif($read_think_write=='good'){
				$data_read_think_write_good++;
			}elseif($read_think_write=='verygood'){
				$data_read_think_write_verygood++;
			}
			$number++;
		}
		$data_response['attend_class_std_list']=$attend_class_std_list;
		$data_response['number']=$number;
		$data_response['data_i']=$data_i;
		$data_response['data_atte']=$data_atte;
		
		$data_response['data_00']=$data_00;
		$data_response['data_10']=$data_10;
		$data_response['data_15']=$data_15;
		$data_response['data_20']=$data_20;
		$data_response['data_25']=$data_25;
		$data_response['data_30']=$data_30;
		$data_response['data_35']=$data_35;
		$data_response['data_40']=$data_40;

		$data_response['data_desirable_nopass']=$data_desirable_nopass;
		$data_response['data_desirable_pass']=$data_desirable_pass;
		$data_response['data_desirable_good']=$data_desirable_good;
		$data_response['data_desirable_verygood']=$data_desirable_verygood;

		$data_response['data_read_think_write_nopass']=$data_read_think_write_nopass;
		$data_response['data_read_think_write_pass']=$data_read_think_write_pass;
		$data_response['data_read_think_write_good']=$data_read_think_write_good;
		$data_response['data_read_think_write_verygood']=$data_read_think_write_verygood;

		echo json_encode($data_response);
	}
	public function get_read_think_write($std_ID,$coures_id_list_val){
		$registed_courseID=$this->get_registed_courseID($coures_id_list_val);
		$score_total=0;

		$score_read=0;
		$score_think=0;
		$score_write=0;
		$this->sql ="SELECT  *
					FROM tbl_read_score
					WHERE stdID='$std_ID'
					AND course_teachingID in(
						SELECT DataID
						FROM tbl_registed_course_teaching 	
						WHERE registed_courseID=$registed_courseID
					)
					";
		$this->select();
		$this->setRows();
		$score_read=$this->rows[0]['score'];

		$this->sql ="SELECT  *
					FROM tbl_think_score
					WHERE stdID='$std_ID'
					AND course_teachingID in(
						SELECT DataID
						FROM tbl_registed_course_teaching 	
						WHERE registed_courseID=$registed_courseID
					)
					";
		$this->select();
		$this->setRows();
		$score_think=$this->rows[0]['score'];

		$this->sql ="SELECT  *
					FROM tbl_write_score
					WHERE stdID='$std_ID'
					AND course_teachingID in(
						SELECT DataID
						FROM tbl_registed_course_teaching 	
						WHERE registed_courseID=$registed_courseID
					)
					";
		$this->select();
		$this->setRows();
		$score_write=$this->rows[0]['score'];

		$this->sql ="SELECT  *
					FROM tbl_rtw_4_score
					WHERE stdID='$std_ID'
					AND course_teachingID in(
						SELECT DataID
						FROM tbl_registed_course_teaching 	
						WHERE registed_courseID=$registed_courseID
					)
					";
		$this->select();
		$this->setRows();
		$score_rtw_4=$this->rows[0]['score'];

		$this->sql ="SELECT  *
					FROM tbl_rtw_5_score
					WHERE stdID='$std_ID'
					AND course_teachingID in(
						SELECT DataID
						FROM tbl_registed_course_teaching 	
						WHERE registed_courseID=$registed_courseID
					)
					";
		$this->select();
		$this->setRows();
		$score_rtw_5=$this->rows[0]['score'];

		$score_total=($score_read+$score_think+$score_write+$score_rtw_4+$score_rtw_5)/5;
			if ($score_total<1) {
				$data='nopass';
			}elseif($score_total<1.5){
				$data='pass';
			}elseif($score_total<2.5){
				$data='good';
			}elseif($score_total>=2.5){
				$data='verygood';
			}
		return $data;
	}
	public function get_desirable($std_ID,$coures_id_list_val){
		$registed_courseID=$this->get_registed_courseID($coures_id_list_val);
		$score_total=0;
		for ($i=1; $i <= 8 ; $i++) { 
				$this->sql ="SELECT  *
					FROM tbl_desirable_$i 
					WHERE stdID='$std_ID'
					AND course_teachingID in(
						SELECT DataID
						FROM tbl_registed_course_teaching 	
						WHERE registed_courseID=$registed_courseID
					)
					";
			$this->select();
			$this->setRows();
			$score=$this->rows[0]['score'];
			$score_total=$score_total+$score;
			}	
			$evaluation_score=$score_total/8;
			if ($evaluation_score<1) {
				$data='nopass';
			}elseif($evaluation_score<1.5){
				$data='pass';
			}elseif($evaluation_score<2.5){
				$data='good';
			}elseif($evaluation_score>=2.5){
				$data='verygood';
			}
		return $data;
	}
	public function get_registed_courseID($coures_id_list_val){
		$this->sql ="SELECT  *
					FROM tbl_set_term_year 			
							";
		$this->select();
		$this->setRows();
		$term_set=$this->rows[0]['term'];
		$year_set=$this->rows[0]['year'];

		$data_response = array();
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 	
					WHERE DataID=$coures_id_list_val					
					";
		$this->select();
		$this->setRows();
		$class_level=$this->rows[0]['class_level'];
		$status=$this->rows[0]['status'];
		if ($class_level=='p1' || $class_level=='p2' || $class_level=='p3' || $class_level=='p4' || $class_level=='p5' || $class_level=='p6' || $status==2) {
			$term_set='1,2';
		}
			
		$this->sql ="SELECT  *
					FROM tbl_registed_course 	
					WHERE courseID=$coures_id_list_val
					AND term='$term_set'
					AND year='$year_set'

					";
		$this->select();
		$this->setRows();		
		return $this->rows[0]['DataID'];	
	}
	public function get_grade($score_exam,$score_pick){
		$total=$score_exam+$score_pick;
		if ($total<50) {
			$grade='0.0';
		}elseif($total<55){
			$grade='1.0';
		}elseif($total<60){
			$grade='1.5';
		}elseif($total<65){
			$grade='2.0';
		}elseif($total<70){
			$grade='2.5';
		}elseif($total<75){
			$grade='3.0';
		}elseif($total<80){
			$grade='3.5';
		}elseif($total>=80){
			$grade='4.0';
		}
		return $grade;
	}
	public function get_score_attend_class($std_ID,$coures_id_list_val){
		$registed_courseID=$this->get_registed_courseID($coures_id_list_val);
		$this->sql ="SELECT COUNT(course_teaching_std_id) as sum_no_come
					FROM tbl_attend_class_std 
					WHERE course_teaching_std_id IN(
						SELECT DataID
						FROM tbl_course_teaching_std
						WHERE registed_courseID=$registed_courseID
						AND stdID=$std_ID
					)	
					AND set_attend_day_id IN(
						SELECT DataID
						FROM tbl_set_attend_day
						WHERE registed_course_teachingID IN(
							SELECT DataID
							FROM tbl_registed_course_teaching
							WHERE registed_courseID=$registed_courseID
						)
					)
					";
		$this->select();
		$this->setRows();	
		$sum_no_come=$this->rows[0]['sum_no_come'];
		
		$registed_course_teaching_id=$this->get_registed_course_id($coures_id_list_val);
		$this->sql ="SELECT  SUM(hr) as num_hr
					FROM tbl_set_attend_day 	
					WHERE registed_course_teachingID=$registed_course_teaching_id
					";
		$this->select();
		$this->setRows();
		$num_hr=$this->rows[0]['num_hr'];	
		$class_level_status=$this->get_class_level_status($coures_id_list_val);
		if ($class_level_status=='p') {
			$week_all=40;
		}else{
			$week_all=20;
		}
		$total_day=$num_hr*$week_all;
		$total_attend_per=round((($total_day-$sum_no_come)*100)/$total_day);

		if ($total_attend_per>=80) {
			$find_80_per='pass';
		}else{
			$find_80_per='nopass';
		}
		/*
		$this->sql ="SELECT *
					FROM tbl_set_count_adttend_class 
					WHERE registed_courseID=$registed_courseID		
					";
		$this->select();
		$this->setRows();	
		$week_name=$this->rows[0]['week_name'];

		$this->sql ="SELECT  SUM(score_status) as sum_score
					FROM tbl_attend_class 
					WHERE week BETWEEN 1 AND $week_name
					AND course_teaching_stdID in(
						SELECT DataID
						FROM tbl_course_teaching_std
						WHERE registed_courseID=$registed_courseID
						AND stdID='$std_ID'
					)					
					";
		$this->select();
		$this->setRows();	
		$sum_score=$this->rows[0]['sum_score'];
		$data_must_pass=floor((80*$week_name)/100);
		if ($sum_score>=$data_must_pass) {
			$find_80_per='pass';
		}else{
			$find_80_per='nopass';
		}*/
		return $find_80_per;
	}
	public function get_registed_course_id($coures_id_list){
		$this->sql ="SELECT  *
					FROM tbl_set_term_year 			
							";
		$this->select();
		$this->setRows();
		$term_set=$this->rows[0]['term'];
		$year_set=$this->rows[0]['year'];
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 	
					WHERE DataID=$coures_id_list
					
					";
		$this->select();
		$this->setRows();		
		$class_level_data=$this->rows[0]['class_level'];
		$status=$this->rows[0]['status'];	
		if ($class_level_data=='p1' || $class_level_data=='p2' || $class_level_data=='p3' || $class_level_data=='p4' || $class_level_data=='p5' || $class_level_data=='p6' || $status==2) {
			$term_set='1,2';
		}

		$this->sql ="SELECT  *
					FROM tbl_registed_course_teaching 	
					WHERE registed_courseID in(
						SELECT DataID
						FROM tbl_registed_course 
						WHERE term='$term_set'
						AND year='$year_set'
						AND courseID=$coures_id_list
					)
					";
		$this->select();
		$this->setRows();
		return $this->rows[0]['DataID'];	
	}
	public function get_class_level_status($coures_id_list_val){
		$data_response = array();	
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 	
					WHERE DataID=$coures_id_list_val
					";
		$this->select();
		$this->setRows();		
		$class_level=$this->rows[0]['class_level'];	
		$status=$this->rows[0]['status'];	
		if ($class_level=='p1' || $class_level=='p2' || $class_level=='p3' || $class_level=='p4' || $class_level=='p5' || $class_level=='p6' ||$status==2) {
			$data='p';
		}else{
			$data='m';
		}
		return $data;
	}
	public function get_score_pick($std_ID,$coures_id_list_val){
		$registed_courseID=$this->get_registed_courseID($coures_id_list_val);
		$num_of_i=0;
		$this->sql ="SELECT  COUNT(score) as num_of_i
					FROM tbl_objective_score_std 	
					WHERE staID='$std_ID'
					AND registed_courseID=$registed_courseID
					AND score=-1
					";
		$this->select();
		$this->setRows();
		$num_of_i=$this->rows[0]['num_of_i'];			
		$this->sql ="SELECT  SUM(score) as score_total
					FROM tbl_objective_score_std 	
					WHERE staID='$std_ID'
					AND registed_courseID=$registed_courseID
					";
		$this->select();
		$this->setRows();	
		$score_total_data=$this->rows[0]['score_total'];
		if ($num_of_i>0) {
			$total='i';
		}else{
			$total=$score_total_data;
		}
			return $total;
	}
	public function get_score_exam($std_ID,$coures_id_list_val){	
	$this->sql ="SELECT  *
					FROM tbl_set_term_year 			
							";
		$this->select();
		$this->setRows();
		$term_set=$this->rows[0]['term'];
		$year_set=$this->rows[0]['year'];
		$data_response = array();	
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 	
					WHERE DataID=$coures_id_list_val
					
					";
		$this->select();
		$this->setRows();		
		$class_level_data=$this->rows[0]['class_level'];	
		$data_response['class_level']=$this->get_class_level_new($class_level_data);
		if ($class_level_data=='p1' || $class_level_data=='p2' || $class_level_data=='p3' || $class_level_data=='p4' || $class_level_data=='p5' || $class_level_data=='p6' ) {
			$term_set='1,2';
		}	
		$mid_status=0;
		$final_status=0;
		$this->sql ="SELECT  COUNT(score) as num_of_i_mid
					FROM tbl_mid_exam_score
					WHERE stdID='$std_ID'
					AND score=-1
					AND course_teachingID in(
						SELECT DataID
						FROM tbl_registed_course_teaching
						WHERE registed_courseID in(
							SELECT DataID
							FROM tbl_registed_course
							WHERE courseID=$coures_id_list_val
							AND term='$term_set'
							AND year='$year_set'
						)
					)
					";
		$this->select();
		$this->setRows();	
		$num_of_i_mid=$this->rows[0]['num_of_i_mid'];
		if ($num_of_i_mid>0) {
			$mid_status=-1;
		}
		$this->sql ="SELECT  *
					FROM tbl_mid_exam_score
					WHERE stdID='$std_ID'
					AND course_teachingID in(
						SELECT DataID
						FROM tbl_registed_course_teaching
						WHERE registed_courseID in(
							SELECT DataID
							FROM tbl_registed_course
							WHERE courseID=$coures_id_list_val
							AND term='$term_set'
							AND year='$year_set'
						)
					)
					";
		$this->select();
		$this->setRows();	
		$mid_exam_score=$this->rows[0]['score'];
		$this->sql ="SELECT  COUNT(score) as num_of_i_final
					FROM tbl_final_exam_score
					WHERE stdID='$std_ID'
					AND score=-1
					AND course_teachingID in(
						SELECT DataID
						FROM tbl_registed_course_teaching
						WHERE registed_courseID in(
							SELECT DataID
							FROM tbl_registed_course
							WHERE courseID=$coures_id_list_val
							AND term='$term_set'
							AND year='$year_set'
						)
					)
					";
		$this->select();
		$this->setRows();	
		$num_of_i_final=$this->rows[0]['num_of_i_final'];

		if ($num_of_i_final>0) {
			$final_status=-1;
		}
		$this->sql ="SELECT  *
					FROM tbl_final_exam_score 
					WHERE stdID='$std_ID'
					AND course_teachingID in(
						SELECT DataID
						FROM tbl_registed_course_teaching
						WHERE registed_courseID in(
							SELECT DataID
							FROM tbl_registed_course
							WHERE courseID=$coures_id_list_val
							AND term='$term_set'
							AND year='$year_set'
						)
					)
					";
		$this->select();
		$this->setRows();	
		$final_exam_score=$this->rows[0]['score'];
		if ($mid_status==-1 || $final_status==-1) {
			$total='i';
		}else{
			$total=$mid_exam_score+$final_exam_score;
		}
		return $total;
	}
	public function get_class_level($coures_id_list_val){
		$this->sql ="SELECT  *
					FROM tbl_set_term_year 			
							";
		$this->select();
		$this->setRows();
		$term_set=$this->rows[0]['term'];
		$year_set=$this->rows[0]['year'];
		$data_response = array();	
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 	
					WHERE DataID=$coures_id_list_val
					
					";
		$this->select();
		$this->setRows();		
		$class_level_data=$this->rows[0]['class_level'];
		$status=$this->rows[0]['status'];
		$data_response['status']=$status;
		$data_response['class_level']=$this->get_class_level_new($class_level_data);
		if ($class_level_data=='p1' || $class_level_data=='p2' || $class_level_data=='p3' || $class_level_data=='p4' || $class_level_data=='p5' || $class_level_data=='p6' || $status==2) {
			$term_set='1,2';
		}

		$this->sql ="SELECT distinct room
						FROM tbl_student 
						WHERE std_ID in(
							SELECT stdID
							FROM tbl_course_teaching_std
							WHERE registed_courseID in(
								SELECT DataID
								FROM tbl_registed_course
								WHERE courseID=$coures_id_list_val
                                AND term='$term_set'
                                AND year='$year_set'
								)
						)
						ORDER BY std_ID ASC
							";
			$this->select();
			$this->setRows();
			foreach($this->rows as $key => $value) {
				$room=$value['room'];
				$data_response['room'].=' <option value='.$room.'>'.$room.'</option>';
			}
		return json_encode($data_response);
	}
	public function get_data_dicision($DataID,$courseID_long,$class_level,$status,$term_set,$year_set){
		if ($class_level=='p1' || $class_level=='p2' || $class_level=='p3' || $class_level=='p4' || $class_level=='p5' || $class_level=='p6' || $status==2) {
			$data_response='<option value="'.$DataID.'">'.$courseID_long.'</option>';
		}else{
		$this->sql ="SELECT  COUNT(*) as num_row
					FROM tbl_registed_course 		
					WHERE courseID=$DataID
					AND term='$term_set'
					AND year='$year_set'

							";
		$this->select();
		$this->setRows();
		$num_row=$this->rows[0]['num_row'];
			if ($num_row==1) {
				$data_response='<option value="'.$DataID.'">'.$courseID_long.'</option>';
			}
		}
		return $data_response;
			
	}
	public function get_coures_id_list($data_id,$data_room){

		$data_response = array();	
		$this->sql ="SELECT  *
					FROM tbl_set_term_year 			
							";
		$this->select();
		$this->setRows();
		$term_set=$this->rows[0]['term'];
		$year_set=$this->rows[0]['year'];
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 		
                    WHERE DataID in(
                    	SELECT courseID
                        FROM tbl_registed_course
                        WHERE year='$year_set'                   
                        AND DataID IN(
                        	SELECT registed_courseID
                            FROM tbl_registed_course_teaching
                        )
                    )
					ORDER BY courseID ASC	
							";
		$this->select();
		$this->setRows();
		foreach($this->rows as $key => $value) {
			$DataID=$value['DataID'];
			
			$courseID_long=$value['courseID'];
			$status=$value['status'];
			$class_level=$value['class_level'];
			$data_dicision=$this->get_data_dicision($DataID,$courseID_long,$class_level,$status,$term_set,$year_set);

			$data_response['coures_id_list'].=$data_dicision;
		}
		return json_encode($data_response);
	}
	public function get_class_level_new($class_level_data){
		if ($class_level_data=="p1") {
			$class_level="ป.1";
		}elseif($class_level_data=="p2"){
			$class_level="ป.2";	
		}elseif($class_level_data=="p3"){
			$class_level="ป.3";	
		}elseif($class_level_data=="p4"){
			$class_level="ป.4";	
		}elseif($class_level_data=="p5"){
			$class_level="ป.5";	
		}elseif($class_level_data=="p6"){
			$class_level="ป.6";	
		}elseif($class_level_data=="m1"){
			$class_level="ม.1";	
		}elseif($class_level_data=="m2"){
			$class_level="ม.2";	
		}elseif($class_level_data=="m3"){
			$class_level="ม.3";	
		}elseif($class_level_data=="m4"){
			$class_level="ม.4";	
		}elseif($class_level_data=="m5"){
			$class_level="ม.5";	
		}elseif($class_level_data=="m6"){
			$class_level="ม.6";	
		}
		return $class_level;
	}
}<file_sep>/modules/profile/changepass.js
var opPage = 'profile';
$(document).ready(function() {
get_img()
}); 
function get_img(){
	var formData = new Array();
	formData.push({ "name": "acc_action", "value": "get_img" }); 
	formData.push({ "name": "status_get", "value": "index" }); 
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus) {
	// console.log(data);
		$("#get_profile_img").html(data.get_profile_img);

	});
}
function form_reset(form_se) {
	$("#"+form_se)[0].reset();
}
$(document).delegate('#btn__save', 'click', function(event) {
	var new_password =$("#<PASSWORD>").val();
	var new_password_again =$("#new_password_again").val();
	if(new_password===new_password_again) {
		if(new_password.length<6){
			$(".modal").modal("hide");
			$("#new_password").val('');
			$("#new_password_again").val('');
			$("#new_password").attr( "placeholder", "ใส่รหัสผ่านอย่างน้อย 6 ตั<PASSWORD>" );
			$("#new_password_again").attr( "placeholder", "ใส่รหัสผ่านอย่างน้อย 6 ต<PASSWORD>" );
		}else{
			var formData = $( "#frm_data" ).serializeArray();
			formData.push({ "name": "acc_action", "value": "update_new_pass" }); 
			$.post('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {
				$(".modal").modal("hide");
				if (data==0) {
					$(".modal").modal("hide");
					$("#old_password").val('');
					$("#profile-edit-box_chk").removeClass("profile-edit-box");
					$("#profile-edit-box_chk").addClass("profile-edit-box-null-data");
					$("#old_password").attr( "placeholder", "<PASSWORD>" );
				}else{
					$("#modalChangedPass").modal("show");
					form_reset("frm_data");
				}
				
			});
		}
	}else{
		$(".modal").modal("hide");
		$("#new_password").val('');
		$("#new_password_again").val('');
		$("#new_password").attr( "placeholder", "<PASSWORD>" );
		$("#new_password_again").attr( "placeholder", "<PASSWORD> <PASSWORD>" );
	}

});
<file_sep>/modules/print/class_modules.php
<?php 
set_time_limit(120);
class ClassData extends Databases {
	public function get_count_std_dev($registed_courseID){
		$this->sql ="	SELECT COUNT(stdID) AS count_std
						FROM tbl_course_teaching_std
						WHERE registed_courseID=$registed_courseID
						AND  stdID in(
							SELECT std_ID
							FROM tbl_student
						)	
					";
		$this->select();
		$this->setRows();
		return $this->rows[0]['count_std'];
	}
	public function get_dev_summary($coures_id_list_val,$room_search){
		$data_response = array();	
		$this->sql ="SELECT  *
					FROM tbl_set_term_year 			
							";
		$this->select();
		$this->setRows();
		
		$year_set=$this->rows[0]['year'];
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 	
					WHERE DataID=$coures_id_list_val					
					";
		$this->select();
		$this->setRows();
		$status_form=$this->rows[0]['status_form'];
		if ($status_form==25 ||$status_form==26|| $status_form==27) {
			$sql_condition="WHERE std_ID in(
								SELECT std_ID
								FROM tbl_std_class_room
								WHERE room='$room_search'
								AND status=1 
								AND year='$year_set'
							) 
							AND";
		}else{
			$sql_condition="WHERE";
		}
		$registed_courseID=$this->get_registed_courseID($coures_id_list_val);
		$this->sql ="SELECT  count(*) as num_row_std
					FROM tbl_student 
					$sql_condition std_ID in(
						SELECT stdID
						FROM tbl_course_teaching_std
						WHERE registed_courseID =$registed_courseID
					)
					";
		$this->select();
		$this->setRows();	
		$data_response['num_all_std']=$this->rows[0]['num_row_std'];

		$count_std=$this->get_count_std_dev($registed_courseID);
		$set_loop_html=ceil($count_std/30);
		for ($i=1; $i <=$set_loop_html ; $i++) { 
			$std_dev_summary=$this->get_std_dev_summary($coures_id_list_val,$i,$registed_courseID,$room_search,$year_set,$sql_condition);
			$data_html_dev.='
					<div style="page-break-after:always; ">
					    <table cellspacing="0" style="width: 92%; text-align: center; font-size: 24px;margin-left: 30px;border: 1px solid black;">
					                <caption style="font-size:28px ;margin-left: 30px;margin-top: 80px;">สรุปผลการเรียน</caption>
					                <thead>
					                  <tr>
					                    <td rowspan="2" style="width: 20%;">เลขที่</td>
					                    <td rowspan="2" style="width: 50%;">ชื่อ-สกุล</td>
					                    <td colspan="2" style="width: 30%;">สรุปผลการเรียน</td>
					                  </tr>
					                  <tr>
					                    <td style="width:13%;">ผ่าน</td>
					                    <td style="width:13%;">ไม่ผ่าน</td>
					                  </tr>
					                </thead>
					                <tbody>
					                 '.$std_dev_summary['std_list'].'					                  
					                </tbody>
					              </table>
					          </div>
			';
		}
		$data_response['data_atte_nopass']=$std_dev_summary['data_atte_nopass'];	
		$data_response['data_atte_pass']=$std_dev_summary['data_atte_pass'];

		$data_response['data_desirable_nopass']=$std_dev_summary['data_desirable_nopass'];
		$data_response['data_desirable_pass']=$std_dev_summary['data_desirable_pass'];
		$data_response['data_desirable_good']=$std_dev_summary['data_desirable_good'];
		$data_response['data_desirable_verygood']=$std_dev_summary['data_desirable_verygood'];	

		$data_response['data_read_think_write_nopass']=$std_dev_summary['data_read_think_write_nopass'];
		$data_response['data_read_think_write_pass']=$std_dev_summary['data_read_think_write_pass'];
		$data_response['data_read_think_write_good']=$std_dev_summary['data_read_think_write_good'];
		$data_response['data_read_think_write_verygood']=$std_dev_summary['data_read_think_write_verygood'];
		$data_response['data_html_dev']=$data_html_dev;

		return $data_response;
	}

	 public function get_std_dev_summary($coures_id_list_val,$i,$registed_courseID,$room_search,$year_set,$sql_condition){
	 	$find_start=($i-1)*30;
		$this->sql ="SELECT  *
						FROM tbl_student 
						$sql_condition std_ID in(
							SELECT stdID
							FROM tbl_course_teaching_std
							WHERE registed_courseID = $registed_courseID							
						)
						ORDER BY room ASC,
						CASE
							WHEN name_title LIKE '%dekchai%' THEN 0
					        WHEN name_title LIKE '%nai%' THEN 1
					        WHEN name_title LIKE '%dekying%' THEN 2
					        WHEN name_title LIKE '%nangsaw%'THEN 3
					        WHEN std_ID THEN 4      
					    END
						LIMIT $find_start,30
						";
			$this->select();
			$this->setRows();	
			$data_atte_nopass=0;
			$data_atte_pass=0;
			$data_desirable_nopass=0;
			$data_desirable_pass=0;
			$data_desirable_good=0;
			$data_desirable_verygood=0;

			$data_read_think_write_nopass=0;
			$data_read_think_write_pass=0;
			$data_read_think_write_good=0;
			$data_read_think_write_verygood=0;

			$number=$find_start+1;

			foreach($this->rows as $key => $value) {
				$std_ID=$value['std_ID'];
				$name_title_data=$value['name_title'];
				$name_title=$this->get_name_title($name_title_data);
				$fname=$value['fname'];
				$lname=$value['lname'];
				
				$score_attend_class=$this->get_score_attend_class($std_ID,$coures_id_list_val);
				if ($score_attend_class=='nopass') {
					$data_atte_nopass++;
				}else{
					$data_atte_pass++;
				}
				$desirable=$this->get_desirable($std_ID,$coures_id_list_val);	
					if ($desirable=='nopass') {
						$data_desirable_nopass++;
					}elseif($desirable=='pass'){
						$data_desirable_pass++;
					}elseif($desirable=='good'){
						$data_desirable_good++;
					}elseif($desirable=='verygood'){
						$data_desirable_verygood++;
					}
				$read_think_write=$this->get_read_think_write($std_ID,$coures_id_list_val);
				if ($read_think_write=='nopass') {
					$data_read_think_write_nopass++;
				}elseif($read_think_write=='pass'){
					$data_read_think_write_pass++;
				}elseif($read_think_write=='good'){
					$data_read_think_write_good++;
				}elseif($read_think_write=='verygood'){
					$data_read_think_write_verygood++;
				}
				include('checked.php');
				if ($score_attend_class=='pass') {
					$pass_status='<td><img style="width:22px;" src="../../assets/images/checked.png"></td>
	                              <td></td>';
				}else{
					$pass_status='<td></td>
	                              <td><img style="width:22px;" src="../../assets/images/checked.png"></td>';

				}
				$data_response['std_list'].='
									<tr>
	                                  <td>'.$number.'</td>
	                                  <td style="text-align:left;padding-left:140px;">'.$name_title.$fname.' '.$lname.'</td>
	                                   '.$pass_status.'               
	                                </tr>
				';
			$number++;
			}	
			$data_response['data_atte_nopass']=$data_atte_nopass;	
			$data_response['data_atte_pass']=$data_atte_pass;

			$data_response['data_desirable_nopass']=$data_desirable_nopass;
			$data_response['data_desirable_pass']=$data_desirable_pass;
			$data_response['data_desirable_good']=$data_desirable_good;
			$data_response['data_desirable_verygood']=$data_desirable_verygood;	

			$data_response['data_read_think_write_nopass']=$data_read_think_write_nopass;
			$data_response['data_read_think_write_pass']=$data_read_think_write_pass;
			$data_response['data_read_think_write_good']=$data_read_think_write_good;
			$data_response['data_read_think_write_verygood']=$data_read_think_write_verygood;
			return $data_response;
		}
	public function get_std_desirable($coures_id_list_val,$room_search){
		$course_teachingID=$this->get_registed_course_id($coures_id_list_val);	
		$registed_courseID=$this->get_registed_courseID($coures_id_list_val);

		$count_std=$this->get_count_std($registed_courseID);
		$set_loop_html=ceil($count_std/30);
		for ($i=1; $i <=$set_loop_html ; $i++) { 
			$stdlist_desirable=$this->get_stdlist_desirable($i,$registed_courseID,$course_teachingID,$coures_id_list_val,$room_search);
			$data_response.='
					<div style="page-break-after:always;">
						<page orientation="portrait">
						    <table cellspacing="0" style="width: 94%; text-align: center; font-size: 24px;margin-left: 30px;">
						    <caption style="font-size:28px ;margin-left: 30px;margin-top: 80px;">การประเมินคุณลักษณะอันพึงประสงค์และการอ่าน คิดวิเคราะห์ และเขียน</caption>
						              <thead>
						                <tr class="">
						                  <td rowspan="2"  style="vertical-align: middle;width: 1%;text-align: center;">
						                  	<div style="transform: rotate(-90deg);white-space: nowrap;">เลขที่</div>
						                  </td>
						                  <td rowspan="2"  style="vertical-align: middle;width: 1%;text-align: center;">
						                  	<div style="transform: rotate(-90deg);white-space: nowrap;">รหัส</div>
						                  </td>
						                  <td rowspan="2"  style="vertical-align: middle;width: 20%;text-align: center;">ชื่อ-สกุล</td>
						                  <td colspan="10" style="width: 18%;padding: 5px;text-align: center;">คุณลักษณะอันพึงประสงค์</td>                       
						                  <td colspan="7" style="vertical-align: middle;width: 22%;text-align: center;">การอ่าน คิดวิเคราะห์ และเขียน</td> 
						                </tr>
						                
						                <tr>          
						                  <td class="rotate" style="border-left: none;height: 60px;width: 0.1%;"><div style="margin-top: 10px;">ข้อที่&nbsp;&nbsp;1</div></td>
						                  <td class="rotate" style="width: 0.1%;"><div style="margin-top: 10px;">ข้อที่&nbsp;&nbsp;2</div></td>
						                  <td class="rotate" style="width: 0.1%;"><div style="margin-top: 10px;">ข้อที่&nbsp;&nbsp;3</div></td>
						                  <td class="rotate" style="width: 0.1%;"><div style="margin-top: 10px;">ข้อที่&nbsp;&nbsp;4</div></td>
						                  <td class="rotate" style="width: 0.1%;"><div style="margin-top: 10px;">ข้อที่&nbsp;&nbsp;5</div></td>
						                  <td class="rotate" style="width: 0.1%;"><div style="margin-top: 10px;">ข้อที่&nbsp;&nbsp;6</div></td>
						                  <td class="rotate" style="width: 0.1%;"><div style="margin-top: 10px;">ข้อที่&nbsp;&nbsp;7</div></td>
						                  <td class="rotate" style="width: 0.1%;"><div style="margin-top: 10px;">ข้อที่&nbsp;&nbsp;8</div></td>
						                  <td class="rotate" style="width: 0.1%;"><div style="margin-top: 10px;">คะแนนรวม</div></td>
						                  <td class="rotate" style="width: 0.1%;"><div style="margin-top: 10px;">คะแนนเฉลี่ย</div></td>
						                  <td class="rotate" style="width: 0.1%;"><div style="margin-top: 10px;">ตัวชี้วัดที่&nbsp;&nbsp;1</div></td>
						                  <td class="rotate" style="width: 0.1%;"><div style="margin-top: 10px;">ตัวชี้วัดที่&nbsp;&nbsp;2</div></td>
						                  <td class="rotate" style="width: 0.1%;"><div style="margin-top: 10px;">ตัวชี้วัดที่&nbsp;&nbsp;3</div></td>
						                  <td class="rotate" style="width: 0.1%;"><div style="margin-top: 10px;">ตัวชี้วัดที่&nbsp;&nbsp;4</div></td>
						                  <td class="rotate" style="width: 0.1%;"><div style="margin-top: 10px;">ตัวชี้วัดที่&nbsp;&nbsp;5</div></td>
						                  <td class="rotate" style="width: 0.1%;"><div style="margin-top: 10px;">คะแนนรวม</div></td>
						                  <td class="rotate" style="width: 0.1%;"><div style="margin-top: 10px;">คะแนนเฉลี่ย</div></td>
						                </tr>
						              </thead>
						              <tbody>
						               	'.$stdlist_desirable.'
						              </tbody>
						    </table> 
						  </page>
						</div>
			';
		}
		return $data_response;
	}
	public function get_stdlist_desirable($i,$registed_courseID,$course_teachingID,$coures_id_list_val,$room_search){
			$this->sql ="SELECT  *
						FROM tbl_set_term_year 			
								";
			$this->select();
			$this->setRows();
			$term_set=$this->rows[0]['term'];
			$year_set=$this->rows[0]['year'];
			$this->sql ="SELECT  *
						FROM tbl_add_delete_course 	
						WHERE DataID=$coures_id_list_val					
						";
			$this->select();
			$this->setRows();
			$class_level=$this->rows[0]['class_level'];
			$status=$this->rows[0]['status'];
			$status_form=$this->rows[0]['status_form'];
			if ($class_level=='p1' || $class_level=='p2' || $class_level=='p3' || $class_level=='p4' || $class_level=='p5' || $class_level=='p6' ) {
				$term_set='1,2';
			}
			
			if ($status==1) {
				$sql_condition="WHERE std_ID in(
									SELECT std_ID
									FROM tbl_std_class_room
									WHERE room='$room_search'
									AND status=1 
									AND year='$year_set'
								) 
								AND";
			}else{
				if ($status_form==25 || $status_form==26 || $status_form==27) {
					$sql_condition="WHERE std_ID in(
									SELECT std_ID
									FROM tbl_std_class_room
									WHERE room='$room_search'
									AND status=1 
									AND year='$year_set'
								) 
								AND";
				}else{
					$sql_condition="WHERE std_ID in(
									SELECT std_ID
									FROM tbl_std_class_room
									WHERE status=1 
									AND year='$year_set'
								) 
								AND
						";
				}
				
			}

			$find_start=($i-1)*30;
			$this->sql ="SELECT  *
						FROM tbl_student 	
						$sql_condition
						std_ID in(
							SELECT stdID
						    FROM tbl_course_teaching_std
						    WHERE registed_courseID = $registed_courseID
						)
						ORDER BY std_ID ASC
						LIMIT $find_start,30
						";
			$this->select();
			$this->setRows();
			$num_set=$find_start+1;
			$loo_no=1;
			foreach($this->rows as $key => $value) {
				$std_ID=$value['std_ID'];
				$name_title_data=$value['name_title'];
				$name_title=$this->get_name_title($name_title_data);
				$score_desirable_1=$this->get_score_desirable_1($std_ID,$course_teachingID);
				$score_desirable_2=$this->get_score_desirable_2($std_ID,$course_teachingID);
				$score_desirable_3=$this->get_score_desirable_3($std_ID,$course_teachingID);
				$score_desirable_4=$this->get_score_desirable_4($std_ID,$course_teachingID);
				$score_desirable_5=$this->get_score_desirable_5($std_ID,$course_teachingID);
				$score_desirable_6=$this->get_score_desirable_6($std_ID,$course_teachingID);
				$score_desirable_7=$this->get_score_desirable_7($std_ID,$course_teachingID);
				$score_desirable_8=$this->get_score_desirable_8($std_ID,$course_teachingID);
				$score_total_sum=$score_desirable_1['score']+$score_desirable_2['score']+$score_desirable_3['score']+$score_desirable_4['score']+$score_desirable_5['score']+$score_desirable_6['score']+$score_desirable_7['score']+$score_desirable_8['score'];
				$score_total=round(($score_total_sum)/8,2);

				$get_score_read=$this->get_score_read($std_ID,$course_teachingID);
				$get_score_write=$this->get_score_write($std_ID,$course_teachingID);
				$get_score_think=$this->get_score_think($std_ID,$course_teachingID);
				$get_score_rtw_4=$this->get_score_rtw_4($std_ID,$course_teachingID);
				$get_score_rtw_5=$this->get_score_rtw_5($std_ID,$course_teachingID);
				
				$score_total_rwt_sum=$get_score_read['score']+$get_score_write['score']+$get_score_think['score']+$get_score_rtw_4['score']+$get_score_rtw_5['score'];
				$score_total_rwt=round(($score_total_rwt_sum)/5,2);

				$fname=$value['fname'];
				$lname=$value['lname'];
			
				$data_response.='							
							 		<tr>
							 			<td>'.$num_set.'</td> 
							 			<td>'.$std_ID.'</td> 
							 			<td style="text-align:left;">'.$name_title.$fname.' '.$lname.'</td> 

	                                  	<td>'.$score_desirable_1['score'].'</td> 
	                                  	<td>'.$score_desirable_2['score'].'</td> 
	                                  	<td>'.$score_desirable_3['score'].'</td> 
	                                  	<td>'.$score_desirable_4['score'].'</td> 
	                                  	<td>'.$score_desirable_5['score'].'</td> 
	                                  	<td>'.$score_desirable_6['score'].'</td> 
	                                  	<td>'.$score_desirable_7['score'].'</td> 
	                                  	<td>'.$score_desirable_8['score'].'</td> 

	                                  	<td>'.$score_total_sum.'</td> 
	                                  	<td>'.$score_total.'</td>   

	                                  	<td>'.$get_score_read['score'].'</td> 
	                                  	<td>'.$get_score_write['score'].'</td> 
	                                  	<td>'.$get_score_think['score'].'</td> 
	                                  	<td>'.$get_score_rtw_4['score'].'</td> 
	                                  	<td>'.$get_score_rtw_5['score'].'</td> 

	                                  	<td>'.$score_total_rwt_sum.'</td> 
	                                  	<td>'.$score_total_rwt.'</td> 

	                                  	         
	                                </tr>
				';
				$num_set++;
			}
		return $data_response;
	}
	public function get_score_read($std_ID,$course_teachingID){
		$data_response = array();
		$this->sql ="SELECT  *
					FROM tbl_read_score 			
					WHERE course_teachingID=$course_teachingID
					AND stdID='$std_ID'
					";
		$this->select();
		$this->setRows();
		$data_response['DataID']=$this->rows[0]['DataID'];
		$score=$this->rows[0]['score'];
		if ($score=='') {
			$data_response['score']=0;
		}else{
			$data_response['score']=$score;
		}
		return $data_response;
	}
	public function get_score_write($std_ID,$course_teachingID){
		$data_response = array();
		$this->sql ="SELECT  *
					FROM tbl_write_score 			
					WHERE course_teachingID=$course_teachingID
					AND stdID='$std_ID'
					";
		$this->select();
		$this->setRows();
		$data_response['DataID']=$this->rows[0]['DataID'];
		$score=$this->rows[0]['score'];
		if ($score=='') {
			$data_response['score']=0;
		}else{
			$data_response['score']=$score;
		}
		return $data_response;
	}
	public function get_score_think($std_ID,$course_teachingID){
		$data_response = array();
		$this->sql ="SELECT  *
					FROM tbl_think_score 			
					WHERE course_teachingID=$course_teachingID
					AND stdID='$std_ID'
					";
		$this->select();
		$this->setRows();
		$data_response['DataID']=$this->rows[0]['DataID'];
		$score=$this->rows[0]['score'];
		if ($score=='') {
			$data_response['score']=0;
		}else{
			$data_response['score']=$score;
		}
		return $data_response;
	}
	public function get_score_rtw_4($std_ID,$course_teachingID){
		$data_response = array();
		$this->sql ="SELECT  *
					FROM tbl_rtw_4_score 			
					WHERE course_teachingID=$course_teachingID
					AND stdID='$std_ID'
					";
		$this->select();
		$this->setRows();
		$data_response['DataID']=$this->rows[0]['DataID'];
		$score=$this->rows[0]['score'];
		if ($score=='') {
			$data_response['score']=0;
		}else{
			$data_response['score']=$score;
		}
		return $data_response;
	}
	public function get_score_rtw_5($std_ID,$course_teachingID){
		$data_response = array();
		$this->sql ="SELECT  *
					FROM tbl_rtw_5_score 			
					WHERE course_teachingID=$course_teachingID
					AND stdID='$std_ID'
					";
		$this->select();
		$this->setRows();
		$data_response['DataID']=$this->rows[0]['DataID'];
		$score=$this->rows[0]['score'];
		if ($score=='') {
			$data_response['score']=0;
		}else{
			$data_response['score']=$score;
		}
		return $data_response;
	}

	public function get_score_desirable_1($std_ID,$course_teachingID){
		$data_response = array();
		$this->sql ="SELECT  *
					FROM tbl_desirable_1 			
					WHERE course_teachingID=$course_teachingID
					AND stdID='$std_ID'
					";
		$this->select();
		$this->setRows();
		$data_response['DataID']=$this->rows[0]['DataID'];
		$score=$this->rows[0]['score'];
		if ($score=='') {
			$data_response['score']=0;
		}else{
			$data_response['score']=$score;
		}
		return $data_response;
	}
	public function get_score_desirable_2($std_ID,$course_teachingID){
		$data_response = array();
		$this->sql ="SELECT  *
					FROM tbl_desirable_2 			
					WHERE course_teachingID=$course_teachingID
					AND stdID='$std_ID'
					";
		$this->select();
		$this->setRows();
		$data_response['DataID']=$this->rows[0]['DataID'];
		$score=$this->rows[0]['score'];
		if ($score=='') {
			$data_response['score']=0;
		}else{
			$data_response['score']=$score;
		}
		return $data_response;
	}
	public function get_score_desirable_3($std_ID,$course_teachingID){
		$data_response = array();
		$this->sql ="SELECT  *
					FROM tbl_desirable_3 			
					WHERE course_teachingID=$course_teachingID
					AND stdID='$std_ID'
					";
		$this->select();
		$this->setRows();
		$data_response['DataID']=$this->rows[0]['DataID'];
		$score=$this->rows[0]['score'];
		if ($score=='') {
			$data_response['score']=0;
		}else{
			$data_response['score']=$score;
		}
		return $data_response;
	}
	public function get_score_desirable_4($std_ID,$course_teachingID){
		$data_response = array();
		$this->sql ="SELECT  *
					FROM tbl_desirable_4 			
					WHERE course_teachingID=$course_teachingID
					AND stdID='$std_ID'
					";
		$this->select();
		$this->setRows();
		$data_response['DataID']=$this->rows[0]['DataID'];
		$score=$this->rows[0]['score'];
		if ($score=='') {
			$data_response['score']=0;
		}else{
			$data_response['score']=$score;
		}
		return $data_response;
	}
	public function get_score_desirable_5($std_ID,$course_teachingID){
		$data_response = array();
		$this->sql ="SELECT  *
					FROM tbl_desirable_5 			
					WHERE course_teachingID=$course_teachingID
					AND stdID='$std_ID'
					";
		$this->select();
		$this->setRows();
		$data_response['DataID']=$this->rows[0]['DataID'];
		$score=$this->rows[0]['score'];
		if ($score=='') {
			$data_response['score']=0;
		}else{
			$data_response['score']=$score;
		}
		return $data_response;
	}
	public function get_score_desirable_6($std_ID,$course_teachingID){
		$data_response = array();
		$this->sql ="SELECT  *
					FROM tbl_desirable_6 			
					WHERE course_teachingID=$course_teachingID
					AND stdID='$std_ID'
					";
		$this->select();
		$this->setRows();
		$data_response['DataID']=$this->rows[0]['DataID'];
		$score=$this->rows[0]['score'];
		if ($score=='') {
			$data_response['score']=0;
		}else{
			$data_response['score']=$score;
		}
		return $data_response;
	}
	public function get_score_desirable_7($std_ID,$course_teachingID){
		$data_response = array();
		$this->sql ="SELECT  *
					FROM tbl_desirable_7 			
					WHERE course_teachingID=$course_teachingID
					AND stdID='$std_ID'
					";
		$this->select();
		$this->setRows();
		$data_response['DataID']=$this->rows[0]['DataID'];
		$score=$this->rows[0]['score'];
		if ($score=='') {
			$data_response['score']=0;
		}else{
			$data_response['score']=$score;
		}
		return $data_response;
	}
	public function get_score_desirable_8($std_ID,$course_teachingID){
		$data_response = array();
		$this->sql ="SELECT  *
					FROM tbl_desirable_8 			
					WHERE course_teachingID=$course_teachingID
					AND stdID='$std_ID'
					";
		$this->select();
		$this->setRows();
		$data_response['DataID']=$this->rows[0]['DataID'];
		$score=$this->rows[0]['score'];
		if ($score=='') {
			$data_response['score']=0;
		}else{
			$data_response['score']=$score;
		}
		return $data_response;
	}

	public function get_count_std($registed_courseID,$room_search,$status,$status_form){
		$this->sql ="SELECT  *
						FROM tbl_set_term_year 			
								";
		$this->select();
		$this->setRows();
		$year_set=$this->rows[0]['year'];

		if ($status==1) {
			$sql_condition="WHERE std_ID in(
								SELECT std_ID
								FROM tbl_std_class_room
								WHERE room='$room_search'
								AND status=1 
								AND year='$year_set'
							) 
							";
		}else{
			if ($status_form==25 || $status_form==26 || $status_form==27) {
				$sql_condition="WHERE std_ID in(
								SELECT std_ID
								FROM tbl_std_class_room
								WHERE room='$room_search'
								AND status=1 
								AND year='$year_set'
							) 
							";
			}else{
				$sql_condition="WHERE std_ID in(
								SELECT std_ID
								FROM tbl_std_class_room
								WHERE status=1 
								AND year='$year_set'
							) 
							
					";
			}
			
		}
		$this->sql ="	SELECT COUNT(stdID) AS count_std
						FROM tbl_course_teaching_std
						WHERE registed_courseID=$registed_courseID
						AND  stdID in(
							SELECT std_ID
							FROM tbl_student
							$sql_condition
						)	
					";
		$this->select();
		$this->setRows();
		return $this->rows[0]['count_std'];
	}
	public function get_attend($coures_id_list,$status,$room_search){
		$data_response = array();
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 	
					WHERE DataID=$coures_id_list					
					";
		$this->select();
		$this->setRows();
		$class_level=$this->rows[0]['class_level'];
		$status_form=$this->rows[0]['status_form'];
		if ($class_level=='p1' || $class_level=='p2' || $class_level=='p3' || $class_level=='p4' || $class_level=='p5' || $class_level=='p6') {
			$class_status='p';
		}else{
			$class_status='m';
		}
		

		$registed_course_id=$this->get_registed_course_id($coures_id_list);
		if ($status==1) {
			$sql_condition="AND room='$room_search'";
		}else{
			if ($status_form==25 || $status_form==26 || $status_form==27) {
				$sql_condition="AND room='$room_search'";
			}else{
				$sql_condition="";
			}
			
		}
		$this->sql ="SELECT  SUM(hr) as num_hr
					FROM tbl_set_attend_day 		
					WHERE registed_course_teachingID=$registed_course_id	
					$sql_condition
					ORDER BY attend_class_week_listID ASC
							";
		$this->select();
		$this->setRows();
		$num_day=$this->rows[0]['num_hr'];
		if ($class_status=='m') { //p and m
			$total_hr=20*$num_day;
			$set_page='port';

			$registed_courseID=$this->get_registed_courseID($coures_id_list);
			$count_std=$this->get_count_std($registed_courseID,$room_search,$status,$status_form);
			$set_loop_html=ceil($count_std/30);

			for ($i=1; $i <=$set_loop_html ; $i++) {
				$detail_std_attend_m=$this->get_detail_std_attend_m($coures_id_list,$room_search,$status,$num_day,$set_page,$i,$registed_courseID);
				$data_html.='
							<div style="page-break-after:always;">
								<page>
								  <p style="font-size:28px ;margin-left: 30px;margin-top: 80px;">บันทึกเวลาเข้าเรียน</p>
								<table cellspacing="0" style="width: 92%; text-align: center; font-size: 24px;margin-left: 30px;">
								              <thead>
								                
								                <tr class="text-middle">
								               
								                  <td rowspan="3" style="width: 5%;"><div style="transform: rotate(-90deg);white-space: nowrap;">เลขที่</div></td>
								               	  <td rowspan="3" style="width: 5%;"><div style="transform: rotate(-90deg);white-space: nowrap;">รหัส</div></td>
								   
								                  <td rowspan="3" style="width: 22%;vertical-align: middle;">ชื่อ-สกุล</td>
								                  <td colspan="20" style="width: 60%;padding: 5px;">'.$num_day.' ชั่วโมง/สัปดาห์</td>      
								                  <td rowspan="3" style="width: 5%;"><div >รวม <br>'.$total_hr.'<br> ชั่วโมง</div></td>
								                  <td rowspan="3" style="width: 5%;"><div style="transform: rotate(-90deg);white-space: nowrap;">ร้อยละ</div></td>
								                </tr>
								                <tr>
								                  <td colspan="20" style="width: 60%;padding: 5px;border-left:none;">สัปดาห์ที่</td>      
								                </tr> 
								                 <tr>
								                  <td style="border-left: none;width: 3%;">1</td>
								                  <td style="width: 3%;">2</td>
								                  <td style="width: 3%;">3</td>
								                  <td style="width: 3%;">4</td>
								                  <td style="width: 3%;">5</td>
								                  <td style="width: 3%;">6</td>
								                  <td style="width: 3%;">7</td>
								                  <td style="width: 3%;">8</td>
								                  <td style="width: 3%;">9</td>
								                  <td style="width: 3%;">10</td>
								                  <td style="width: 3%;">11</td>
								                  <td style="width: 3%;">12</td>
								                  <td style="width: 3%;">13</td>
								                  <td style="width: 3%;">14</td>
								                  <td style="width: 3%;">15</td>
								                  <td style="width: 3%;">16</td>
								                  <td style="width: 3%;">17</td>
								                  <td style="width: 3%;">18</td>
								                  <td style="width: 3%;">19</td>
								                  <td style="width: 3%;">20</td>               
								                </tr> 
								                
								              </thead>
								              <tbody >
								               '.$detail_std_attend_m['detail_std'].'
								              </tbody>
								            </table>							         
								        
								 </page>
								 </div>
				';
			}

			

		}elseif($status==2 || $class_status=='p'){
			$total_hr=40*$num_day;
			$set_page='land';

			$registed_courseID=$this->get_registed_courseID($coures_id_list);
			$count_std=$this->get_count_std($registed_courseID,$room_search,$status,$status_form);
			$set_loop_html=ceil($count_std/20);

			for ($i=1; $i <=$set_loop_html ; $i++) { 
				$detail_std_attend_p=$this->get_detail_std_attend_p($coures_id_list,$room_search,$status,$num_day,$set_page,$i,$registed_courseID);
				$data_html.='
							<div style="page-break-after:always;">
								 <page >
								   <div class="wrapper-page-attend-p-print" >
								    <table cellspacing="0"  style=" text-align: center; font-size: 22px;width:142%;">
								      <caption style="font-size:28px ;margin-left: 30px;margin-top: 0px;">บันทึกเวลาเข้าเรียน</caption>
								              <thead>
								                  <tr class="text-middle">
								                  <td rowspan="3" class="rotate" style="width: 0.1%;font-size: 22px;height: 0px;"><div >เลขที่</div></td>
								                  <td rowspan="3" class="rotate" style="width: 0.1%;font-size: 22px;height: 0px;"><div >รหัส</div></td>
								                  <td rowspan="3" style="width: 10%;vertical-align: middle;font-size: 22px;">ชื่อ-สกุล</td>
								                  <td colspan="40" style="width: 50%;padding: 5px;font-size: 22px;">'.$num_day.' ชั่วโมง/สัปดาห์</td>      
								                  <td rowspan="3" class="rotate" style="width: 0.1%;height: 0px;"><div style="margin-top: 30px;">รวม '.$total_hr.' ชั่วโมง</div></td>
								                  <td rowspan="3" class="rotate" style="width: 0.1%;height: 0px;"><div style="margin-top: 30px;">ร้อยละ</div></td>
								            
								                </tr>
								                <tr>
								                  <td colspan="40" style="width: 60%;padding: 5px;border-left:none;font-size: 22px;">สัปดาห์ที่</td>      
								                </tr> 
								                 <tr>
								                  <td style="border-left: none;width: 0.5%;">1</td>
								                  <td style="width: 0.5%;">2</td>
								                  <td style="width: 0.5%;">3</td>
								                  <td style="width: 0.5%;">4</td>
								                  <td style="width: 0.5%;">5</td>
								                  <td style="width: 0.5%;">6</td>
								                  <td style="width: 0.5%;">7</td>
								                  <td style="width: 0.5%;">8</td>
								                  <td style="width: 0.5%;">9</td>
								                  <td style="width: 0.5%;">10</td>
								                  <td style="width: 0.5%;">11</td>
								                  <td style="width: 0.5%;">12</td>
								                  <td style="width: 0.5%;">13</td>
								                  <td style="width: 0.5%;">14</td>
								                  <td style="width: 0.5%;">15</td>
								                  <td style="width: 0.5%;">16</td>
								                  <td style="width: 0.5%;">17</td>
								                  <td style="width: 0.5%;">18</td>
								                  <td style="width: 0.5%;">19</td>
								                  <td style="width: 0.5%;">20</td>  
								                  <td style="width: 0.5%;">21</td>  
								                  <td style="width: 0.5%;">22</td>  
								                  <td style="width: 0.5%;">23</td>  
								                  <td style="width: 0.5%;">24</td>  
								                  <td style="width: 0.5%;">25</td>  
								                  <td style="width: 0.5%;">26</td>  
								                  <td style="width: 0.5%;">27</td>  
								                  <td style="width: 0.5%;">28</td>  
								                  <td style="width: 0.5%;">29</td>  
								                  <td style="width: 0.5%;">30</td>  
								                  <td style="width: 0.5%;">31</td>  
								                  <td style="width: 0.5%;">32</td>  
								                  <td style="width: 0.5%;">33</td>  
								                  <td style="width: 0.5%;">34</td>  
								                  <td style="width: 0.5%;">35</td>  
								                  <td style="width: 0.5%;">36</td>  
								                  <td style="width: 0.5%;">37</td>  
								                  <td style="width: 0.5%;">38</td>  
								                  <td style="width: 0.5%;">39</td>  
								                  <td style="width: 0.5%;">40</td>               
								                </tr>      
								              </thead>
								              <tbody >
								                
								               '.$detail_std_attend_p['detail_std'].'
								                
								              </tbody>
								            </table>
								          </div>
								 </page>
								</div>
				';
			}
			/*for ($i=1; $i <= 40; $i++) { 
				if ($i==1) {
					$data_response['num_day'].='<td style="border-left:none;">'.$num_day.'</td>';
				}else{
					$data_response['num_day'].='<td>'.$num_day.'</td>';
				}
			}*/
					
		}

		/*$detail_std=$this->get_detail_std_attend($coures_id_list,$room_search,$status,$num_day,$set_page);
		$data_response['detail_std']=$detail_std['detail_std'];*/
		$data_response['data_html']=$data_html;
		
		$data_response['class_status']=$class_status;
		$data_response['set_page']=$set_page;
		$data_response['total_hr']=$total_hr;
		$data_response['num_day']=$num_day;
		return $data_response;
	}
public function get_detail_std_attend_m($coures_id_list_val,$room_search,$status,$num_day,$set_page,$i,$registed_courseID){
		$this->sql ="SELECT  *
					FROM tbl_set_term_year 			
							";
		$this->select();
		$this->setRows();
		$term_set=$this->rows[0]['term'];
		$year_set=$this->rows[0]['year'];
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 	
					WHERE DataID=$coures_id_list_val					
					";
		$this->select();
		$this->setRows();
		$class_level=$this->rows[0]['class_level'];
		$status_form=$this->rows[0]['status_form'];
		if ($class_level=='p1' || $class_level=='p2' || $class_level=='p3' || $class_level=='p4' || $class_level=='p5' || $class_level=='p6') {
			$term_set='1,2';
		}
		$registed_courseID=$this->get_registed_courseID($coures_id_list_val);
		if ($status==1) {
			$sql_condition="WHERE std_ID in(
								SELECT std_ID
								FROM tbl_std_class_room
								WHERE room='$room_search'
								AND status=1 
								AND year='$year_set'
							) 
							AND";
		}else{
			if ($status_form==25 || $status_form==26 || $status_form==27) {
				$sql_condition="WHERE std_ID in(
								SELECT std_ID
								FROM tbl_std_class_room
								WHERE room='$room_search'
								AND status=1 
								AND year='$year_set'
							) 
							AND";
			}else{
				$sql_condition="WHERE std_ID in(
								SELECT std_ID
								FROM tbl_std_class_room
								WHERE status=1 
								AND year='$year_set'
							) 
							AND
					";
			}
			
		}
		$find_start=($i-1)*30;

		$this->sql ="SELECT  *
					FROM tbl_student 	
					$sql_condition
					std_ID IN(
						SELECT stdID
						FROM tbl_course_teaching_std
						WHERE registed_courseID=$registed_courseID						
					)
					ORDER BY room ASC,
					CASE
						WHEN name_title LIKE '%dekchai%' THEN 0
				        WHEN name_title LIKE '%nai%' THEN 1
				        WHEN name_title LIKE '%dekying%' THEN 2
				        WHEN name_title LIKE '%nangsaw%'THEN 3
				        WHEN std_ID THEN 4      
				    END
					LIMIT $find_start,30
					";
		$this->select();
		$this->setRows();
		$no_std=$find_start+1;
		foreach($this->rows as $key => $value) {
			$std_ID=$value['std_ID'];
			$fname=$value['fname'];
			$lname=$value['lname'];
			$name_title_data=$value['name_title'];
			$name_title=$this->get_name_title($name_title_data);
		//	$attend_data=$this->get_attend_data($registed_course_teaching_id,$std_ID,$registed_courseID,$length_list_val,$class_level_status);
			$attend_data=$this->get_attend_data($std_ID,$registed_courseID,$status,$num_day,$set_page);
			
			$data_response['detail_std'].='<tr>
										<td>'.$no_std.'</td>
										<td>'.$std_ID.'</td>
										
						                  <td  style="text-align:left;">'.$name_title.$fname.' '.$lname.'</td>				                  
						                 
						                 '.$attend_data['total_attend_list'].' 
						                 <td>'.$attend_data['sum_attend'].'</td>
						                 <td>'.round($attend_data['sum_attend_per'],2).'</td>
						                            
						             </tr>
			';			
		$no_std++;				
		}
		
		return $data_response;
	}	
public function get_detail_std_attend_p($coures_id_list_val,$room_search,$status,$num_day,$set_page,$i,$registed_courseID){
			$this->sql ="SELECT  *
				FROM tbl_set_term_year 			
						";
			$this->select();
			$this->setRows();
			$term_set=$this->rows[0]['term'];
			$year_set=$this->rows[0]['year'];
			$this->sql ="SELECT  *
						FROM tbl_add_delete_course 	
						WHERE DataID=$coures_id_list_val					
						";
			$this->select();
			$this->setRows();
			$class_level=$this->rows[0]['class_level'];
			if ($class_level=='p1' || $class_level=='p2' || $class_level=='p3' || $class_level=='p4' || $class_level=='p5' || $class_level=='p6') {
				$term_set='1,2';
			}

			if ($status==1) {
				$sql_condition="WHERE std_ID in(
									SELECT std_ID
									FROM tbl_std_class_room
									WHERE room='$room_search'
									AND status=1 
									AND year='$year_set'
								) 
								AND";
			}else{
				$sql_condition="WHERE std_ID in(
									SELECT std_ID
									FROM tbl_std_class_room
									WHERE status=1 
									AND year='$year_set'
								) 
								AND
						";
			}
			$find_start=($i-1)*20;
			$this->sql ="SELECT  *
						FROM tbl_student 	
						$sql_condition
						std_ID IN(
							SELECT stdID
							FROM tbl_course_teaching_std
							WHERE registed_courseID=$registed_courseID						
						)
						ORDER BY room ASC,
						CASE
							WHEN name_title LIKE '%dekchai%' THEN 0
					        WHEN name_title LIKE '%nai%' THEN 1
					        WHEN name_title LIKE '%dekying%' THEN 2
					        WHEN name_title LIKE '%nangsaw%'THEN 3
					        WHEN std_ID THEN 4      
					    END
						LIMIT $find_start,20
						

						";
			$this->select();
			$this->setRows();
			$no_std=$find_start+1;
			foreach($this->rows as $key => $value) {
				$std_ID=$value['std_ID'];
				$fname=$value['fname'];
				$lname=$value['lname'];
				$name_title_data=$value['name_title'];
				$name_title=$this->get_name_title($name_title_data);
			//	$attend_data=$this->get_attend_data($registed_course_teaching_id,$std_ID,$registed_courseID,$length_list_val,$class_level_status);
				$attend_data=$this->get_attend_data($std_ID,$registed_courseID,$status,$num_day,$set_page);
				
				$data_response['detail_std'].='<tr>
											<td>'.$no_std.'</td>
											<td>'.$std_ID.'</td>
							                  <td  style="text-align:left;">'.$name_title.$fname.' '.$lname.'</td>			
							                 '.$attend_data['total_attend_list'].' 
							                 <td>'.$attend_data['sum_attend'].'</td>
							                 <td>'.round($attend_data['sum_attend_per'],2).'</td>
							                            
							             </tr>
				';			
			$no_std++;				
			}
		
		return $data_response;
	}

	
	public function get_attend_data($std_ID,$registed_courseID,$status,$num_day,$set_page){
			
			if ($set_page=='port') {
				$count_no_attend=0;
				for ($i=1; $i <=20 ; $i++) { 
					$this->sql ="SELECT  COUNT(*) as num_no_attend
						FROM tbl_attend_class_std 	
						WHERE week=$i
						AND course_teaching_std_id in(
							SELECT DataID
							FROM tbl_course_teaching_std
							WHERE registed_courseID=$registed_courseID
							AND stdID='$std_ID'
						)
						";
					$this->select();
					$this->setRows();
					$num_no_attend=$this->rows[0]['num_no_attend'];
					$total_attend=$num_day-$num_no_attend;
					$data_response['total_attend_list'].='<td>'.$total_attend.'</td>';
					$count_no_attend=$count_no_attend+$num_no_attend;					
				}
				$all_day=$num_day*20;
				$sum_attend=$all_day-$count_no_attend;
				$data_response['sum_attend']=$sum_attend;
				$data_response['sum_attend_per']=($sum_attend*100)/$all_day;
			}else{
				$count_no_attend=0;
				for ($i=1; $i <=40 ; $i++) { 
					$this->sql ="SELECT  COUNT(*) as num_no_attend
						FROM tbl_attend_class_std 	
						WHERE week=$i
						AND course_teaching_std_id in(
							SELECT DataID
							FROM tbl_course_teaching_std
							WHERE registed_courseID=$registed_courseID
							AND stdID='$std_ID'
						)
						";
					$this->select();
					$this->setRows();
					$num_no_attend=$this->rows[0]['num_no_attend'];
					$total_attend=$num_day-$num_no_attend;
					$data_response['total_attend_list'].='<td>'.$total_attend.'</td>';
					$count_no_attend=$count_no_attend+$num_no_attend;					
				}
				$all_day=$num_day*40;
				$sum_attend=$all_day-$count_no_attend;
				$data_response['sum_attend']=$sum_attend;
				$data_response['sum_attend_per']=($sum_attend*100)/$all_day;
			}
			return $data_response;
	}
	public function get_objective_list($coures_id_list_val,$room_search){
		$data_response = array();	

		$this->sql ="SELECT  COUNT(*) as find_end
					FROM tbl_objective_conclude 	
					WHERE courseID=$coures_id_list_val

					";
		$this->select();
		$this->setRows();	
		$find_end=$this->rows[0]['find_end'];	
		$this->sql ="SELECT  *
					FROM tbl_objective_conclude 	
					WHERE courseID=$coures_id_list_val
					ORDER BY no_order ASC
					";
		$this->select();
		$this->setRows();	
		$chk_loop=1;	
		$sum_score_main=0;
		foreach($this->rows as $key => $value) {
			$DataID=$value['DataID'];
			$no_order=$value['no_order'];
			$detail=$value['detail'];
			$score=$value['score'];
			$objective_conclude_detail.='
								<tr>
					                <td style="border: none;width:12%;">
					                  ตัวชี้วัดที่ '.$no_order.'
					                </td>
					                <td style="border: none;">
					                 	'.$detail.'
					                </td>
					              </tr>   
								';


			if ($chk_loop==1) {
				$ob_title_table_col.='
				<td style="border-left:none;">'.$no_order.'</td>';
				$score_title_table_col.='
				<td style="border-left:none;width: 1%;">'.$score.'</td>';
			}else{
				$ob_title_table_col.='
				<td >'.$no_order.'</td>';
				$score_title_table_col.='
				<td style="width: 1%;">'.$score.'</td>';
			}
					
			if ($find_end==$chk_loop) {
				$data_objective.=$DataID; 
			}else{
				$data_objective.=$DataID.'-'; 
			}
			$sum_score_main=$sum_score_main+$score;
			$chk_loop++;
		}

		$data_response['objective_conclude_detail']=$objective_conclude_detail;
		//$data_response['chk_loop']=$chk_loop;

		$this->sql ="SELECT  *
					FROM tbl_proportion 	
					WHERE courseID=$coures_id_list_val
					
					";
		$this->select();
		$this->setRows();
		$mid_exam=$this->rows[0]['mid_exam'];
		$final_exam=$this->rows[0]['final_exam'];
		$total_score_exam=$sum_score_main+$mid_exam+$final_exam;

		$chk_loop_set=$chk_loop-1;

		$registed_courseID=$this->get_registed_courseID($coures_id_list_val);
		$count_std=$this->get_count_std($registed_courseID,$room_search,1);

		if ($find_end<=10) {
			$set_loop_html=ceil($count_std/30);
		}else{
			$set_loop_html=ceil($count_std/20);
		}
		
		for ($i=1; $i <=$set_loop_html ; $i++) {		
			$detail_std=$this->get_detail_std($coures_id_list_val,$registed_courseID,$data_objective,$room_search,$i,$find_end);
				if ($find_end<=10) {
					if ($i==$set_loop_html) {
						$data_objective_list_box='
								<div style="top: 80px;position: relative;">
								    <p style="margin-left: 30px;font-size: 24px;">คำอธิบายตัวชี้วัด</p>
								    <table style="width: 80%;margin-left: 50px;margin-top: -10px;" >  
								      <tbody style="border: none;font-size: 22px;line-height: 0.9">
								      	'.$objective_conclude_detail.'
								      </tbody>
								    </table>
								    </div>
								';	
					}
					$data_response['data_html'].='
						<div style="page-break-after:always; position:relative;top: 80px;">
							<p style="font-size:28px ;margin-left: 30px;">การประเมินผลการเรียน</p>
							    <table cellspacing="0" style="width: 92%; text-align: center; font-size: 24px;margin-left: 30px;">
							              <thead>
							                <tr class="text-middle">
							                  <td rowspan="3" style="vertical-align: middle;width: 2%;">เลขที่</td>
							                  <td rowspan="3" style="vertical-align: middle;width: 2%;">รหัส</td>
							                  <td rowspan="3" style="vertical-align: middle;width: 20%;">ชื่อ-สกุล</td>
							                  <td colspan="'.$chk_loop_set.'" style="width: 50%">ตัวชี้วัดข้อที่</td>      
							                  <td class="rotate" rowspan="2" style="width: 0.1%;"><div style="margin-bottom: -24px;">สอบกลางภาค</div></td>
							                  <td class="rotate" rowspan="2" style="width: 0.1%;"><div style="margin-bottom: -24px;">สอบปลายภาค</div></td>
							                  <td class="rotate" rowspan="2" style="width: 0.1%;"><div style="margin-bottom: -24px;">คะแนนรวม</div></td>
							                  <td class="rotate" rowspan="2" style="width: 0.1%;"><div style="margin-bottom: -24px;">GPA</div></td>
							                </tr>

							                <tr>
							                  '.$ob_title_table_col.'
							                </tr>
							                  <tr>
							                  '.$score_title_table_col.'
							                  <td>'.$mid_exam.'</td>
							                  <td>'.$final_exam.'</td>
							                  <td>'.$total_score_exam.'</td>

							                  <td>4.0</td>
							                </tr>                                                
							              </thead>
							              <tbody >
							                '.$detail_std.'						              
							              </tbody>
							            </table>
							            '.$data_objective_list_box.'
							            
							        </div>
				';
			}else{
					$data_response['data_html'].='
							<div style="page-break-after:always;">
								 <page >
								   <div class="wrapper-page-ob table_original_long" >
								    <table cellspacing="0" style="width: 140%; text-align: center; font-size: 24px;margin-left: 30px;">
								    	<caption style="font-size:28px ;margin-left: 30px;margin-top: 0px;">การประเมินผลการเรียน</caption>
							              <thead>
							                <tr class="text-middle">
							                  <td rowspan="3" style="text-align:center;vertical-align: middle;width: 0.1%;">
							                  	<div style="transform: rotate(-90deg);white-space: nowrap;">เลขที่</div>
							                  </td>
							                  <td rowspan="3" style="text-align:center;vertical-align: middle;width: 0.1%;">
							                  
							                  	<div style="transform: rotate(-90deg);white-space: nowrap;">รหัสนักเรียน</div>
							                  	</td>
							                  <td rowspan="3" style="vertical-align: middle;width: 10%;">ชื่อ-สกุล</td>
							                  <td colspan="'.$chk_loop_set.'" style="width: 65%">ตัวชี้วัดข้อที่</td>      
							                  <td class="rotate" rowspan="2" style="width: 0.1%;"><div style="margin-bottom: -24px;">สอบกลางภาค</div></td>
							                  <td class="rotate" rowspan="2" style="width: 0.1%;"><div style="margin-bottom: -24px;">สอบปลายภาค</div></td>
							                  <td class="rotate" rowspan="2" style="width: 0.1%;"><div style="margin-bottom: -24px;">คะแนนรวม</div></td>
							                  <td class="rotate" rowspan="2" style="width: 0.1%;"><div style="margin-bottom: -24px;">GPA</div></td>
							                </tr>

							                <tr>
							                  '.$ob_title_table_col.'
							                </tr>
							                  <tr>
							                  '.$score_title_table_col.'
							                  <td>'.$mid_exam.'</td>
							                  <td>'.$final_exam.'</td>
							                  <td>'.$total_score_exam.'</td>

							                  <td>4.0</td>
							                </tr>                                                
							              </thead>
							              <tbody >
							                '.$detail_std.'						              
							              </tbody>
							            </table>
								          </div>
								 </page>
								</div>
					';
			}
		}
		if ($find_end>10) {
			$data_response['data_html'].='
						<div style="page-break-after:always;margin-top: 20px;">
						  <page>
						    <div style="top: 80px;position: relative;">
						    <p style="margin-left: 30px;font-size: 24px;">คำอธิบายตัวชี้วัด</p>
						    <table style="width: 80%;margin-left: 50px;margin-top: -10px;" >  
						      <tbody style="border: none;font-size: 22px;line-height: 0.9">
						       '.$objective_conclude_detail.'
						      </tbody>
						    </table>
						    </div>
						  </page>
						</div>
			';
		}
		
		$data_response['data_html'].=$room_search;
		return $data_response;
	}
	public function get_course_teachingID($DataID,$term_set,$year_set){
		$this->sql ="SELECT  *
					FROM tbl_registed_course_teaching 			
					WHERE registed_courseID in(
						SELECT DataID
						FROM tbl_registed_course
						WHERE courseID=$DataID
						AND term='$term_set'
						AND year='$year_set'
					)
							";
		$this->select();
		$this->setRows();
		return $this->rows[0]['DataID'];	
	}
	public function get_detail_std($coures_id_list_val,$registed_courseID,$data_objective,$room_search,$i,$find_end){
		$this->sql ="SELECT  *
					FROM tbl_set_term_year 			
							";
		$this->select();
		$this->setRows();
		$term_set=$this->rows[0]['term'];
		$year_set=$this->rows[0]['year'];	

		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 	
					WHERE DataID=$coures_id_list_val					
					";
		$this->select();
		$this->setRows();
		$class_level=$this->rows[0]['class_level'];
		if ($class_level=='p1' || $class_level=='p2' || $class_level=='p3' || $class_level=='p4' || $class_level=='p5' || $class_level=='p6') {
			$term_set='1,2';
		}

		
		if ($find_end<=10) {
			$find_start=($i-1)*30;
			$sql_condition="LIMIT $find_start,30";
		}else{
			$find_start=($i-1)*20;
			$sql_condition="LIMIT $find_start,20";
		}
		$this->sql ="SELECT  *
					FROM tbl_student 	
					WHERE std_ID in(
						SELECT std_ID
						FROM tbl_std_class_room
						WHERE room='$room_search'
						AND status=1 
						AND year='$year_set'
					)
					AND std_ID in(
						SELECT stdID
					    FROM tbl_course_teaching_std
					    WHERE registed_courseID = $registed_courseID
					)
					ORDER BY 
					CASE
						WHEN name_title LIKE '%dekchai%' THEN 0
				        WHEN name_title LIKE '%nai%' THEN 1
				        WHEN name_title LIKE '%dekying%' THEN 2
				        WHEN name_title LIKE '%nangsaw%'THEN 3
				        WHEN std_ID THEN 4      
				    END
					$sql_condition

					";
		$this->select();
		$this->setRows();		
		$no_std=$find_start+1;
		foreach($this->rows as $key => $value) {
			$std_ID=$value['std_ID'];
			$fname=$value['fname'];
			$lname=$value['lname'];
			$name_title_data=$value['name_title'];
			$name_title=$this->get_name_title($name_title_data);
			$class_level_status=$this->get_class_level_status($coures_id_list_val);
			$score_col=$this->get_score_col($std_ID,$data_objective,$registed_courseID);
			$score_col_total=$this->get_score_col_total($std_ID,$registed_courseID);

			$course_teachingID=$this->get_course_teachingID($coures_id_list_val,$term_set,$year_set);
			$score_mid_exam=$this->get_score_mid_exam($std_ID,$course_teachingID);
			$score_final_exam=$this->get_score_final_exam($std_ID,$course_teachingID);
			$sum_score=$score_col_total+$score_mid_exam['score']+$score_final_exam['score'];
			$score_exam=$score_mid_exam['score']+$score_final_exam['score'];
			$grade=$this->get_grade($score_exam,$score_col_total);
		
			$data_response.='<tr>
										<td>'.$no_std.'</td>
										<td>'.$std_ID.'</td>
						                  <td style="text-align:left;">'.$name_title.$fname.' '.$lname.'</td>
						                  '.$score_col.'
						                  <td>'.$score_mid_exam['score'].'</td>
						                  <td>'.$score_final_exam['score'].'</td>
						                 <td>'.$sum_score.'</td>
						                 <td>'.$grade.'</td>
						              
						             </tr>
			';
					
			$no_std++;
			
		}
		return $data_response;
	}
	public function get_score_final_exam($std_ID,$course_teachingID){
		$data_response = array();
		$this->sql ="SELECT  *
					FROM tbl_final_exam_score 			
					WHERE course_teachingID=$course_teachingID
					AND stdID='$std_ID'
					";
		$this->select();
		$this->setRows();
		$data_response['DataID']=$this->rows[0]['DataID'];
		$score=$this->rows[0]['score'];
		if ($score=='' || $score==0) {
				$data_response['score']=0;
			}else{
				if ($score==-1) {
					$data_response['score']='ร';
				}else{
					$data_response['score']=$score;
				}				
			}
		return $data_response;
	}
	public function get_score_mid_exam($std_ID,$course_teachingID){
		$data_response = array();
		$this->sql ="SELECT  *
					FROM tbl_mid_exam_score 			
					WHERE course_teachingID=$course_teachingID
					AND stdID='$std_ID'
					";
		$this->select();
		$this->setRows();
		$data_response['DataID']=$this->rows[0]['DataID'];
		$score=$this->rows[0]['score'];
		if ($score=='' || $score==0) {
				$data_response['score']=0;
			}else{
				if ($score==-1) {
					$data_response['score']='ร';
				}else{
					$data_response['score']=$score;
				}				
			}
		return $data_response;
	}
	public function get_score_col_total($std_ID,$registed_courseID){
		$num_of_i=0;
		$this->sql ="SELECT  count(score) as num_of_i
					FROM tbl_objective_score_std 	
					WHERE staID='$std_ID'
					AND registed_courseID=$registed_courseID
					AND score=-1;
					";
			$this->select();
			$this->setRows();	
			$num_of_i=$this->rows[0]['num_of_i'];
		$this->sql ="SELECT  SUM(score) as score_total
					FROM tbl_objective_score_std 	
					WHERE staID='$std_ID'
					AND registed_courseID=$registed_courseID
					";
			$this->select();
			$this->setRows();	
			$score_total_data=$this->rows[0]['score_total'];
			if ($score_total_data==0) {
				$score_total=0;	
			}else{
				$score_total=$score_total_data;	
			}
			return $score_total+$num_of_i;
	}
	public function get_score_col($std_ID,$data_objective,$registed_courseID){
		$arr_id = explode("-", $data_objective);	
		for ($i=0; $i < count($arr_id) ; $i++) { 
			if ($arr_id[$i]=='') {
				$arr_id[$i]=0;
			}else{
				$arr_id[$i]=$arr_id[$i];
			}
			$total_ob_conclude=$this->get_total_ob_conclude($arr_id[$i]);
			$this->sql ="SELECT  *
					FROM tbl_objective_score_std 	
					WHERE staID='$std_ID'
					AND objectiveID={$arr_id[$i]}
					AND registed_courseID=$registed_courseID
					";
			$this->select();
			$this->setRows();	
			$DataID=$this->rows[0]['DataID'];	
			$score=$this->rows[0]['score'];	
			if ($score=='' || $score==0) {
				$score=0;
			}else{
				if ($score==-1) {
					$score='ร';
				}else{
					$score=$score;
				}				
			}
			$data_response.='<td>'.$score.'</td>';
			$start_data++;
		}
		return $data_response;
	}
	public function get_total_ob_conclude($data_objective_ob){
		$this->sql ="SELECT  score
					FROM tbl_objective_conclude 	
					WHERE DataID=$data_objective_ob					
					";
			$this->select();
			$this->setRows();	
			return $this->rows[0]['score'];	
	}	
	public function get_grade_summary($coures_id_list_val,$room_search,$status){
		$data_response = array();	
		$this->sql ="SELECT  *
					FROM tbl_set_term_year 			
							";
		$this->select();
		$this->setRows();
		
		$year_set=$this->rows[0]['year'];
		$registed_courseID=$this->get_registed_courseID($coures_id_list_val);

		if ($status==1) {
			$sql_condition="WHERE std_ID in(
								SELECT std_ID
								FROM tbl_std_class_room
								WHERE room='$room_search'
								AND status=1 
								AND year='$year_set'
							) 
							AND";
		}else{
			$sql_condition="WHERE std_ID in(
								SELECT std_ID
								FROM tbl_std_class_room
								WHERE status=1 
								AND year='$year_set'
							) 
							AND
					";
		}
	
		$this->sql ="SELECT  count(*) as num_row_std
					FROM tbl_student 
					$sql_condition 
					std_ID in(
						SELECT stdID
						FROM tbl_course_teaching_std
						WHERE registed_courseID =$registed_courseID
					)
					";
		$this->select();
		$this->setRows();	
		$num_row_std=$this->rows[0]['num_row_std'];
		if ($num_row_std!=0) {	
			$data_response['num_all_std']=$this->rows[0]['num_row_std'];
		}else{
			$data_response['num_all_std']='-';
		}
		
		$this->sql ="SELECT  *
					FROM tbl_student 
					$sql_condition 
					std_ID in(
						SELECT stdID
						FROM tbl_course_teaching_std
						WHERE registed_courseID =$registed_courseID
					)
					ORDER BY std_ID ASC
					";
		$this->select();
		$this->setRows();	
		$data_i=0;
		$data_atte=0;
		$data_00=0;
		$data_10=0;
		$data_15=0;
		$data_20=0;
		$data_25=0;
		$data_30=0;
		$data_35=0;
		$data_40=0;

		$data_desirable_nopass=0;
		$data_desirable_pass=0;
		$data_desirable_good=0;
		$data_desirable_verygood=0;

		$data_read_think_write_nopass=0;
		$data_read_think_write_pass=0;
		$data_read_think_write_good=0;
		$data_read_think_write_verygood=0;

		$number=1;
		foreach($this->rows as $key => $value) {
			$std_ID=$value['std_ID'];
			$name_title_data=$value['name_title'];
			$name_title=$this->get_name_title($name_title_data);
			$fname=$value['fname'];
			$lname=$value['lname'];

			$comulative_score=$this->get_comulative_score($std_ID,$coures_id_list_val);
			$mid_exam_score=$this->get_mid_exam_score($std_ID,$coures_id_list_val);
			$final_exam_score=$this->get_final_exam_score($std_ID,$coures_id_list_val);
			$total_score_std=$comulative_score['sum_score_total_before']+$comulative_score['sum_score_total_after']+$mid_exam_score+$final_exam_score;
			$comulative_score_sum=$comulative_score['sum_score_total_before']+$comulative_score['sum_score_total_after'];
			$score_exam=$mid_exam_score+$final_exam_score;
			$grade_data=$this->get_grade($score_exam,$comulative_score_sum);

			$data_response['std_list'].='
					 <tr>
                  		<td>'.$number.'</td>
                  		<td>'.$name_title.$fname.' '.$lname.'</td>
                  		<td>'.$comulative_score['sum_score_total_before'].'</td>
                  		<td>'.$comulative_score['sum_score_total_after'].'</td>
                  		<td>'.$mid_exam_score.'</td>
                  		<td>'.$final_exam_score.'</td>
                 		<td>'.$total_score_std.'</td>
                  		<td>'.$grade_data.'</td>
                </tr>
			';
			$score_exam=$this->get_score_exam($std_ID,$coures_id_list_val);		
			$score_pick=$this->get_score_pick($std_ID,$coures_id_list_val);	
			$score_attend_class=$this->get_score_attend_class($std_ID,$coures_id_list_val);	
			//$data_response['score_attend_class']=$score_attend_class;
			if ($score_exam=='i' || $score_pick=='i' || $score_attend_class=='nopass') {
				if ($score_exam=='i' || $score_pick=='i') {
					$data_i++;
				}
				if ($score_attend_class=='nopass') {
					$data_atte++;
				}
				
			}else{
				$grade=$this->get_grade($score_exam,$score_pick);	
				$data_response['exam'].=$grade.'-';
				if ($grade=='0.0') {
					$data_00++;
				}elseif($grade=='1.0'){
					$data_10++;
				}elseif($grade=='1.5'){
					$data_15++;
				}elseif($grade=='2.0'){
					$data_20++;
				}elseif($grade=='2.5'){
					$data_25++;
				}elseif($grade=='3.0'){
					$data_30++;
				}elseif($grade=='3.5'){
					$data_35++;
				}elseif($grade=='4.0'){
					$data_40++;
				}		
			}	

		$desirable=$this->get_desirable($std_ID,$coures_id_list_val);	
			if ($desirable=='nopass') {
				$data_desirable_nopass++;
			}elseif($desirable=='pass'){
				$data_desirable_pass++;
			}elseif($desirable=='good'){
				$data_desirable_good++;
			}elseif($desirable=='verygood'){
				$data_desirable_verygood++;
			}
		$read_think_write=$this->get_read_think_write($std_ID,$coures_id_list_val);
			if ($read_think_write=='nopass') {
				$data_read_think_write_nopass++;
			}elseif($read_think_write=='pass'){
				$data_read_think_write_pass++;
			}elseif($read_think_write=='good'){
				$data_read_think_write_good++;
			}elseif($read_think_write=='verygood'){
				$data_read_think_write_verygood++;
			}
		$number++;
		}
		$data_response['data_read_think_write_nopass']=$data_read_think_write_nopass;
		$data_response['data_read_think_write_pass']=$data_read_think_write_pass;
		$data_response['data_read_think_write_good']=$data_read_think_write_good;
		$data_response['data_read_think_write_verygood']=$data_read_think_write_verygood;

		$data_response['data_desirable_nopass']=$data_desirable_nopass;
		$data_response['data_desirable_pass']=$data_desirable_pass;
		$data_response['data_desirable_good']=$data_desirable_good;
		$data_response['data_desirable_verygood']=$data_desirable_verygood;

		$data_response['data_i']=$data_i;
		$data_response['data_atte']=$data_atte;
		
		$data_response['data_00']=$data_00;
		$data_response['data_10']=$data_10;
		$data_response['data_15']=$data_15;
		$data_response['data_20']=$data_20;
		$data_response['data_25']=$data_25;
		$data_response['data_30']=$data_30;
		$data_response['data_35']=$data_35;
		$data_response['data_40']=$data_40;

		$propotion_total=$this->get_propotion_total($coures_id_list_val);
		
		$comulative_before_mid_title=$propotion_total['cumulative_before_mid'];
		$comulative_after_mid_title=$propotion_total['cumulative_after_mid'];
		$mid_exam_title=$propotion_total['mid_exam'];
		$final_exam_title=$propotion_total['final_exam'];

		$data_response['total_title']=$comulative_before_mid_title+$comulative_after_mid_title+$mid_exam_title+$final_exam_title;
		$data_response['comulative_before_mid_title']=$comulative_before_mid_title;
		$data_response['comulative_after_mid_title']=$comulative_after_mid_title;
		$data_response['mid_exam_title']=$mid_exam_title;
		$data_response['final_exam_title']=$final_exam_title;
		return $data_response;
	}
	public function get_name_title($name_title_data){
		if ($name_title_data=="dekchai") {
			$name_title="ด.ช.";
		}elseif($name_title_data=="dekying"){
			$name_title="ด.ญ.";
		}elseif($name_title_data=="nai"){
			$name_title="นาย";
		}elseif($name_title_data=="nangsaw"){
			$name_title="น.ส.";
		}
		return $name_title;
	}
	public function get_comulative_score($std_ID,$coures_id_list_val){
		$data_response = array();	
		$registed_courseID=$this->get_registed_courseID($coures_id_list_val);
		$this->sql ="SELECT  SUM(score) as sum_score_total_before
					FROM tbl_objective_score_std 			
					WHERE registed_courseID=$registed_courseID
					AND staID='$std_ID'
					AND objectiveID IN(
						SELECT DataID
						FROM tbl_objective_conclude
						WHERE proportion_status=1
					)
					";

		$this->select();
		$this->setRows();
		$data_response['sum_score_total_before']=$this->rows[0]['sum_score_total_before'];

		$this->sql ="SELECT  SUM(score) as sum_score_total_after
					FROM tbl_objective_score_std 			
					WHERE registed_courseID=$registed_courseID
					AND staID='$std_ID'
					AND objectiveID IN(
						SELECT DataID
						FROM tbl_objective_conclude
						WHERE proportion_status=2
					)
					";

		$this->select();
		$this->setRows();
		$data_response['sum_score_total_after']=$this->rows[0]['sum_score_total_after'];
		return $data_response;
	}
	public function get_mid_exam_score($std_ID,$coures_id_list_val){
		$registed_courseID=$this->get_registed_courseID($coures_id_list_val);
		$this->sql ="SELECT  *
					FROM tbl_mid_exam_score 			
					WHERE stdID='$std_ID'
					AND course_teachingID in(
						SELECT DataID
						FROM tbl_registed_course_teaching
						WHERE registed_courseID=$registed_courseID
					)
					";

		$this->select();
		$this->setRows();
		return $this->rows[0]['score'];
	}
	public function get_final_exam_score($std_ID,$coures_id_list_val){
		$registed_courseID=$this->get_registed_courseID($coures_id_list_val);
		$this->sql ="SELECT  *
					FROM tbl_final_exam_score 			
					WHERE stdID='$std_ID'
					AND course_teachingID in(
						SELECT DataID
						FROM tbl_registed_course_teaching
						WHERE registed_courseID=$registed_courseID
					)
					";

		$this->select();
		$this->setRows();
		return $this->rows[0]['score'];
	}
	public function get_propotion_total($coures_id_list_val){
		$data_response = array();	
		$this->sql ="SELECT  *
					FROM tbl_proportion 			
					WHERE courseID=$coures_id_list_val";
		$this->select();
		$this->setRows();
		$data_response['cumulative_before_mid']=$this->rows[0]['cumulative_before_mid'];
		$data_response['cumulative_after_mid']=$this->rows[0]['cumulative_after_mid'];
		
		$data_response['mid_exam']=$this->rows[0]['mid_exam'];
		$data_response['final_exam']=$this->rows[0]['final_exam'];
		$mid_exam=$this->rows[0]['mid_exam'];
		$final_exam=$this->rows[0]['final_exam'];
		$data_response['total']=$mid_exam+$final_exam;
		return $data_response;
	}
	public function search_course_detail($coures_id_list_val,$room_search){
		$data_response = array();	
		$this->sql ="SELECT  *
					FROM tbl_set_term_year 			
							";
		$this->select();
		$this->setRows();
		$year_set=$this->rows[0]['year'];
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 	
					WHERE DataID=$coures_id_list_val
					";
		$this->select();
		$this->setRows();		
		$data_response['courseID']=$this->rows[0]['courseID'];	
		$data_response['name']=$this->rows[0]['name'];	
		$data_response['unit']=$this->rows[0]['unit'];	
		$data_response['hr_learn']=$this->rows[0]['hr_learn'];	
		$data_response['status']=$this->rows[0]['status'];	
		$class_level_data=$this->rows[0]['class_level'];
		$class_level=$this->get_class_level_new($class_level_data);
		$data_response['class_level_co']=$class_level.'/'.$room_search;

		$this->sql ="SELECT  count(*) as num_row_std
					FROM tbl_student 
					WHERE std_ID in(
						SELECT std_ID
						FROM tbl_std_class_room
						WHERE room='$room_search'
						AND status=1 
						AND year='$year_set'
					)
					AND std_ID in(
						SELECT stdID
						FROM tbl_course_teaching_std
						WHERE registed_courseID in(
							SELECT DataID
							FROM tbl_registed_course
							WHERE courseID=$coures_id_list_val
						)
					)
					";
		$this->select();
		$this->setRows();	
		$data_response['num_all_std']=$this->rows[0]['num_row_std'];	

		$this->sql ="SELECT  *
					FROM tbl_student 
					WHERE std_ID in(
						SELECT std_ID
						FROM tbl_std_class_room
						WHERE room='$room_search'
						AND status=1 
						AND year='$year_set'
					)
					AND std_ID in(
						SELECT stdID
						FROM tbl_course_teaching_std
						WHERE registed_courseID in(
							SELECT DataID
							FROM tbl_registed_course
							WHERE courseID=$coures_id_list_val
						)
					)
					ORDER BY std_ID ASC
					";
		$this->select();
		$this->setRows();	
		$data_i=0;
		$data_atte=0;
		$data_00=0;
		$data_10=0;
		$data_15=0;
		$data_20=0;
		$data_25=0;
		$data_30=0;
		$data_35=0;
		$data_40=0;

		$data_desirable_nopass=0;
		$data_desirable_pass=0;
		$data_desirable_good=0;
		$data_desirable_verygood=0;

		$data_read_think_write_nopass=0;
		$data_read_think_write_pass=0;
		$data_read_think_write_good=0;
		$data_read_think_write_verygood=0;

		$number=1;
		foreach($this->rows as $key => $value) {
			$std_ID=$value['std_ID'];

			//$attend_class_std_list=$this->get_attend_class_std_list($std_ID,$coures_id_list_val);

			$score_exam=$this->get_score_exam($std_ID,$coures_id_list_val);		
			$score_pick=$this->get_score_pick($std_ID,$coures_id_list_val);	
			$score_attend_class=$this->get_score_attend_class($std_ID,$coures_id_list_val);	
			//$data_response['score_attend_class']=$score_attend_class;
			if ($score_exam=='i' || $score_pick=='i' || $score_attend_class=='nopass') {
				if ($score_exam=='i' || $score_pick=='i') {
					$data_i++;
				}
				if ($score_attend_class=='nopass') {
					$data_atte++;
				}
				
			}else{
				$grade=$this->get_grade($score_exam,$score_pick);	
				$data_response['exam'].=$grade.'-';
				if ($grade=='0.0') {
					$data_00++;
				}elseif($grade=='1.0'){
					$data_10++;
				}elseif($grade=='1.5'){
					$data_15++;
				}elseif($grade=='2.0'){
					$data_20++;
				}elseif($grade=='2.5'){
					$data_25++;
				}elseif($grade=='3.0'){
					$data_30++;
				}elseif($grade=='3.5'){
					$data_35++;
				}elseif($grade=='4.0'){
					$data_40++;
				}		
			}	
			$desirable=$this->get_desirable($std_ID,$coures_id_list_val);	
			if ($desirable=='nopass') {
				$data_desirable_nopass++;
			}elseif($desirable=='pass'){
				$data_desirable_pass++;
			}elseif($desirable=='good'){
				$data_desirable_good++;
			}elseif($desirable=='verygood'){
				$data_desirable_verygood++;
			}
			$read_think_write=$this->get_read_think_write($std_ID,$coures_id_list_val);
			if ($read_think_write=='nopass') {
				$data_read_think_write_nopass++;
			}elseif($read_think_write=='pass'){
				$data_read_think_write_pass++;
			}elseif($read_think_write=='good'){
				$data_read_think_write_good++;
			}elseif($read_think_write=='verygood'){
				$data_read_think_write_verygood++;
			}
			$number++;
		}
		$data_response['attend_class_std_list']=$attend_class_std_list;
		$data_response['number']=$number;
		$data_response['data_i']=$data_i;
		$data_response['data_atte']=$data_atte;
		
		$data_response['data_00']=$data_00;
		$data_response['data_10']=$data_10;
		$data_response['data_15']=$data_15;
		$data_response['data_20']=$data_20;
		$data_response['data_25']=$data_25;
		$data_response['data_30']=$data_30;
		$data_response['data_35']=$data_35;
		$data_response['data_40']=$data_40;

		$data_response['data_desirable_nopass']=$data_desirable_nopass;
		$data_response['data_desirable_pass']=$data_desirable_pass;
		$data_response['data_desirable_good']=$data_desirable_good;
		$data_response['data_desirable_verygood']=$data_desirable_verygood;

		$data_response['data_read_think_write_nopass']=$data_read_think_write_nopass;
		$data_response['data_read_think_write_pass']=$data_read_think_write_pass;
		$data_response['data_read_think_write_good']=$data_read_think_write_good;
		$data_response['data_read_think_write_verygood']=$data_read_think_write_verygood;

		echo json_encode($data_response);
	}
	public function get_read_think_write($std_ID,$coures_id_list_val){
		$registed_courseID=$this->get_registed_courseID($coures_id_list_val);
		$score_total=0;

		$score_read=0;
		$score_think=0;
		$score_write=0;
		$this->sql ="SELECT  *
					FROM tbl_read_score
					WHERE stdID='$std_ID'
					AND course_teachingID in(
						SELECT DataID
						FROM tbl_registed_course_teaching 	
						WHERE registed_courseID=$registed_courseID
					)
					";
		$this->select();
		$this->setRows();
		$score_read=$this->rows[0]['score'];

		$this->sql ="SELECT  *
					FROM tbl_think_score
					WHERE stdID='$std_ID'
					AND course_teachingID in(
						SELECT DataID
						FROM tbl_registed_course_teaching 	
						WHERE registed_courseID=$registed_courseID
					)
					";
		$this->select();
		$this->setRows();
		$score_think=$this->rows[0]['score'];

		$this->sql ="SELECT  *
					FROM tbl_write_score
					WHERE stdID='$std_ID'
					AND course_teachingID in(
						SELECT DataID
						FROM tbl_registed_course_teaching 	
						WHERE registed_courseID=$registed_courseID
					)
					";
		$this->select();
		$this->setRows();
		$score_write=$this->rows[0]['score'];

		$this->sql ="SELECT  *
					FROM tbl_rtw_4_score
					WHERE stdID='$std_ID'
					AND course_teachingID in(
						SELECT DataID
						FROM tbl_registed_course_teaching 	
						WHERE registed_courseID=$registed_courseID
					)
					";
		$this->select();
		$this->setRows();
		$score_rtw_4=$this->rows[0]['score'];

		$this->sql ="SELECT  *
					FROM tbl_rtw_5_score
					WHERE stdID='$std_ID'
					AND course_teachingID in(
						SELECT DataID
						FROM tbl_registed_course_teaching 	
						WHERE registed_courseID=$registed_courseID
					)
					";
		$this->select();
		$this->setRows();
		$score_rtw_5=$this->rows[0]['score'];

		$score_total=($score_read+$score_think+$score_write+$score_rtw_4+$score_rtw_5)/5;
			if ($score_total<1) {
				$data='nopass';
			}elseif($score_total<1.5){
				$data='pass';
			}elseif($score_total<2.5){
				$data='good';
			}elseif($score_total>=2.5){
				$data='verygood';
			}
		return $data;
	}
	public function get_desirable($std_ID,$coures_id_list_val){
		$registed_courseID=$this->get_registed_courseID($coures_id_list_val);
		$score_total=0;
		for ($i=1; $i <= 8 ; $i++) { 
				$this->sql ="SELECT  *
					FROM tbl_desirable_$i 
					WHERE stdID='$std_ID'
					AND course_teachingID in(
						SELECT DataID
						FROM tbl_registed_course_teaching 	
						WHERE registed_courseID=$registed_courseID
					)
					";
			$this->select();
			$this->setRows();
			$score=$this->rows[0]['score'];
			$score_total=$score_total+$score;
			}	
			$evaluation_score=$score_total/8;
			if ($evaluation_score<1) {
				$data='nopass';
			}elseif($evaluation_score<1.5){
				$data='pass';
			}elseif($evaluation_score<2.5){
				$data='good';
			}elseif($evaluation_score>=2.5){
				$data='verygood';
			}
		return $data;
	}
	public function get_registed_courseID($coures_id_list_val){
		$this->sql ="SELECT  *
					FROM tbl_set_term_year 			
							";
		$this->select();
		$this->setRows();
		$term_set=$this->rows[0]['term'];
		$year_set=$this->rows[0]['year'];

		$data_response = array();
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 	
					WHERE DataID=$coures_id_list_val					
					";
		$this->select();
		$this->setRows();
		$class_level=$this->rows[0]['class_level'];
		$status=$this->rows[0]['status'];
		if ($class_level=='p1' || $class_level=='p2' || $class_level=='p3' || $class_level=='p4' || $class_level=='p5' || $class_level=='p6' ) {
			$term_set='1,2';
		}
			
		$this->sql ="SELECT  *
					FROM tbl_registed_course 	
					WHERE courseID=$coures_id_list_val
					AND term='$term_set'
					AND year='$year_set'

					";
		$this->select();
		$this->setRows();		
		return $this->rows[0]['DataID'];	
	}
	public function get_grade($score_exam,$score_pick){
		$total=$score_exam+$score_pick;
		if ($total<50) {
			$grade='0.0';
		}elseif($total<55){
			$grade='1.0';
		}elseif($total<60){
			$grade='1.5';
		}elseif($total<65){
			$grade='2.0';
		}elseif($total<70){
			$grade='2.5';
		}elseif($total<75){
			$grade='3.0';
		}elseif($total<80){
			$grade='3.5';
		}elseif($total>=80){
			$grade='4.0';
		}
		return $grade;
	}
	public function get_score_attend_class($std_ID,$coures_id_list_val){
		$registed_courseID=$this->get_registed_courseID($coures_id_list_val);
		$this->sql ="SELECT COUNT(course_teaching_std_id) as sum_no_come
					FROM tbl_attend_class_std 
					WHERE course_teaching_std_id IN(
						SELECT DataID
						FROM tbl_course_teaching_std
						WHERE registed_courseID=$registed_courseID
						AND stdID=$std_ID
					)	
					AND set_attend_day_id IN(
						SELECT DataID
						FROM tbl_set_attend_day
						WHERE registed_course_teachingID IN(
							SELECT DataID
							FROM tbl_registed_course_teaching
							WHERE registed_courseID=$registed_courseID
						)
					)
					";
		$this->select();
		$this->setRows();	
		$sum_no_come=$this->rows[0]['sum_no_come'];
		
		$registed_course_teaching_id=$this->get_registed_course_id($coures_id_list_val);
		$this->sql ="SELECT  SUM(hr) as num_hr
					FROM tbl_set_attend_day 	
					WHERE registed_course_teachingID=$registed_course_teaching_id
					";
		$this->select();
		$this->setRows();
		$num_hr=$this->rows[0]['num_hr'];	
		$class_level_status=$this->get_class_level_status($coures_id_list_val);
		if ($class_level_status=='p') {
			$week_all=40;
		}else{
			$week_all=20;
		}
		$total_day=$num_hr*$week_all;
		$total_attend_per=round((($total_day-$sum_no_come)*100)/$total_day);

		if ($total_attend_per>=80) {
			$find_80_per='pass';
		}else{
			$find_80_per='nopass';
		}
		/*
		$this->sql ="SELECT *
					FROM tbl_set_count_adttend_class 
					WHERE registed_courseID=$registed_courseID		
					";
		$this->select();
		$this->setRows();	
		$week_name=$this->rows[0]['week_name'];

		$this->sql ="SELECT  SUM(score_status) as sum_score
					FROM tbl_attend_class 
					WHERE week BETWEEN 1 AND $week_name
					AND course_teaching_stdID in(
						SELECT DataID
						FROM tbl_course_teaching_std
						WHERE registed_courseID=$registed_courseID
						AND stdID='$std_ID'
					)					
					";
		$this->select();
		$this->setRows();	
		$sum_score=$this->rows[0]['sum_score'];
		$data_must_pass=floor((80*$week_name)/100);
		if ($sum_score>=$data_must_pass) {
			$find_80_per='pass';
		}else{
			$find_80_per='nopass';
		}*/
		return $find_80_per;
	}
	public function get_registed_course_id($coures_id_list){
		$this->sql ="SELECT  *
					FROM tbl_set_term_year 			
							";
		$this->select();
		$this->setRows();
		$term_set=$this->rows[0]['term'];
		$year_set=$this->rows[0]['year'];
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 	
					WHERE DataID=$coures_id_list
					
					";
		$this->select();
		$this->setRows();		
		$class_level_data=$this->rows[0]['class_level'];
		$status=$this->rows[0]['status'];	
		if ($class_level_data=='p1' || $class_level_data=='p2' || $class_level_data=='p3' || $class_level_data=='p4' || $class_level_data=='p5' || $class_level_data=='p6' ) {
			$term_set='1,2';
		}

		$this->sql ="SELECT  *
					FROM tbl_registed_course_teaching 	
					WHERE registed_courseID in(
						SELECT DataID
						FROM tbl_registed_course 
						WHERE term='$term_set'
						AND year='$year_set'
						AND courseID=$coures_id_list
					)
					";
		$this->select();
		$this->setRows();
		return $this->rows[0]['DataID'];	
	}
	public function get_class_level_status($coures_id_list_val){
		$data_response = array();	
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 	
					WHERE DataID=$coures_id_list_val
					";
		$this->select();
		$this->setRows();		
		$class_level=$this->rows[0]['class_level'];	
		$status=$this->rows[0]['status'];	
		if ($class_level=='p1' || $class_level=='p2' || $class_level=='p3' || $class_level=='p4' || $class_level=='p5' || $class_level=='p6') {
			$data='p';
		}else{
			$data='m';
		}
		return $data;
	}
	public function get_score_pick($std_ID,$coures_id_list_val){
		$registed_courseID=$this->get_registed_courseID($coures_id_list_val);
		$num_of_i=0;
		$this->sql ="SELECT  COUNT(score) as num_of_i
					FROM tbl_objective_score_std 	
					WHERE staID='$std_ID'
					AND registed_courseID=$registed_courseID
					AND score=-1
					";
		$this->select();
		$this->setRows();
		$num_of_i=$this->rows[0]['num_of_i'];			
		$this->sql ="SELECT  SUM(score) as score_total
					FROM tbl_objective_score_std 	
					WHERE staID='$std_ID'
					AND registed_courseID=$registed_courseID
					";
		$this->select();
		$this->setRows();	
		$score_total_data=$this->rows[0]['score_total'];
		if ($num_of_i>0) {
			$total='i';
		}else{
			$total=$score_total_data;
		}
			return $total;
	}
	public function get_score_exam($std_ID,$coures_id_list_val){	
	$this->sql ="SELECT  *
					FROM tbl_set_term_year 			
							";
		$this->select();
		$this->setRows();
		$term_set=$this->rows[0]['term'];
		$year_set=$this->rows[0]['year'];
		$data_response = array();	
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 	
					WHERE DataID=$coures_id_list_val
					
					";
		$this->select();
		$this->setRows();		
		$class_level_data=$this->rows[0]['class_level'];	
		$data_response['class_level']=$this->get_class_level_new($class_level_data);
		if ($class_level_data=='p1' || $class_level_data=='p2' || $class_level_data=='p3' || $class_level_data=='p4' || $class_level_data=='p5' || $class_level_data=='p6' ) {
			$term_set='1,2';
		}	
		$mid_status=0;
		$final_status=0;
		$this->sql ="SELECT  COUNT(score) as num_of_i_mid
					FROM tbl_mid_exam_score
					WHERE stdID='$std_ID'
					AND score=-1
					AND course_teachingID in(
						SELECT DataID
						FROM tbl_registed_course_teaching
						WHERE registed_courseID in(
							SELECT DataID
							FROM tbl_registed_course
							WHERE courseID=$coures_id_list_val
							AND term='$term_set'
							AND year='$year_set'
						)
					)
					";
		$this->select();
		$this->setRows();	
		$num_of_i_mid=$this->rows[0]['num_of_i_mid'];
		if ($num_of_i_mid>0) {
			$mid_status=-1;
		}
		$this->sql ="SELECT  *
					FROM tbl_mid_exam_score
					WHERE stdID='$std_ID'
					AND course_teachingID in(
						SELECT DataID
						FROM tbl_registed_course_teaching
						WHERE registed_courseID in(
							SELECT DataID
							FROM tbl_registed_course
							WHERE courseID=$coures_id_list_val
							AND term='$term_set'
							AND year='$year_set'
						)
					)
					";
		$this->select();
		$this->setRows();	
		$mid_exam_score=$this->rows[0]['score'];
		$this->sql ="SELECT  COUNT(score) as num_of_i_final
					FROM tbl_final_exam_score
					WHERE stdID='$std_ID'
					AND score=-1
					AND course_teachingID in(
						SELECT DataID
						FROM tbl_registed_course_teaching
						WHERE registed_courseID in(
							SELECT DataID
							FROM tbl_registed_course
							WHERE courseID=$coures_id_list_val
							AND term='$term_set'
							AND year='$year_set'
						)
					)
					";
		$this->select();
		$this->setRows();	
		$num_of_i_final=$this->rows[0]['num_of_i_final'];

		if ($num_of_i_final>0) {
			$final_status=-1;
		}
		$this->sql ="SELECT  *
					FROM tbl_final_exam_score 
					WHERE stdID='$std_ID'
					AND course_teachingID in(
						SELECT DataID
						FROM tbl_registed_course_teaching
						WHERE registed_courseID in(
							SELECT DataID
							FROM tbl_registed_course
							WHERE courseID=$coures_id_list_val
							AND term='$term_set'
							AND year='$year_set'
						)
					)
					";
		$this->select();
		$this->setRows();	
		$final_exam_score=$this->rows[0]['score'];
		if ($mid_status==-1 || $final_status==-1) {
			$total='i';
		}else{
			$total=$mid_exam_score+$final_exam_score;
		}
		return $total;
	}
	public function get_class_level($coures_id_list_val){
		$this->sql ="SELECT  *
					FROM tbl_set_term_year 			
							";
		$this->select();
		$this->setRows();
		$term_set=$this->rows[0]['term'];
		$year_set=$this->rows[0]['year'];
		$data_response = array();	
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 	
					WHERE DataID=$coures_id_list_val
					
					";
		$this->select();
		$this->setRows();		
		$class_level_data=$this->rows[0]['class_level'];
		$status=$this->rows[0]['status'];
		$status_form=$this->rows[0]['status_form'];
		$data_response['status']=$status;
		$data_response['status_form']=$status_form;
		$data_response['class_level']=$this->get_class_level_new($class_level_data);
		if ($class_level_data=='p1' || $class_level_data=='p2' || $class_level_data=='p3' || $class_level_data=='p4' || $class_level_data=='p5' || $class_level_data=='p6' ) {
			$term_set='1,2';
		}

		$user_status=$_SESSION['ss_status'];
		$user_id=$_SESSION['ss_user_id'];
		if ($user_status==1) {
			$this->sql ="SELECT  room
					FROM tbl_room_teacher 
					WHERE course_teacherID in(
						SELECT DataID
						FROM tbl_course_teacher
						WHERE teacher_id=$user_id
						AND regis_course_id in(
							SELECT DataID
							FROM tbl_registed_course
							WHERE courseID=$coures_id_list_val
                            AND term='$term_set'
                            AND year='$year_set'
						)
						
					)	
					ORDER BY room ASC
						";
		}else{
			$this->sql ="
						SELECT distinct room
						FROM tbl_std_class_room
						WHERE std_ID in(
							SELECT std_ID
							FROM tbl_student 
							WHERE std_ID in(
								SELECT stdID
								FROM tbl_course_teaching_std
								WHERE registed_courseID in(
									SELECT DataID
									FROM tbl_registed_course
									WHERE courseID=$coures_id_list_val
	                                AND term='$term_set'
	                                AND year='$year_set'
									)
							)
						)
						ORDER BY room ASC
							";
		}
			$this->select();
			$this->setRows();
			foreach($this->rows as $key => $value) {
				$room=$value['room'];
				$data_response['room'].=' <option value='.$room.'>'.$room.'</option>';
			}
		return json_encode($data_response);
	}
	public function get_data_dicision($DataID,$courseID_long,$class_level,$status,$term_set,$year_set){
		if ($class_level=='p1' || $class_level=='p2' || $class_level=='p3' || $class_level=='p4' || $class_level=='p5' || $class_level=='p6' ) {
			$data_response='<option value="'.$DataID.'">'.$courseID_long.'</option>';
		}else{
		$this->sql ="SELECT  COUNT(*) as num_row
					FROM tbl_registed_course 		
					WHERE courseID=$DataID
					AND term='$term_set'
					AND year='$year_set'

							";
		$this->select();
		$this->setRows();
		$num_row=$this->rows[0]['num_row'];
			if ($num_row==1) {
				$data_response='<option value="'.$DataID.'">'.$courseID_long.'</option>';
			}
		}
		return $data_response;
			
	}
	public function get_coures_id_list($data_id,$data_room){
		$user_id=$_SESSION['ss_user_id'];
		$data_response = array();	
		$this->sql ="SELECT  *
					FROM tbl_set_term_year 			
							";
		$this->select();
		$this->setRows();
		$term_set=$this->rows[0]['term'];
		$year_set=$this->rows[0]['year'];
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 		
                    WHERE DataID in(
                    	SELECT courseID
                        FROM tbl_registed_course
                        WHERE year='$year_set'                   
                        AND DataID IN(
                        	SELECT registed_courseID
                            FROM tbl_registed_course_teaching
                        )
                        AND DataID in(
                            	SELECT regis_course_id
								FROM tbl_course_teacher
								WHERE teacher_id=$user_id
                            )
                    )
					ORDER BY courseID ASC	
							";
		$this->select();
		$this->setRows();
		foreach($this->rows as $key => $value) {
			$DataID=$value['DataID'];
			
			$courseID_long=$value['courseID'];
			$status=$value['status'];
			$class_level=$value['class_level'];
			$data_dicision=$this->get_data_dicision($DataID,$courseID_long,$class_level,$status,$term_set,$year_set);

			$data_response['coures_id_list'].=$data_dicision;
		}
		return json_encode($data_response);
	}
	public function get_class_level_new($class_level_data){
		if ($class_level_data=="p1") {
			$class_level="ป.1";
		}elseif($class_level_data=="p2"){
			$class_level="ป.2";	
		}elseif($class_level_data=="p3"){
			$class_level="ป.3";	
		}elseif($class_level_data=="p4"){
			$class_level="ป.4";	
		}elseif($class_level_data=="p5"){
			$class_level="ป.5";	
		}elseif($class_level_data=="p6"){
			$class_level="ป.6";	
		}elseif($class_level_data=="m1"){
			$class_level="ม.1";	
		}elseif($class_level_data=="m2"){
			$class_level="ม.2";	
		}elseif($class_level_data=="m3"){
			$class_level="ม.3";	
		}elseif($class_level_data=="m4"){
			$class_level="ม.4";	
		}elseif($class_level_data=="m5"){
			$class_level="ม.5";	
		}elseif($class_level_data=="m6"){
			$class_level="ม.6";	
		}
		return $class_level;
	}
}<file_sep>/modules/report/major_form.php
<link href="../../assets/css/bootstrap.css" rel="stylesheet" type="text/css">
<link href="../../assets/css/custom.css" rel="stylesheet" type="text/css">
<link href="../../assets/css/margin-padding.css" rel="stylesheet" type="text/css">
<link href="../../assets/css/responsive.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
 table {
    border-collapse: collapse;
}

td, th {
    border: 1px solid black;
    padding: 5px;
}
-->
</style>
<?php
 @session_start();
    include('logo.php');
    require_once('../../init.php');
    include('class_modules.php');
    $class_data = new ClassData();
  ?>
<page orientation="landscape">
    <img style="margin :10px 0px 10px 495px;display:block;width: 80px;height: 80px;"src="<?php echo $image_logo ?>">
   	<br>
   	<div class="col-sm-12 text-center " style="font-size: 22px;margin-top: -5px;">
      <p style="margin-top: -8px;"><span class="text-bold">รายงานการประเมินผลการเรียน กลุ่มสาระการเรียนรู้</span> ภาษาไทย</p>
      <p class="text-bold " style="margin-top: -8px;">โรงเรียนเทศบาลวัดสระทอง</p>
      <p style="margin-top: -8px;"> <span class="text-bold">ภาคเรียนที่ </span> 1  <span class="text-bold">ปีการศึกษา</span> 2560</p>
    
    </div>
     <table cellspacing="0" style="width: 94%; text-align: center; font-size: 11pt;margin-left: 50px;border: 1px solid black;margin-top: 35px;">
              <thead >
                <tr class="text-middle" style="background-color: #e0e0e0;">
                  <td rowspan="2"  style="  vertical-align: middle;width: 6px;font-weight: bold;">ที่</td>
                  <td rowspan="2"  style="  vertical-align: middle;width: 8%;font-weight: bold;">ระดับชั้น</td>
                  <td rowspan="2"  style="  vertical-align: middle;width: 12%;font-weight: bold;">รหัสวิชา</td>
                 

                  <td colspan="10" style="width: 35%;padding: 5px;font-weight: bold;">ระดับผลการเรียน</td>    
                  <td colspan="4" style="width:17%;padding: 5px;font-weight: bold;">คุณลักษณะฯ</td> 
                  <td colspan="4" style="width: 17%;padding: 5px;font-weight: bold;">อ่าน เขียน คิดฯ</td>
                  <td rowspan="2"  style="  vertical-align: middle;width: 15px;font-weight: bold;">รวม</td>
                </tr>
                <tr style="background-color: #e0e0e0;">
                  
                  <td style="width: 3.5%;border-left: none;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                
                </tr>
              </thead>
              <tbody>
                <tr>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>                
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>                
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                </tr>
               
                <tr>
                  <td colspan="3" class="text-bold">รวม</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>                
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>                
                  <td >1</td>            
                </tr>
                <tr>
                  <td colspan="3" class="text-bold">ร้อยละ</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>                
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>                
                  <td >1</td>            
                </tr>
              </tbody>
    </table> 
    <table cellspacing="0" style="width: 94%; text-align: center; font-size: 11pt;margin-left: 50px;border: 1px solid black;margin-top: 35px;">
              <thead >
                <tr class="text-middle" style="background-color: #e0e0e0;">
                  <td rowspan="2"  style="  vertical-align: middle;width: 6px;font-weight: bold;">ที่</td>
                  <td rowspan="2"  style="  vertical-align: middle;width: 8%;font-weight: bold;">ระดับชั้น</td>
                  <td rowspan="2"  style="  vertical-align: middle;width: 12%;font-weight: bold;">รหัสวิชา</td>
                 

                  <td colspan="10" style="width: 35%;padding: 5px;font-weight: bold;">ระดับผลการเรียน</td>    
                  <td colspan="4" style="width:17%;padding: 5px;font-weight: bold;">คุณลักษณะฯ</td> 
                  <td colspan="4" style="width: 17%;padding: 5px;font-weight: bold;">อ่าน เขียน คิดฯ</td>
                  <td rowspan="2"  style="  vertical-align: middle;width: 15px;font-weight: bold;">รวม</td>
                </tr>
                <tr style="background-color: #e0e0e0;">
                  
                  <td style="width: 3.5%;border-left: none;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                
                </tr>
              </thead>
              <tbody>
                <tr>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>                
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>                
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                </tr>
               
                <tr>
                  <td colspan="3" class="text-bold">รวม</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>                
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>                
                  <td >1</td>            
                </tr>
                <tr>
                  <td colspan="3" class="text-bold">ร้อยละ</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>                
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>                
                  <td >1</td>            
                </tr>
              </tbody>
    </table> 
    <table cellspacing="0" style="width: 94%; text-align: center; font-size: 11pt;margin-left: 50px;border: 1px solid black;margin-top: 35px;">
              <thead >
                <tr class="text-middle" style="background-color: #e0e0e0;">
                  <td rowspan="2"  style="  vertical-align: middle;width: 6px;font-weight: bold;">ที่</td>
                  <td rowspan="2"  style="  vertical-align: middle;width: 8%;font-weight: bold;">ระดับชั้น</td>
                  <td rowspan="2"  style="  vertical-align: middle;width: 12%;font-weight: bold;">รหัสวิชา</td>
                 

                  <td colspan="10" style="width: 35%;padding: 5px;font-weight: bold;">ระดับผลการเรียน</td>    
                  <td colspan="4" style="width:17%;padding: 5px;font-weight: bold;">คุณลักษณะฯ</td> 
                  <td colspan="4" style="width: 17%;padding: 5px;font-weight: bold;">อ่าน เขียน คิดฯ</td>
                  <td rowspan="2"  style="  vertical-align: middle;width: 15px;font-weight: bold;">รวม</td>
                </tr>
                <tr style="background-color: #e0e0e0;">
                  
                  <td style="width: 3.5%;border-left: none;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                
                </tr>
              </thead>
              <tbody>
                <tr>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>                
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>                
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                </tr>
               
                <tr>
                  <td colspan="3" class="text-bold">รวม</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>                
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>                
                  <td >1</td>            
                </tr>
                <tr>
                  <td colspan="3" class="text-bold">ร้อยละ</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>                
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>                
                  <td >1</td>            
                </tr>
              </tbody>
    </table> 
    <table cellspacing="0" style="width: 94%; text-align: center; font-size: 11pt;margin-left: 50px;border: 1px solid black;margin-top: 35px;">
              <thead >
                <tr class="text-middle" style="background-color: #e0e0e0;">
                  <td rowspan="2"  style="  vertical-align: middle;width: 6px;font-weight: bold;">ที่</td>
                  <td rowspan="2"  style="  vertical-align: middle;width: 8%;font-weight: bold;">ระดับชั้น</td>
                  <td rowspan="2"  style="  vertical-align: middle;width: 12%;font-weight: bold;">รหัสวิชา</td>
                 

                  <td colspan="10" style="width: 35%;padding: 5px;font-weight: bold;">ระดับผลการเรียน</td>    
                  <td colspan="4" style="width:17%;padding: 5px;font-weight: bold;">คุณลักษณะฯ</td> 
                  <td colspan="4" style="width: 17%;padding: 5px;font-weight: bold;">อ่าน เขียน คิดฯ</td>
                  <td rowspan="2"  style="  vertical-align: middle;width: 15px;font-weight: bold;">รวม</td>
                </tr>
                <tr style="background-color: #e0e0e0;">
                  
                  <td style="width: 3.5%;border-left: none;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                
                </tr>
              </thead>
              <tbody>
                <tr>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>                
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>                
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                </tr>
               
                <tr>
                  <td colspan="3" class="text-bold">รวม</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>                
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>                
                  <td >1</td>            
                </tr>
                <tr>
                  <td colspan="3" class="text-bold">ร้อยละ</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>                
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>                
                  <td >1</td>            
                </tr>
              </tbody>
    </table> 
    <table cellspacing="0" style="width: 94%; text-align: center; font-size: 11pt;margin-left: 50px;border: 1px solid black;margin-top: 35px;">
              <thead >
                <tr class="text-middle" style="background-color: #e0e0e0;">
                  <td rowspan="2"  style="  vertical-align: middle;width: 6px;font-weight: bold;">ที่</td>
                  <td rowspan="2"  style="  vertical-align: middle;width: 8%;font-weight: bold;">ระดับชั้น</td>
                  <td rowspan="2"  style="  vertical-align: middle;width: 12%;font-weight: bold;">รหัสวิชา</td>
                 

                  <td colspan="10" style="width: 35%;padding: 5px;font-weight: bold;">ระดับผลการเรียน</td>    
                  <td colspan="4" style="width:17%;padding: 5px;font-weight: bold;">คุณลักษณะฯ</td> 
                  <td colspan="4" style="width: 17%;padding: 5px;font-weight: bold;">อ่าน เขียน คิดฯ</td>
                  <td rowspan="2"  style="  vertical-align: middle;width: 15px;font-weight: bold;">รวม</td>
                </tr>
                <tr style="background-color: #e0e0e0;">
                  
                  <td style="width: 3.5%;border-left: none;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                
                </tr>
              </thead>
              <tbody>
                <tr>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>                
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>                
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                </tr>
               
                <tr>
                  <td colspan="3" class="text-bold">รวม</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>                
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>                
                  <td >1</td>            
                </tr>
                <tr>
                  <td colspan="3" class="text-bold">ร้อยละ</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>                
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>                
                  <td >1</td>            
                </tr>
              </tbody>
    </table> 
    <table cellspacing="0" style="width: 94%; text-align: center; font-size: 11pt;margin-left: 50px;border: 1px solid black;margin-top: 35px;">
              <thead >
                <tr class="text-middle" style="background-color: #e0e0e0;">
                  <td rowspan="2"  style="  vertical-align: middle;width: 6px;font-weight: bold;">ที่</td>
                  <td rowspan="2"  style="  vertical-align: middle;width: 8%;font-weight: bold;">ระดับชั้น</td>
                  <td rowspan="2"  style="  vertical-align: middle;width: 12%;font-weight: bold;">รหัสวิชา</td>
                 

                  <td colspan="10" style="width: 35%;padding: 5px;font-weight: bold;">ระดับผลการเรียน</td>    
                  <td colspan="4" style="width:17%;padding: 5px;font-weight: bold;">คุณลักษณะฯ</td> 
                  <td colspan="4" style="width: 17%;padding: 5px;font-weight: bold;">อ่าน เขียน คิดฯ</td>
                  <td rowspan="2"  style="  vertical-align: middle;width: 15px;font-weight: bold;">รวม</td>
                </tr>
                <tr style="background-color: #e0e0e0;">
                  
                  <td style="width: 3.5%;border-left: none;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                  <td style="width: 3.5%;">1</td>
                
                </tr>
              </thead>
              <tbody>
                <tr>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>                
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>                
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                </tr>
               
                <tr>
                  <td colspan="3" class="text-bold">รวม</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>                
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>                
                  <td >1</td>            
                </tr>
                <tr>
                  <td colspan="3" class="text-bold">ร้อยละ</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>                
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>                
                  <td >1</td>            
                </tr>
              </tbody>
    </table> 

    <div style="margin-left: 740px;margin-top: 60px;">
      <p>.................................................................หัวหน้ากลุ่มสาระ </p>
     
      <p style="margin-left: 2px;">(</p> <p style="margin-top: -24px;margin-left:140px;"> )</p>

      <p style="margin-left: 12px;">................/................/...................</p>
    </div>
   
</page><file_sep>/modules/print_tset/class_modules.php
<?php 
class ClassData extends Databases {
	public function get_attend_class_std_list($std_ID,$coures_id_list_val){
		$data_response="
				
		";
		return $data_response;
	}
	public function search_course_detail($coures_id_list_val,$room_search){
		$data_response = array();	
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 	
					WHERE DataID=$coures_id_list_val
					";
		$this->select();
		$this->setRows();		
		$data_response['courseID']=$this->rows[0]['courseID'];	
		$data_response['name']=$this->rows[0]['name'];	
		$data_response['unit']=$this->rows[0]['unit'];	
		$data_response['hr_learn']=$this->rows[0]['hr_learn'];	
		$data_response['status']=$this->rows[0]['status'];	
		$class_level_data=$this->rows[0]['class_level'];
		$class_level=$this->get_class_level_new($class_level_data);
		$data_response['class_level_co']=$class_level.'/'.$room_search;

		$this->sql ="SELECT  count(*) as num_row_std
					FROM tbl_student 
					WHERE room='$room_search'
					AND std_ID in(
						SELECT stdID
						FROM tbl_course_teaching_std
						WHERE registed_courseID in(
							SELECT DataID
							FROM tbl_registed_course
							WHERE courseID=$coures_id_list_val
						)
					)
					";
		$this->select();
		$this->setRows();	
		$data_response['num_all_std']=$this->rows[0]['num_row_std'];	

		$this->sql ="SELECT  *
					FROM tbl_student 
					WHERE room='$room_search'
					AND std_ID in(
						SELECT stdID
						FROM tbl_course_teaching_std
						WHERE registed_courseID in(
							SELECT DataID
							FROM tbl_registed_course
							WHERE courseID=$coures_id_list_val
						)
					)
					";
		$this->select();
		$this->setRows();	
		$data_i=0;
		$data_atte=0;
		$data_00=0;
		$data_10=0;
		$data_15=0;
		$data_20=0;
		$data_25=0;
		$data_30=0;
		$data_35=0;
		$data_40=0;

		$data_desirable_nopass=0;
		$data_desirable_pass=0;
		$data_desirable_good=0;
		$data_desirable_verygood=0;

		$data_read_think_write_nopass=0;
		$data_read_think_write_pass=0;
		$data_read_think_write_good=0;
		$data_read_think_write_verygood=0;

		$number=1;
		foreach($this->rows as $key => $value) {
			$std_ID=$value['std_ID'];

			//$attend_class_std_list=$this->get_attend_class_std_list($std_ID,$coures_id_list_val);

			$score_exam=$this->get_score_exam($std_ID,$coures_id_list_val);		
			$score_pick=$this->get_score_pick($std_ID,$coures_id_list_val);	
			$score_attend_class=$this->get_score_attend_class($std_ID,$coures_id_list_val);	
			//$data_response['score_attend_class']=$score_attend_class;
			if ($score_exam=='i' || $score_pick=='i' || $score_attend_class=='nopass') {
				if ($score_exam=='i' || $score_pick=='i') {
					$data_i++;
				}
				if ($score_attend_class=='nopass') {
					$data_atte++;
				}
				
			}else{
				$grade=$this->get_grade($score_exam,$score_pick);	
				$data_response['exam'].=$grade.'-';
				if ($grade=='0.0') {
					$data_00++;
				}elseif($grade=='1.0'){
					$data_10++;
				}elseif($grade=='1.5'){
					$data_15++;
				}elseif($grade=='2.0'){
					$data_20++;
				}elseif($grade=='2.5'){
					$data_25++;
				}elseif($grade=='3.0'){
					$data_30++;
				}elseif($grade=='3.5'){
					$data_35++;
				}elseif($grade=='4.0'){
					$data_40++;
				}		
			}	
			$desirable=$this->get_desirable($std_ID,$coures_id_list_val);	
			if ($desirable=='nopass') {
				$data_desirable_nopass++;
			}elseif($desirable=='pass'){
				$data_desirable_pass++;
			}elseif($desirable=='good'){
				$data_desirable_good++;
			}elseif($desirable=='verygood'){
				$data_desirable_verygood++;
			}
			$read_think_write=$this->get_read_think_write($std_ID,$coures_id_list_val);
			if ($read_think_write=='nopass') {
				$data_read_think_write_nopass++;
			}elseif($read_think_write=='pass'){
				$data_read_think_write_pass++;
			}elseif($read_think_write=='good'){
				$data_read_think_write_good++;
			}elseif($read_think_write=='verygood'){
				$data_read_think_write_verygood++;
			}
			$number++;
		}
		$data_response['attend_class_std_list']=$attend_class_std_list;
		$data_response['number']=$number;
		$data_response['data_i']=$data_i;
		$data_response['data_atte']=$data_atte;
		
		$data_response['data_00']=$data_00;
		$data_response['data_10']=$data_10;
		$data_response['data_15']=$data_15;
		$data_response['data_20']=$data_20;
		$data_response['data_25']=$data_25;
		$data_response['data_30']=$data_30;
		$data_response['data_35']=$data_35;
		$data_response['data_40']=$data_40;

		$data_response['data_desirable_nopass']=$data_desirable_nopass;
		$data_response['data_desirable_pass']=$data_desirable_pass;
		$data_response['data_desirable_good']=$data_desirable_good;
		$data_response['data_desirable_verygood']=$data_desirable_verygood;

		$data_response['data_read_think_write_nopass']=$data_read_think_write_nopass;
		$data_response['data_read_think_write_pass']=$data_read_think_write_pass;
		$data_response['data_read_think_write_good']=$data_read_think_write_good;
		$data_response['data_read_think_write_verygood']=$data_read_think_write_verygood;

		echo json_encode($data_response);
	}
	public function get_read_think_write($std_ID,$coures_id_list_val){
		$registed_courseID=$this->get_registed_courseID($coures_id_list_val);
		$score_total=0;

		$score_read=0;
		$score_think=0;
		$score_write=0;
		$this->sql ="SELECT  *
					FROM tbl_read_score
					WHERE stdID='$std_ID'
					AND course_teachingID in(
						SELECT DataID
						FROM tbl_registed_course_teaching 	
						WHERE registed_courseID=$registed_courseID
					)
					";
		$this->select();
		$this->setRows();
		$score_read=$this->rows[0]['score'];

		$this->sql ="SELECT  *
					FROM tbl_think_score
					WHERE stdID='$std_ID'
					AND course_teachingID in(
						SELECT DataID
						FROM tbl_registed_course_teaching 	
						WHERE registed_courseID=$registed_courseID
					)
					";
		$this->select();
		$this->setRows();
		$score_think=$this->rows[0]['score'];

		$this->sql ="SELECT  *
					FROM tbl_write_score
					WHERE stdID='$std_ID'
					AND course_teachingID in(
						SELECT DataID
						FROM tbl_registed_course_teaching 	
						WHERE registed_courseID=$registed_courseID
					)
					";
		$this->select();
		$this->setRows();
		$score_write=$this->rows[0]['score'];

		$score_total=($score_read+$score_think+$score_write)/3;
			if ($score_total<1) {
				$data='nopass';
			}elseif($score_total<1.5){
				$data='pass';
			}elseif($score_total<2.5){
				$data='good';
			}elseif($score_total>=2.5){
				$data='verygood';
			}
		return $data;
	}
	public function get_desirable($std_ID,$coures_id_list_val){
		$registed_courseID=$this->get_registed_courseID($coures_id_list_val);
		$score_total=0;
		for ($i=1; $i <= 8 ; $i++) { 
				$this->sql ="SELECT  *
					FROM tbl_desirable_$i 
					WHERE stdID='$std_ID'
					AND course_teachingID in(
						SELECT DataID
						FROM tbl_registed_course_teaching 	
						WHERE registed_courseID=$registed_courseID
					)
					";
			$this->select();
			$this->setRows();
			$score=$this->rows[0]['score'];
			$score_total=$score_total+$score;
			}	
			$evaluation_score=$score_total/8;
			if ($evaluation_score<1) {
				$data='nopass';
			}elseif($evaluation_score<1.5){
				$data='pass';
			}elseif($evaluation_score<2.5){
				$data='good';
			}elseif($evaluation_score>=2.5){
				$data='verygood';
			}
		return $data;
	}
	public function get_registed_courseID($coures_id_list_val){
		$this->sql ="SELECT  *
					FROM tbl_set_term_year 			
							";
		$this->select();
		$this->setRows();
		$term_set=$this->rows[0]['term'];
		$year_set=$this->rows[0]['year'];

		$data_response = array();
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 	
					WHERE DataID=$coures_id_list_val					
					";
		$this->select();
		$this->setRows();
		$class_level=$this->rows[0]['class_level'];
		if ($class_level=='p1' || $class_level=='p2' || $class_level=='p3' || $class_level=='p4' || $class_level=='p5' || $class_level=='p6') {
			$term_set='1,2';
		}
			
		$this->sql ="SELECT  *
					FROM tbl_registed_course 	
					WHERE courseID=$coures_id_list_val
					AND term='$term_set'
					AND year='$year_set'

					";
		$this->select();
		$this->setRows();		
		return $this->rows[0]['DataID'];	
	}
	public function get_grade($score_exam,$score_pick){
		$total=$score_exam+$score_pick;
		if ($total<50) {
			$grade='0.0';
		}elseif($total<55){
			$grade='1.0';
		}elseif($total<60){
			$grade='1.5';
		}elseif($total<65){
			$grade='2.0';
		}elseif($total<70){
			$grade='2.5';
		}elseif($total<75){
			$grade='3.0';
		}elseif($total<80){
			$grade='3.5';
		}elseif($total>=80){
			$grade='4.0';
		}
		return $grade;
	}
	public function get_score_attend_class($std_ID,$coures_id_list_val){
		$registed_courseID=$this->get_registed_courseID($coures_id_list_val);
		
		$this->sql ="SELECT *
					FROM tbl_set_count_adttend_class 
					WHERE registed_courseID=$registed_courseID		
					";
		$this->select();
		$this->setRows();	
		$week_name=$this->rows[0]['week_name'];

		$this->sql ="SELECT  SUM(score_status) as sum_score
					FROM tbl_attend_class 
					WHERE week BETWEEN 1 AND $week_name
					AND course_teaching_stdID in(
						SELECT DataID
						FROM tbl_course_teaching_std
						WHERE registed_courseID=$registed_courseID
						AND stdID='$std_ID'
					)					
					";
		$this->select();
		$this->setRows();	
		$sum_score=$this->rows[0]['sum_score'];
		$data_must_pass=floor((80*$week_name)/100);
		if ($sum_score>=$data_must_pass) {
			$find_80_per='pass';
		}else{
			$find_80_per='nopass';
		}
		return $find_80_per;
	}
	public function get_score_pick($std_ID,$coures_id_list_val){
		$registed_courseID=$this->get_registed_courseID($coures_id_list_val);
		$num_of_i=0;
		$this->sql ="SELECT  COUNT(score) as num_of_i
					FROM tbl_objective_score_std 	
					WHERE staID='$std_ID'
					AND registed_courseID=$registed_courseID
					AND score=-1
					";
		$this->select();
		$this->setRows();
		$num_of_i=$this->rows[0]['num_of_i'];			
		$this->sql ="SELECT  SUM(score) as score_total
					FROM tbl_objective_score_std 	
					WHERE staID='$std_ID'
					AND registed_courseID=$registed_courseID
					";
		$this->select();
		$this->setRows();	
		$score_total_data=$this->rows[0]['score_total'];
		if ($num_of_i>0) {
			$total='i';
		}else{
			$total=$score_total_data;
		}
			return $total;
	}
	public function get_score_exam($std_ID,$coures_id_list_val){	
	$this->sql ="SELECT  *
					FROM tbl_set_term_year 			
							";
		$this->select();
		$this->setRows();
		$term_set=$this->rows[0]['term'];
		$year_set=$this->rows[0]['year'];
		$data_response = array();	
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 	
					WHERE DataID=$coures_id_list_val
					
					";
		$this->select();
		$this->setRows();		
		$class_level_data=$this->rows[0]['class_level'];	
		$data_response['class_level']=$this->get_class_level_new($class_level_data);
		if ($class_level_data=='p1' || $class_level_data=='p2' || $class_level_data=='p3' || $class_level_data=='p4' || $class_level_data=='p5' || $class_level_data=='p6' ) {
			$term_set='1,2';
		}	
		$mid_status=0;
		$final_status=0;
		$this->sql ="SELECT  COUNT(score) as num_of_i_mid
					FROM tbl_mid_exam_score
					WHERE stdID='$std_ID'
					AND score=-1
					AND course_teachingID in(
						SELECT DataID
						FROM tbl_registed_course_teaching
						WHERE registed_courseID in(
							SELECT DataID
							FROM tbl_registed_course
							WHERE courseID=$coures_id_list_val
							AND term='$term_set'
							AND year='$year_set'
						)
					)
					";
		$this->select();
		$this->setRows();	
		$num_of_i_mid=$this->rows[0]['num_of_i_mid'];
		if ($num_of_i_mid>0) {
			$mid_status=-1;
		}
		$this->sql ="SELECT  *
					FROM tbl_mid_exam_score
					WHERE stdID='$std_ID'
					AND course_teachingID in(
						SELECT DataID
						FROM tbl_registed_course_teaching
						WHERE registed_courseID in(
							SELECT DataID
							FROM tbl_registed_course
							WHERE courseID=$coures_id_list_val
							AND term='$term_set'
							AND year='$year_set'
						)
					)
					";
		$this->select();
		$this->setRows();	
		$mid_exam_score=$this->rows[0]['score'];
		$this->sql ="SELECT  COUNT(score) as num_of_i_final
					FROM tbl_final_exam_score
					WHERE stdID='$std_ID'
					AND score=-1
					AND course_teachingID in(
						SELECT DataID
						FROM tbl_registed_course_teaching
						WHERE registed_courseID in(
							SELECT DataID
							FROM tbl_registed_course
							WHERE courseID=$coures_id_list_val
							AND term='$term_set'
							AND year='$year_set'
						)
					)
					";
		$this->select();
		$this->setRows();	
		$num_of_i_final=$this->rows[0]['num_of_i_final'];

		if ($num_of_i_final>0) {
			$final_status=-1;
		}
		$this->sql ="SELECT  *
					FROM tbl_final_exam_score 
					WHERE stdID='$std_ID'
					AND course_teachingID in(
						SELECT DataID
						FROM tbl_registed_course_teaching
						WHERE registed_courseID in(
							SELECT DataID
							FROM tbl_registed_course
							WHERE courseID=$coures_id_list_val
							AND term='$term_set'
							AND year='$year_set'
						)
					)
					";
		$this->select();
		$this->setRows();	
		$final_exam_score=$this->rows[0]['score'];
		if ($mid_status==-1 || $final_status==-1) {
			$total='i';
		}else{
			$total=$mid_exam_score+$final_exam_score;
		}
		return $total;
	}
	public function get_class_level($coures_id_list_val){
		$this->sql ="SELECT  *
					FROM tbl_set_term_year 			
							";
		$this->select();
		$this->setRows();
		$term_set=$this->rows[0]['term'];
		$year_set=$this->rows[0]['year'];
		$data_response = array();	
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 	
					WHERE DataID=$coures_id_list_val
					AND DataID in(
                    	SELECT courseID
                        FROM tbl_registed_course 
                        WHERE term='$term_set'  
                        OR term='1,2'
                        AND year='$year_set'
                         AND DataID IN(
                            SELECT registed_courseID
                        	FROM tbl_registed_course_teaching
                        )
                    )
					";
		$this->select();
		$this->setRows();		
		$class_level_data=$this->rows[0]['class_level'];
		$data_response['class_level']=$this->get_class_level_new($class_level_data);
		if ($class_level_data=='p1' || $class_level_data=='p2' || $class_level_data=='p3' || $class_level_data=='p4' || $class_level_data=='p5' || $class_level_data=='p6' ) {
			$term_set='1,2';
		}

		$this->sql ="SELECT distinct room
						FROM tbl_student 
						WHERE std_ID in(
							SELECT stdID
							FROM tbl_course_teaching_std
							WHERE registed_courseID in(
								SELECT DataID
								FROM tbl_registed_course
								WHERE courseID=$coures_id_list_val
                                AND term='$term_set'
                                AND year='$year_set'
								)
						)
						ORDER BY room ASC
							";
			$this->select();
			$this->setRows();
			foreach($this->rows as $key => $value) {
				$room=$value['room'];
				$data_response['room'].=' <option value='.$room.'>'.$room.'</option>';
			}
		return json_encode($data_response);
	}
public function get_coures_id_list($data_id,$data_room){

		$data_response = array();	
		$this->sql ="SELECT  *
					FROM tbl_set_term_year 			
							";
		$this->select();
		$this->setRows();
		$term_set=$this->rows[0]['term'];
		$year_set=$this->rows[0]['year'];
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 		
                    WHERE DataID in(
                    	SELECT courseID
                        FROM tbl_registed_course
                        WHERE term='$term_set'
                        AND year='$year_set'
                        AND DataID IN(
                        	SELECT registed_courseID
                            FROM tbl_registed_course_teaching
                        )                      
                    )
					ORDER BY courseID ASC								
							";
		$this->select();
		$this->setRows();
		foreach($this->rows as $key => $value) {
			$DataID=$value['DataID'];			
			$courseID_long=$value['courseID'];
			$data_response['coures_id_list'].='
							<option value="'.$DataID.'">'.$courseID_long.'</option>
			';
		}
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 		
                    WHERE DataID in(
                    	SELECT courseID
                        FROM tbl_registed_course
                        WHERE term='1,2'
                        AND DataID IN(
                        	SELECT registed_courseID
                            FROM tbl_registed_course_teaching
                        )
                    )
					ORDER BY courseID ASC	
							";
		$this->select();
		$this->setRows();
		foreach($this->rows as $key => $value) {
			$DataID=$value['DataID'];
			$courseID_long=$value['courseID'];
			$data_response['coures_id_list'].='
							<option value="'.$DataID.'">'.$courseID_long.'</option>
			';
		}
		return json_encode($data_response);
	}
	public function get_class_level_new($class_level_data){
		if ($class_level_data=="p1") {
			$class_level="ป.1";
		}elseif($class_level_data=="p2"){
			$class_level="ป.2";	
		}elseif($class_level_data=="p3"){
			$class_level="ป.3";	
		}elseif($class_level_data=="p4"){
			$class_level="ป.4";	
		}elseif($class_level_data=="p5"){
			$class_level="ป.5";	
		}elseif($class_level_data=="p6"){
			$class_level="ป.6";	
		}elseif($class_level_data=="m1"){
			$class_level="ม.1";	
		}elseif($class_level_data=="m2"){
			$class_level="ม.2";	
		}elseif($class_level_data=="m3"){
			$class_level="ม.3";	
		}elseif($class_level_data=="m4"){
			$class_level="ม.4";	
		}elseif($class_level_data=="m5"){
			$class_level="ม.5";	
		}elseif($class_level_data=="m6"){
			$class_level="ม.6";	
		}
		return $class_level;
	}
}<file_sep>/modules/regis_teacher/edit.js
var opPage = 'regis_teacher';
$(document).ready(function() {
	get_day_edit(1);
	years_set();
	get_data_edit();
	
}); 
function years_set() {
	var formData = new Array();
	formData.push({ "name": "acc_action", "value": "get_years" }); 
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {
		$("#years_set").html(data.set_years);
	});
}
function get_day_edit(mouth) {
	//var formData = $( "#frm_data" ).serializeArray();
	var formData = new Array();
	formData.push({ "name": "acc_action", "value": "get_day_edit" }); 
	formData.push({ "name": "mouth", "value": mouth }); 
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {
		console.log(data.day_set)
		$("#day_set").html(data.day_set);
	});

}
function edit_teacher() {
	var id=_get.id;
	var formData = $( "#frm_data" ).serializeArray();
	formData.push({ "name": "acc_action", "value": "edit_teacher" }); 
	formData.push({ "name": "data_id", "value": id }); 
	$.post('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {
		$(".modal").modal("hide");
		$("#modalEdited").modal("show");
	});
}
function get_data_edit() {
	var id=_get.id;
	var formData = new Array();
	formData.push({ "name": "acc_action", "value": "get_data_edit" }); 
	formData.push({ "name": "data_id", "value": id }); 
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {
		$("#positionID").val(data.positionID);
		$("#position_name").val(data.position_name);
		$("#fname_th").val(data.fname_th);
		$("#lname_th").val(data.lname_th);
		$("#fname_en").val(data.fname_en);
		$("#lname_en").val(data.lname_en);
		$("#blood_group").val(data.blood_group);

		$("#years_set").val(data.year);
		$("#mouth").val(data.month);
		$("#day_set").val(data.day);

		$("#gender").val(data.gender);
		$("#tell").val(data.tell);
		$("#email").val(data.email);
		$("#address").val(data.address);
		$("#status_alive").val(data.status_alive);

		//$("#modalRegistered").modal("show");
	});
}<file_sep>/modules/menu/upload_keyword.js
var data_id = (typeof _get.id === 'undefined') ? 0 : _get.id;

$(document).delegate('#bt_add_keyword', 'click', function(event) {
	var KeyName = $('#KeyName').val();

	$.post('modules/contact/process.php', {
		'acc_action' : 'add_keyword',
		'contactID' : data_id,
		'key_name': KeyName
	}, function(data) { 
		$('#KeyName').val("");
		get_keyword();
	});

});

function get_keyword(){
	$.post('modules/contact/process.php', {acc_action: 'get_keyword','data_id':data_id}, function(data) {
		$('#tb_keyword').html(data);
	});
}

$(document).delegate('.btn_remove_key', 'click', function(event) {
	key_id = $(this).attr('data-id');
	$('#modal_key_cancel').modal('show');
});

$(document).delegate('#btn__key_remove', 'click', function(event) {
	$.post('modules/contact/process.php', {
		'acc_action' : 'remove_keyword',
		'data_id' : key_id
	}, function(response) { 
		$('#modal_key_cancel').modal('hide');
		get_keyword();
	});
	return false;
});<file_sep>/modules/conclusion/form/learning_result_footer.php
<?php
	$footer_text='
	<div style="line-height:0.5;margin-top:10px;">
  		<p style="font-size:14px;">
  			<span>หมายเหตุ : วิชากิจกรรมพัฒนาผู้เรียน ผ หมายถึง ผ่าน, มผ หมายถึง ไม่ผ่าน | </span>
  			<span>การประเมินผลคุณลักษณะอันพึงประสงค์ 3 หมายถึง ดีเยี่ยม, 2 หมายถึง ดี, 1 หมายถึง ผ่าน | </span>
  			<span>การประเมินผลการอ่าน เขียน คิด วิเคราะห์3 หมายถึง ดีเยี่ยม, 2 หมายถึง ดี, 1 หมายถึง ผ่าน</span>
  		</p>
    
  	</div>
  	<div style="margin-left:10%;margin-top:20px;font-size:14px">
      	<div style="line-height:0.5;">
         	<p>
         		................................................................. ครูประจำชั้น
         		
         	</p>
         	<p>
         		<span>(</span><span style="margin-left:170px;">)</span>
         	</p>
         	<p>
         		...................../...................../.....................
         	</p>
      	</div>
      	<div style="line-height:0.5;margin-top:20px;">
         	<p>
         		................................................................. รองผู้อำนวยการฝ่ายวิชาการ
         		
         	</p>
         	<p>
         		<span>(</span><span style="margin-left:170px;">)</span>
         	</p>
         	<p>
         		...................../...................../.....................
         	</p>
      	</div>
      </div>
      <div style="margin-left:60%;margin-top:-122px;font-size:14px">
      	<div style="line-height:0.5;margin-top:20px;">
         	<p>
         		................................................................. หัวหน้างานวัดผล
         		
         	</p>
         	<p>
         		<span>(</span><span style="margin-left:170px;">)</span>
         	</p>
         	<p>
         		...................../...................../.....................
         	</p>
      	</div>
      	<div style="line-height:0.5;margin-top:20px;">
         	<p>
         		................................................................. ผู้อำนวยการสถานศึกษา
         		
         	</p>
         	<p>
         		<span>(</span><span style="margin-left:170px;">)</span>
         	</p>
         	<p>
         		...................../...................../.....................
         	</p>
      	</div>
      </div>
	';
	$footer_text_detail='
				<div style="line-height:0.5;margin-top:10px;">
	          		<p style="font-size:14px;">
			  			<span>หมายเหตุ : วิชากิจกรรมพัฒนาผู้เรียน ผ หมายถึง ผ่าน, มผ หมายถึง ไม่ผ่าน | </span>
			  			<span>การประเมินผลคุณลักษณะอันพึงประสงค์ 3 หมายถึง ดีเยี่ยม, 2 หมายถึง ดี, 1 หมายถึง ผ่าน |</span>
			  			<span>การประเมินผลการอ่าน เขียน คิด วิเคราะห์3 หมายถึง ดีเยี่ยม, 2 หมายถึง ดี, 1 หมายถึง ผ่าน</span>
			  		</p>
	          	</div>

	';
	$footer_text_cen='
				<div style="margin-left:10%;margin-top:20px;font-size:14px">
		          	<div style="line-height:0.5;">
			         	<p>
			         		................................................................. ครูประจำชั้น
			         		
			         	</p>
			         	<p>
			         		<span>(</span><span style="margin-left:170px;">)</span>
			         	</p>
			         	<p>
			         		...................../...................../.....................
			         	</p>
		          	</div>
		          	<div style="line-height:0.5;margin-top:20px;">
			         	<p>
			         		................................................................. รองผู้อำนวยการฝ่ายวิชาการ
			         		
			         	</p>
			         	<p>
			         		<span>(</span><span style="margin-left:170px;">)</span>
			         	</p>
			         	<p>
			         		...................../...................../.....................
			         	</p>
		          	</div>
		          </div>
		          <div style="margin-left:60%;margin-top:-122px;font-size:14px">
		          	<div style="line-height:0.5;margin-top:20px;">
			         	<p>
			         		................................................................. หัวหน้างานวัดผล
			         		
			         	</p>
			         	<p>
			         		<span>(</span><span style="margin-left:170px;">)</span>
			         	</p>
			         	<p>
			         		...................../...................../.....................
			         	</p>
		          	</div>
		          	<div style="line-height:0.5;margin-top:20px;">
			         	<p>
			         		................................................................. ผู้อำนวยการสถานศึกษา
			         		
			         	</p>
			         	<p>
			         		<span>(</span><span style="margin-left:170px;">)</span>
			         	</p>
			         	<p>
			         		...................../...................../.....................
			         	</p>
		          	</div>
		          </div>

	';
	$footer_text_cen_normal='
				<div style="margin-left:10%;margin-top:20px;font-size:14px">
		          	<div style="line-height:0.5;">
			         	<p>
			         		................................................................. ครูประจำชั้น
			         		
			         	</p>
			         	<p>
			         		<span>(</span><span style="margin-left:170px;">)</span>
			         	</p>
			         	<p>
			         		...................../...................../.....................
			         	</p>
		          	</div>
		          	<div style="line-height:0.5;margin-top:40px;">
			         	<p>
			         		................................................................. รองผู้อำนวยการฝ่ายวิชาการ
			         		
			         	</p>
			         	<p>
			         		<span>(</span><span style="margin-left:170px;">)</span>
			         	</p>
			         	<p>
			         		...................../...................../.....................
			         	</p>
		          	</div>
		          </div>
		          <div style="margin-left:60%;margin-top:-142px;font-size:14px">
		          	<div style="line-height:0.5;margin-top:20px;">
			         	<p>
			         		................................................................. หัวหน้างานวัดผล
			         		
			         	</p>
			         	<p>
			         		<span>(</span><span style="margin-left:170px;">)</span>
			         	</p>
			         	<p>
			         		...................../...................../.....................
			         	</p>
		          	</div>
		          	<div style="line-height:0.5;margin-top:40px;">
			         	<p>
			         		................................................................. ผู้อำนวยการสถานศึกษา
			         		
			         	</p>
			         	<p>
			         		<span>(</span><span style="margin-left:170px;">)</span>
			         	</p>
			         	<p>
			         		...................../...................../.....................
			         	</p>
		          	</div>
		          </div>

	';
?><file_sep>/modules/news/class_modules.php
<?php 

class ClassData extends Databases {
	public function update_news($update,$data_id){
		$this->sql = "UPDATE tbl_news SET ".implode(",",$update)." WHERE DataID='".$data_id."'";
		$this->query();
		$new_id = $this->insertID();
		return json_encode($new_id);
	}
	public function delete_img_file($data_id,$set_type){
		if ($set_type==1) {
			$this->sql ="SELECT file_name
					FROM tbl_news_gallery
					WHERE DataID=$data_id
						";
			$this->select();
			$this->setRows();
			$file_name=$this->rows[0]['file_name'];
			@unlink("../../file_managers/news/".$file_name);

			$sql = "DELETE 
				FROM tbl_news_gallery
				WHERE DataID=$data_id
				";
			$this->sql = $sql;
			$this->query();
		}else{
			$this->sql ="SELECT file_name
					FROM tbl_news_gallery_sub
					WHERE DataID=$data_id
						";
			$this->select();
			$this->setRows();
			$file_name=$this->rows[0]['file_name'];
			@unlink("../../file_managers/news_sub/".$file_name);

			$sql = "DELETE 
				FROM tbl_news_gallery_sub
				WHERE DataID=$data_id
				";
			$this->sql = $sql;
			$this->query();
		}
		return json_encode('1');
	}
	public function delete_news($data_id){
	$sql = "DELETE 
				FROM tbl_news
				WHERE DataID=$data_id
				";
			$this->sql = $sql;
			$this->query();
			return json_encode('1');
	}
	public function insert_news($insert){
		$this->sql = "INSERT INTO tbl_news(".implode(",",array_keys($insert)).") VALUES (".implode(",",array_values($insert)).")";
		$this->query();
		
		return  $this->insertID();
	}
	public function get_author($authorID){
		$this->sql ="SELECT  *
					FROM tbl_regis_teacher 
					WHERE DataID=$authorID

					";
		$this->select();
		$this->setRows();	
		$fname_th=$this->rows[0]['fname_th'];	
		$lname_th=$this->rows[0]['lname_th'];
		return $fname_th.' '.$lname_th;
	}
	public function get_news_detail($news_id){
		$this->sql ="SELECT  *
					FROM tbl_news 
					WHERE DataID=$news_id

					";
		$this->select();
		$this->setRows();	
		$DataID=$this->rows[0]['DataID'];
		
		$data_response['title']=$this->rows[0]['title'];	
		$data_response['detail']=(unchkhtmlspecialchars($this->rows[0]['detail']));
		$img_list=$this->get_img($DataID);
		$data_response['img_list']=$img_list;
		return json_encode($data_response);
	}
	public function get_img($news_id){
		$this->sql ="SELECT COUNT(*) AS num_row_img_main,file_name,DataID
					FROM tbl_news_gallery 
					WHERE newsID=$news_id
						";
		$this->select();
		$this->setRows();
		$num_row_img_main=$this->rows[0]['num_row_img_main'];
		$DataID=$this->rows[0]['DataID'];
		$file_name=$this->rows[0]['file_name'];
		if ($num_row_img_main>0) {
			$data_response='
					<div class="row">
			            <div class="col-sm-3" style="text-align:right">                                                                  
			           			<div class="delete_img_set" set-type="1" data-id="'.$DataID.'" aria-hidden="true" data-toggle="modal" data-target="#modalDeleteImg">
			                      <span class="glyphicon glyphicon-remove-circle edit-icon-table"></span>
			                    </div>         
			            </div>
			            <div class="col-sm-9 mb-10">                                                                                  
			                <img src="file_managers/news/'.$file_name.'" style="width: 80%" id="output1"/>             
			            </div> 
			          </div>
		';

		}else{
			$data_response.='
						<div class="row">
				            <div class="col-sm-3">                                                                                             
				              <input name="img1" type="file" accept="image/*" onchange="loadFile1()">                                  
				            </div>
				            <div class="col-sm-9 mb-10">                                                                                  
				                <img  style="width:80%" id="output1"/>             
				            </div> 
				          </div>
				';
		}
		$this->sql ="SELECT COUNT(*) AS num_row_img_sub
					FROM tbl_news_gallery_sub
					WHERE newsID=$news_id
						";
		$this->select();
		$this->setRows();
		$num_row_img_sub=$this->rows[0]['num_row_img_sub'];
		if ($num_row_img_sub>0) {
			$this->sql ="SELECT *
					FROM tbl_news_gallery_sub 
					WHERE newsID=$news_id
						";
			$this->select();
			$this->setRows();
			$amount_set_tag=2;
			foreach($this->rows as $key => $value) {
				$file_name=$value['file_name'];
				$DataID=$value['DataID'];
				$data_response.='
						<div class="row">
				            <div class="col-sm-3" style="text-align:right">                                                                  
			           			<div class="delete_img_set" set-type="2" data-id="'.$DataID.'" aria-hidden="true" data-toggle="modal" data-target="#modalDeleteImg">
			                      <span class="glyphicon glyphicon-remove-circle edit-icon-table"></span>
			                    </div>         
			            </div>
				            <div class="col-sm-9 mb-10">                                                                                  
				                <img src="file_managers/news_sub/'.$file_name.'" style="width:80%" id="output'.$amount_set_tag.'"/>             
				            </div> 
				          </div>
				';
				$amount_set_tag++;
			}
		}
		$amount_start_loop=$num_row_img_sub+2;
		for ($i=$amount_start_loop; $i <= 5; $i++) { 
			$data_response.='
						<div class="row">
				            <div class="col-sm-3">                                                                                             
				              <input name="img'.$i.'" type="file" accept="image/*" onchange="loadFile'.$i.'()">                                  
				            </div>
				            <div class="col-sm-9 mb-10">                                                                                  
				                <img  style="width:80%" id="output'.$i.'"/>             
				            </div> 
				          </div>
				';
		}
		return $data_response;
	}
	public function get_news_list(){
		$this->sql ="SELECT  *
					FROM tbl_news 
					ORDER BY date DESC,DataID DESC
						";
		$this->select();
		$this->setRows();
		foreach($this->rows as $key => $value) {
			$DataID=$value['DataID'];
			$title=$value['title'];
			$authorID=$value['author'];
			$author_name=$this->get_author($authorID);
			$date_form = strtotime($value['date']);
			$date_set=date('d-m-Y', $date_form); 
			$data_response.='
						 <tr>
			                  <td style="text-align: center;">'.$date_set.'</td>
			                  <td style="text-align: left;padding-left: 2%">'.$title.'</td>
			                  
			                  <td style="text-align: center;">'.$author_name.'</td>
			                  <td style="text-align: center;">
			                    <a href="index.php?op=news-edit&id='.$DataID.'">
			                    <div class="icon-circle-edit bt_delete" data-id="285-1" aria-hidden="true" data-toggle="modal" data-target="#modalConfirm">
			                      <span class="glyphicon glyphicon-edit edit-icon-table"></span>
			                    </div>
			                    </a>
			                  </td>
			                  <td style="text-align: center;">
			                    <div class="bt_delete" data-id="'.$DataID.'" aria-hidden="true" data-toggle="modal" data-target="#modalDelete">
			                      <span class="glyphicon glyphicon-trash edit-icon-table"></span>
			                    </div>
			                  </td>
			                </tr>
			';
		}
		return json_encode($data_response);
	}
	
}<file_sep>/modules/regis_teacher/class_modules.php
<?php 

class ClassData extends Databases {
	
	public function get_data_edit($data_id){
		$sql = "SELECT *
				FROM tbl_regis_teacher
				WHERE DataID=$data_id
				";
		$this->sql = $sql;
		$this->select();
		$this->setRows();
		$data_response['positionID']=$this->rows[0]['positionID'];
		$data_response['position_name']=$this->rows[0]['position_name'];
		$data_response['fname_th']=$this->rows[0]['fname_th'];
		$data_response['lname_th']=$this->rows[0]['lname_th'];
		$data_response['fname_en']=$this->rows[0]['fname_en'];
		$data_response['lname_en']=$this->rows[0]['lname_en'];
		$birthday_data=$this->rows[0]['birthday'];
		$data_response['blood_group']=$this->rows[0]['blood_group'];
		$data_response['gender']=$this->rows[0]['gender'];
		$data_response['tell']=$this->rows[0]['tell'];
		$data_response['email']=$this->rows[0]['email'];
		$data_response['address']=$this->rows[0]['address'];
		$data_response['status_alive']=$this->rows[0]['status_alive'];

		$birthday=$this->get_birthday($birthday_data);
		$data_response['day']=$birthday['day'];
		$data_response['month']=$birthday['month'];
		$data_response['year']=$birthday['year'];
		return json_encode($data_response);
	}
	public function get_birthday($birthday){
		$time  = strtotime($birthday);
		$birthday_result['day']   = date('d',$time);
		$birthday_result['month'] = date('m',$time);
		$birthday_result['year'] = date('Y',$time)+543;
		return $birthday_result;

	}
	public function get_teacher($status,$data_search){
		$sql_condition = " DataID is not null ";
		if ($status=='id') {
			if (isset($data_search) && $data_search != "") {
				$sql_condition .= " AND ( positionID LIKE '%{$data_search}%') ";
			}
		}elseif($status=='name'){
			if (isset($data_search) && $data_search != "") {
				$sql_condition .= " AND ( fname_th LIKE '%{$data_search}%') OR ( lname_th LIKE '%{$data_search}%')";
			}
		}

		$sql = "SELECT DataID,positionID,fname_th,lname_th ,status_alive
				FROM tbl_regis_teacher
				WHERE $sql_condition	
				ORDER BY fname_th
				";
		$this->sql = $sql;
		$this->select();
		$this->setRows();
		foreach($this->rows as $key => $value) {
			$DataID= $value['DataID'];	
			$positionID= $value['positionID'];	
			$fname_th= $value['fname_th'];	
			$lname_th= $value['lname_th'];	
			$status_alive= $value['status_alive'];
			$status_text=$this->get_status_text($status_alive);
			$data_response.='
						<tr>      
						  <td ></td>                      
                          <td style="text-align: center;">'.$positionID.'</td>
                          <td style="text-align: left;padding-left:10%;">'.$fname_th.'</td>
                          <td style="text-align: left;padding-left:10%;">'.$lname_th.'</td>
                          <td style="text-align: center;">'.$status_text.'</td>
                          <td style="text-align:center;">
                          	<a href="index.php?op=regis_teacher-edit&id='.$DataID.'">
	                           <span class="glyphicon glyphicon-edit edit-icon-table" ari="" a-hidden="true"></span>
	                        </a>
                          </td>
                          
                          <td style="text-align:center;">
                          	<div data-id="'.$DataID.'" class="bt_change_pass"  aria-hidden="true" data-toggle="modal" data-target="#modalChangePass">
	                           <span class="glyphicon glyphicon-refresh edit-icon-table" ari="" a-hidden="true"></span>
	                        </div>
                          </td>  
                      </tr>
			';
		}
		echo json_encode($data_response);
	}
	
	public function get_status_text($status_alive){
		switch($status_alive){
			case '1':
				$data_response='ปกติ';
				break;
			case '2':
				$data_response='ย้าย';
				break;
			case '3':
				$data_response='เสียชีวิต';
				break;
			case '4':
				$data_response='เกษียณ';
				break;
			case '5':
				$data_response='ยกเลิกการใช้งาน';
				break;
			default :
				$data_response='';
				break;
		}
		return $data_response;
	}
	public function change_pass($data_val){
		$sql = "SELECT birthday
				FROM tbl_regis_teacher
				WHERE DataID=$data_val
				";
		$this->sql = $sql;
		$this->select();
		$this->setRows();
		$birthday_set=$this->rows[0]['birthday'];
		list($year_set,$month,$day) = split('[-]', $birthday_set);
		$year_set=$year_set+543;
		$password_set=MD5($day.$month.$year_set);
		$this->sql = "UPDATE tbl_regis_teacher SET password='$<PASSWORD>' WHERE DataID=$data_val";
		$this->query();
		return json_encode($password_set);
	}
	public function get_data_delete($data_val){
		$arr_id = explode(",", $data_val);
		$num=0;
		for ($i=0; $i < count($arr_id) ; $i++) { 
            $this->sql ="DELETE FROM tbl_regis_teacher WHERE DataID = '{$arr_id[$i]}'";
	        $this->query();

           $num=$num+$i;
		}
		return $num;
	}
	public function update_data($update,$user_id){
		$this->sql = "UPDATE tbl_regis_teacher SET ".implode(",",$update)." WHERE DataID='".$user_id."'";
		$this->query();
	}
	public function insert_data($insert){
		$this->sql = "INSERT INTO tbl_regis_teacher(".implode(",",array_keys($insert)).") VALUES (".implode(",",array_values($insert)).")";
		$this->query();
		$new_id = $this->insertID();
		
	}
	public function get_years(){
		$data_response = array();
		$years_now=intval(date("Y"));+
		$years_now=$years_now+543;
		$data_response['set_years']='<option value="0">ปี</option>';
		for ($i=$years_now; $i >= 2480  ; $i--) { 
			$data_response['set_years'].='<option value="'.$i.'">'.$i.'</option>';
		}
		echo json_encode($data_response);
	}
	public function get_day_edit($mouth){
		$data_response = array();
		
		for ($i=1; $i <= 29 ; $i++) { 
			if ($i<=9) {
				$day_make_29.='<option value="0'.$i.'">'.$i.'</option>';
			}else{
				$day_make_29.='<option value="'.$i.'">'.$i.'</option>';
			}
			
		}
		for ($i=1; $i <= 30 ; $i++) { 
			if ($i<=9) {
				$day_make_30.='<option value="0'.$i.'">'.$i.'</option>';
			}else{
				$day_make_30.='<option value="'.$i.'">'.$i.'</option>';
			}
		}
		for ($i=1; $i <= 31 ; $i++) { 
			if ($i<=9) {
				$day_make_31.='<option value="0'.$i.'">'.$i.'</option>';
			}else{
				$day_make_31.='<option value="'.$i.'">'.$i.'</option>';
			}
		}
		if ($mouth==1 || $mouth==3 || $mouth==5 || $mouth==7 || $mouth==8 || $mouth==10 || $mouth==12) {
			$data_response['day_set']=$day_make_31;
		}elseif($mouth==4 || $mouth==6 || $mouth==9 || $mouth==11){
			$data_response['day_set']=$day_make_30;
		}else{
			$data_response['day_set']=$day_make_29;
		}
		echo json_encode($data_response);
	}
	public function get_day($mouth){
		$data_response = array();
		$day_make_29.='<option value="0">วัน</option>';
		$day_make_30.='<option value="0">วัน</option>';
		$day_make_31.='<option value="0">วัน</option>';
		for ($i=1; $i <= 29 ; $i++) { 
			$day_make_29.='<option value="'.$i.'">'.$i.'</option>';
		}
		for ($i=1; $i <= 30 ; $i++) { 
			$day_make_30.='<option value="'.$i.'">'.$i.'</option>';
		}
		for ($i=1; $i <= 31 ; $i++) { 
			$day_make_31.='<option value="'.$i.'">'.$i.'</option>';
		}
		if ($mouth==1 || $mouth==3 || $mouth==5 || $mouth==7 || $mouth==8 || $mouth==10 || $mouth==12) {
			$data_response['day_set']=$day_make_31;
		}elseif($mouth==4 || $mouth==6 || $mouth==9 || $mouth==11){
			$data_response['day_set']=$day_make_30;
		}else{
			$data_response['day_set']=$day_make_29;
		}

	echo json_encode($data_response);
	}

}<file_sep>/login.php
<?php
@ob_start();
@session_start();
require_once('init.php');
?>
<!DOCTYPE html>
<html>
  <head>
   <meta charset="utf-8">
      <meta http-equiv="X-UA-Compatible" content="IE=edge">
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
      <title>ระบบวัดและประเมินผล</title>

      <!-- Bootstrap -->
      <link href="assets/css/bootstrap.min.css" rel="stylesheet">
      <link href="assets/css/custom.css" rel="stylesheet">
      <link href="assets/css/margin-padding.css" rel="stylesheet">
      <link rel="icon" type="image/gif/png" href="assets/images/logo.png">
      <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
      <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
      <!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
        <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
      <![endif]-->
      <link rel="stylesheet" type="text/css" media="screen and (max-width:768px)" href="assets/css/extrasmall.css">
      <link rel="stylesheet" type="text/css" media="screen and (min-width:768px)" href="assets/css/small.css">
      <link rel="stylesheet" type="text/css" media="screen and (min-width:992px)" href="assets/css/medium.css">
      <link rel="stylesheet" type="text/css" media="screen and (min-width:1200px)" href="assets/css/large.css">
    <!--[if lte IE 9]>
        <link href="assets/pages/css/ie9.css" rel="stylesheet" type="text/css" />
    <![endif]-->
    <style>
      .my-modal {

        display: none; /* Hidden by default */
        position: fixed; /* Stay in place */
        z-index: 999; /* Sit on top */
        padding-top: 130px; /* Location of the box */
        left: 0;
        top: 0;
        width: 100%; /* Full width */
        height: 100%; /* Full height */
        overflow: auto; /* Enable scroll if needed */
        background-color: rgb(0,0,0); /* Fallback color */
        background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
    }

    /* Modal Content */
    .my-modal-content {
        border-radius: 10px;
        background-color: #fefefe;
        margin: auto;
        padding: 20px;
        border: 1px solid #888;
        width: 40%;
    }

    /* The Close Button */
    .my-close {
        color: #aaaaaa;
        float: right;
        font-size: 28px;
        margin-top: -20px;
        font-weight: bold;
    }

    .my-close:hover,
    .my-close:focus {
        color: #000;
        text-decoration: none;
        cursor: pointer;
    }
    </style>
    <script type="text/javascript">
    window.onload = function()
    {
      // fix for windows 8
      if (navigator.appVersion.indexOf("Windows NT 6.2") != -1)
        document.head.innerHTML += '<link rel="stylesheet" type="text/css" href="assets/pages/css/windows.chrome.fix.css" />'
    }
    </script>
    
  </head>
  <body class="fixed-header   ">

    <section class="section-index">
        <div class="container">
          <div class="row">
              <div class="col-sm-4 col-sm-offset-4">
                <img class="logo-index" src="assets/images/logo.png">
              </div>
          </div>
          <div class="row">
            <div class="text-header-index">
              <div class="text-first-index">
                <h1>ระบบวัดและประเมินผล</h1>
              </div>
              <div class="text-second-index">
                <h3>โรงเรียนเทศบาลวัดสระทอง</h3>
              </div>
            </div>
          </div>
          <div class="mt-20">
            <form id="form__data" class="form-horizontal">              
              <div class="form-group">
                <div class="col-sm-4 col-sm-offset-4" >
                  <center>
                    <div class="input-group edit-size-form-icon" >
                      <div class="input-group-addon edit-line-form"><span class="glyphicon glyphicon-user" aria-hidden="true"></span></div>
                      <input name="username" id="username" type="text" class="form-control edit-line-form edit-size-form-input" id="exampleInputAmount" placeholder="Username" >
                    </div>
                  </center>    
                </div>
                <div class="col-sm-4 col-sm-offset-4 mt-20">
                  <center>
                    <div class="input-group edit-size-form-icon" >
                      <div class="input-group-addon edit-line-form"><span class="glyphicon glyphicon-lock" aria-hidden="true"></span></div>
                      <input name="<PASSWORD>" id="<PASSWORD>" type="<PASSWORD>" class="form-control edit-line-form edit-size-form-input" id="exampleInputAmount" placeholder="<PASSWORD>" >
                    </div>
                  </center>
                </div>
              </div>
              
              <div class="col-sm-3 col-sm-offset-4" style="text-align: center;">
                <a  class="text-forget" id="myBtn" style="color: #777;" href="#">Forgot your password ?</a>
              </div>
              <div class="col-sm-3 col-sm-offset-4 mt-15">
              
                 <div id="submit__data" class="edit-btn-login">
                    เข้าสู่ระบบ
                  </div>
            
               
              </div>
              
            </form>          
          </div>
        </div> 
         <div class="row">
              <div class="col-md-4 col-sm-offset-4 mt-20" style="text-align: center;">
                <div id="alert__panel" class="alert alert-danger" style="display:none;">
                  <strong>Username or password incorrect</strong>
                </div>   
              </div>           
            </div>
        <div class="tab-footer">
          
        </div>
<div id="myModal" class="my-modal">

  <!-- Modal content -->
  <div class="my-modal-content" style="text-align: center;">
    <span class="my-close" >&times;</span>
      <p style="font-size: 18px;">กรุณาติดต่อ</p>
      <p style="font-size: 24px;font-weight: bold;">ผู้รับผิดชอบงานวัดผล</p>
      <p style="font-size: 18px;">โรงเรียนเทศบาลวัดสระทอง</p>

</div>
      </section>

    <!-- END PAGE CONTAINER -->
    <!-- BEGIN VENDOR JS -->
   <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
      <script type="text/javascript" src="assets/js/jquery.js"></script>
      <!-- Include all compiled plugins (below), or include individual files as needed -->
      <script src="assets/js/bootstrap.min.js"></script>
    <script src="modules/login/login.js?<?=time();?>" type="text/javascript"></script>
    <!-- END PAGE LEVEL JS -->
    <script>
    // Get the modal
    var modal = document.getElementById('myModal');

    // Get the button that opens the modal
    var btn = document.getElementById("myBtn");

    // Get the <span> element that closes the modal
    var span = document.getElementsByClassName("my-close")[0];

    // When the user clicks the button, open the modal 
    btn.onclick = function() {
        modal.style.display = "block";
    }

    // When the user clicks on <span> (x), close the modal
    span.onclick = function() {
        modal.style.display = "none";
    }

    // When the user clicks anywhere outside of the modal, close it
    window.onclick = function(event) {
        if (event.target == modal) {
            modal.style.display = "none";
        }
    }
    </script>
  </body>
</html><file_sep>/modules/save_score/process.php
<?php
@ob_start();
@session_start();

require_once('../../init.php');
include('../../src/class.pagination.php');
include('../../src/class.inputfilter.php');
$InputFilter = new InputFilter();

##CLASS_DB_CONNECT##
include('class_modules.php');
$class_data = new ClassData();
##CLASS_DB_CONNECT##

if(isset($_POST['acc_action']) and $_POST['acc_action'] == "save_read_score_std"){	
	$value_score_read=$_POST['value_score_read'];
	$value_score_write=$_POST['value_score_write'];
	$value_score_think=$_POST['value_score_think'];
	$value_score_rtw_4=$_POST['value_score_rtw_4'];
	$value_score_rtw_5=$_POST['value_score_rtw_5'];

	$std_id_all_read=$_POST['std_id_all_read'];

	$arr_id_value_score_read = explode("-", $value_score_read);
	$arr_id_value_score_write = explode("-", $value_score_write);
	$arr_id_value_score_think = explode("-", $value_score_think);
	$arr_id_value_score_rtw_4 = explode("-", $value_score_rtw_4);
	$arr_id_value_score_rtw_5 = explode("-", $value_score_rtw_5);

	$teaching_id_find=$_POST['teaching_id_find'];
	$arr_std_id_all_read = explode("-", $std_id_all_read);
	$num_1=0;
	for ($i=0; $i <count($arr_std_id_all_read) ; $i++) { 
	
		$class_data->sql ="SELECT  count(*) as num_row_chk
						FROM tbl_read_score 
						WHERE stdID='{$arr_std_id_all_read[$i]}'
						AND course_teachingID=$teaching_id_find
								";
		$class_data->select();
		$class_data->setRows();	
		$num_row_chk=$class_data->rows[0]['num_row_chk'];
		if ($num_row_chk==0) {
			$class_data->sql ="INSERT INTO tbl_read_score(course_teachingID,stdID,score)
								VALUES($teaching_id_find,'{$arr_std_id_all_read[$i]}',$arr_id_value_score_read[$num_1]) 
							   ";
	   	 	echo $class_data->query();	
		}else{
			$class_data->sql ="UPDATE tbl_read_score SET score=$arr_id_value_score_read[$num_1] WHERE stdID='$arr_std_id_all_read[$i]' AND course_teachingID=$teaching_id_find";
	   	 	echo $class_data->query();	
		}
		
		
		$class_data->sql ="SELECT  count(*) as num_row_chk
						FROM tbl_write_score 
						WHERE stdID='{$arr_std_id_all_read[$i]}'
						AND course_teachingID=$teaching_id_find
								";
		$class_data->select();
		$class_data->setRows();	
		$num_row_chk=$class_data->rows[0]['num_row_chk'];
		if ($num_row_chk==0) {
			$class_data->sql ="INSERT INTO tbl_write_score(course_teachingID,stdID,score)
								VALUES($teaching_id_find,'{$arr_std_id_all_read[$i]}',$arr_id_value_score_write[$num_1]) 
							   ";
	   	 	echo $class_data->query();	
		}else{
			$class_data->sql ="UPDATE tbl_write_score SET score=$arr_id_value_score_write[$num_1] WHERE stdID='$arr_std_id_all_read[$i]' AND course_teachingID=$teaching_id_find";
	   	 	echo $class_data->query();	
		}

		$class_data->sql ="SELECT  count(*) as num_row_chk
						FROM tbl_think_score 
						WHERE stdID='{$arr_std_id_all_read[$i]}'
						AND course_teachingID=$teaching_id_find
								";
		$class_data->select();
		$class_data->setRows();	
		$num_row_chk=$class_data->rows[0]['num_row_chk'];
		if ($num_row_chk==0) {
			$class_data->sql ="INSERT INTO tbl_think_score(course_teachingID,stdID,score)
								VALUES($teaching_id_find,'{$arr_std_id_all_read[$i]}',$arr_id_value_score_think[$num_1]) 
							   ";
	   	 	echo $class_data->query();	
		}else{
			$class_data->sql ="UPDATE tbl_think_score SET score=$arr_id_value_score_think[$num_1] WHERE stdID='$arr_std_id_all_read[$i]' AND course_teachingID=$teaching_id_find";
	   	 	echo $class_data->query();	
		}

		$class_data->sql ="SELECT  count(*) as num_row_chk
						FROM tbl_rtw_4_score 
						WHERE stdID='{$arr_std_id_all_read[$i]}'
						AND course_teachingID=$teaching_id_find
								";
		$class_data->select();
		$class_data->setRows();	
		$num_row_chk=$class_data->rows[0]['num_row_chk'];
		if ($num_row_chk==0) {
			$class_data->sql ="INSERT INTO tbl_rtw_4_score(course_teachingID,stdID,score)
								VALUES($teaching_id_find,'{$arr_std_id_all_read[$i]}',$arr_id_value_score_rtw_4[$num_1]) 
							   ";
	   	 	echo $class_data->query();	
		}else{
			$class_data->sql ="UPDATE tbl_rtw_4_score SET score=$arr_id_value_score_rtw_4[$num_1] WHERE stdID='$arr_std_id_all_read[$i]' AND course_teachingID=$teaching_id_find";
	   	 	echo $class_data->query();	
		}

		$class_data->sql ="SELECT  count(*) as num_row_chk
						FROM tbl_rtw_5_score 
						WHERE stdID='{$arr_std_id_all_read[$i]}'
						AND course_teachingID=$teaching_id_find
								";
		$class_data->select();
		$class_data->setRows();	
		$num_row_chk=$class_data->rows[0]['num_row_chk'];
		if ($num_row_chk==0) {
			$class_data->sql ="INSERT INTO tbl_rtw_5_score(course_teachingID,stdID,score)
								VALUES($teaching_id_find,'{$arr_std_id_all_read[$i]}',$arr_id_value_score_rtw_5[$num_1]) 
							   ";
	   	 	echo $class_data->query();	
		}else{
			$class_data->sql ="UPDATE tbl_rtw_5_score SET score=$arr_id_value_score_rtw_5[$num_1] WHERE stdID='$arr_std_id_all_read[$i]' AND course_teachingID=$teaching_id_find";
	   	 	echo $class_data->query();	
		}

		$num_1++;
	}
}

if(isset($_POST['acc_action']) and $_POST['acc_action'] == "save_desirable_score_std"){	
	$value_score_desirable_1=$_POST['value_score_desirable_1'];
	$value_score_desirable_2=$_POST['value_score_desirable_2'];
	$value_score_desirable_3=$_POST['value_score_desirable_3'];
	$value_score_desirable_4=$_POST['value_score_desirable_4'];
	$value_score_desirable_5=$_POST['value_score_desirable_5'];
	$value_score_desirable_6=$_POST['value_score_desirable_6'];
	$value_score_desirable_7=$_POST['value_score_desirable_7'];
	$value_score_desirable_8=$_POST['value_score_desirable_8'];

	$std_id_all_desirable=$_POST['std_id_all_desirable'];

	$arr_id_value_score_desirable_1 = explode("-", $value_score_desirable_1);
	$arr_id_value_score_desirable_2 = explode("-", $value_score_desirable_2);
	$arr_id_value_score_desirable_3 = explode("-", $value_score_desirable_3);
	$arr_id_value_score_desirable_4 = explode("-", $value_score_desirable_4);
	$arr_id_value_score_desirable_5 = explode("-", $value_score_desirable_5);
	$arr_id_value_score_desirable_6 = explode("-", $value_score_desirable_6);
	$arr_id_value_score_desirable_7 = explode("-", $value_score_desirable_7);
	$arr_id_value_score_desirable_8 = explode("-", $value_score_desirable_8);

	$teaching_id_find=$_POST['teaching_id_find'];
	$arr_std_id_all_desirable = explode("-", $std_id_all_desirable);

	$num_1=0;
	$num_2=0;
	for ($i=0; $i <count($arr_std_id_all_desirable) ; $i++) { 
			$class_data->sql ="SELECT  count(*) as num_row_chk
						FROM tbl_desirable_1 
						WHERE stdID='{$arr_std_id_all_desirable[$i]}'
						AND course_teachingID=$teaching_id_find
								";
				$class_data->select();
				$class_data->setRows();	
				$num_row_chk=$class_data->rows[0]['num_row_chk'];
				if ($num_row_chk==0) {
					$class_data->sql ="INSERT INTO tbl_desirable_1(course_teachingID,stdID,score)
										VALUES($teaching_id_find,'{$arr_std_id_all_desirable[$i]}',$arr_id_value_score_desirable_1[$num_1]) 
									   ";
			   	 	echo $class_data->query();	
				}else{
					$class_data->sql ="UPDATE tbl_desirable_1 SET score=$arr_id_value_score_desirable_1[$num_1] WHERE stdID='$arr_std_id_all_desirable[$i]' AND course_teachingID=$teaching_id_find";
			   	 	echo $class_data->query();	
				}
			$class_data->sql ="SELECT  count(*) as num_row_chk
						FROM tbl_desirable_2 
						WHERE stdID='{$arr_std_id_all_desirable[$i]}'
						AND course_teachingID=$teaching_id_find
								";
				$class_data->select();
				$class_data->setRows();	
				$num_row_chk=$class_data->rows[0]['num_row_chk'];
				if ($num_row_chk==0) {
					$class_data->sql ="INSERT INTO tbl_desirable_2(course_teachingID,stdID,score)
										VALUES($teaching_id_find,'{$arr_std_id_all_desirable[$i]}',$arr_id_value_score_desirable_2[$num_1]) 
									   ";
			   	 	echo $class_data->query();	
				}else{
					$class_data->sql ="UPDATE tbl_desirable_2 SET score=$arr_id_value_score_desirable_2[$num_1] WHERE stdID='$arr_std_id_all_desirable[$i]' AND course_teachingID=$teaching_id_find";
			   	 	echo $class_data->query();	
				}		
				$class_data->sql ="SELECT  count(*) as num_row_chk
						FROM tbl_desirable_3 
						WHERE stdID='{$arr_std_id_all_desirable[$i]}'
						AND course_teachingID=$teaching_id_find
								";
				$class_data->select();
				$class_data->setRows();	
				$num_row_chk=$class_data->rows[0]['num_row_chk'];
				if ($num_row_chk==0) {
					$class_data->sql ="INSERT INTO tbl_desirable_3(course_teachingID,stdID,score)
										VALUES($teaching_id_find,'{$arr_std_id_all_desirable[$i]}',$arr_id_value_score_desirable_3[$num_1]) 
									   ";
			   	 	echo $class_data->query();	
				}else{
					$class_data->sql ="UPDATE tbl_desirable_3 SET score=$arr_id_value_score_desirable_3[$num_1] WHERE stdID='$arr_std_id_all_desirable[$i]' AND course_teachingID=$teaching_id_find";
			   	 	echo $class_data->query();	
				}
				$class_data->sql ="SELECT  count(*) as num_row_chk
						FROM tbl_desirable_4 
						WHERE stdID='{$arr_std_id_all_desirable[$i]}'
						AND course_teachingID=$teaching_id_find
								";
				$class_data->select();
				$class_data->setRows();	
				$num_row_chk=$class_data->rows[0]['num_row_chk'];
				if ($num_row_chk==0) {
					$class_data->sql ="INSERT INTO tbl_desirable_4(course_teachingID,stdID,score)
										VALUES($teaching_id_find,'{$arr_std_id_all_desirable[$i]}',$arr_id_value_score_desirable_4[$num_1]) 
									   ";
			   	 	echo $class_data->query();	
				}else{
					$class_data->sql ="UPDATE tbl_desirable_4 SET score=$arr_id_value_score_desirable_4[$num_1] WHERE stdID='$arr_std_id_all_desirable[$i]' AND course_teachingID=$teaching_id_find";
			   	 	echo $class_data->query();	
				}
				$class_data->sql ="SELECT  count(*) as num_row_chk
						FROM tbl_desirable_5 
						WHERE stdID='{$arr_std_id_all_desirable[$i]}'
						AND course_teachingID=$teaching_id_find
								";
				$class_data->select();
				$class_data->setRows();	
				$num_row_chk=$class_data->rows[0]['num_row_chk'];
				if ($num_row_chk==0) {
					$class_data->sql ="INSERT INTO tbl_desirable_5(course_teachingID,stdID,score)
										VALUES($teaching_id_find,'{$arr_std_id_all_desirable[$i]}',$arr_id_value_score_desirable_5[$num_1]) 
									   ";
			   	 	echo $class_data->query();	
				}else{
					$class_data->sql ="UPDATE tbl_desirable_5 SET score=$arr_id_value_score_desirable_5[$num_1] WHERE stdID='$arr_std_id_all_desirable[$i]' AND course_teachingID=$teaching_id_find";
			   	 	echo $class_data->query();	
				}	
				$class_data->sql ="SELECT  count(*) as num_row_chk
						FROM tbl_desirable_6 
						WHERE stdID='{$arr_std_id_all_desirable[$i]}'
						AND course_teachingID=$teaching_id_find
								";
				$class_data->select();
				$class_data->setRows();	
				$num_row_chk=$class_data->rows[0]['num_row_chk'];
				if ($num_row_chk==0) {
					$class_data->sql ="INSERT INTO tbl_desirable_6(course_teachingID,stdID,score)
										VALUES($teaching_id_find,'{$arr_std_id_all_desirable[$i]}',$arr_id_value_score_desirable_6[$num_1]) 
									   ";
			   	 	echo $class_data->query();	
				}else{
					$class_data->sql ="UPDATE tbl_desirable_6 SET score=$arr_id_value_score_desirable_6[$num_1] WHERE stdID='$arr_std_id_all_desirable[$i]' AND course_teachingID=$teaching_id_find";
			   	 	echo $class_data->query();	
				}	
				$class_data->sql ="SELECT  count(*) as num_row_chk
						FROM tbl_desirable_7 
						WHERE stdID='{$arr_std_id_all_desirable[$i]}'
						AND course_teachingID=$teaching_id_find
								";
				$class_data->select();
				$class_data->setRows();	
				$num_row_chk=$class_data->rows[0]['num_row_chk'];
				if ($num_row_chk==0) {
					$class_data->sql ="INSERT INTO tbl_desirable_7(course_teachingID,stdID,score)
										VALUES($teaching_id_find,'{$arr_std_id_all_desirable[$i]}',$arr_id_value_score_desirable_7[$num_1]) 
									   ";
			   	 	echo $class_data->query();	
				}else{
					$class_data->sql ="UPDATE tbl_desirable_7 SET score=$arr_id_value_score_desirable_7[$num_1] WHERE stdID='$arr_std_id_all_desirable[$i]' AND course_teachingID=$teaching_id_find";
			   	 	echo $class_data->query();	
				}	
				$class_data->sql ="SELECT  count(*) as num_row_chk
						FROM tbl_desirable_8 
						WHERE stdID='{$arr_std_id_all_desirable[$i]}'
						AND course_teachingID=$teaching_id_find
								";
				$class_data->select();
				$class_data->setRows();	
				$num_row_chk=$class_data->rows[0]['num_row_chk'];
				if ($num_row_chk==0) {
					$class_data->sql ="INSERT INTO tbl_desirable_8(course_teachingID,stdID,score)
										VALUES($teaching_id_find,'{$arr_std_id_all_desirable[$i]}',$arr_id_value_score_desirable_8[$num_1]) 
									   ";
			   	 	echo $class_data->query();	
				}else{
					$class_data->sql ="UPDATE tbl_desirable_8 SET score=$arr_id_value_score_desirable_8[$num_1] WHERE stdID='$arr_std_id_all_desirable[$i]' AND course_teachingID=$teaching_id_find";
			   	 	echo $class_data->query();	
				}			

		$num_1++;
		
	}
	echo $data;


}
if(isset($_POST['acc_action']) and $_POST['acc_action'] == "save_exam_score_std"){	
	$value_score_mid=$_POST['value_score_mid'];
	$value_score_final=$_POST['value_score_final'];
	$std_id_all_exam=$_POST['std_id_all_exam'];

	$teaching_id_find=$_POST['teaching_id_find'];
	$arr_id_value_score_mid = explode(",", $value_score_mid);
	$arr_id_value_score_final = explode(",", $value_score_final);
	$arr_std_id_all_exam = explode("-", $std_id_all_exam);
	$num_mid=0;
	$num_final=0;
	for ($i=0; $i <count($arr_std_id_all_exam) ; $i++) { 
		for ($j=0; $j < 1 ; $j++) {		
			if ($arr_id_value_score_mid[$num_mid]=='ร') {
				$arr_id_value_score_mid[$num_mid]=-1;
			}	
			$class_data->sql ="SELECT  count(*) as num_row_chk
						FROM tbl_mid_exam_score 
						WHERE stdID='{$arr_std_id_all_exam[$i]}'
						AND course_teachingID=$teaching_id_find
								";
				$class_data->select();
				$class_data->setRows();	
				$num_row_chk=$class_data->rows[0]['num_row_chk'];
				if ($num_row_chk==0) {
					$class_data->sql ="INSERT INTO tbl_mid_exam_score(course_teachingID,stdID,score) 
									VALUES($teaching_id_find,
											'{$arr_std_id_all_exam[$i]}',
											 $arr_id_value_score_mid[$num_mid])";
			   	 	echo $class_data->query();	
				}else{
					$class_data->sql ="UPDATE tbl_mid_exam_score
										 SET score=$arr_id_value_score_mid[$num_mid] 
										 WHERE stdID='{$arr_std_id_all_exam[$i]}' 
										 AND course_teachingID=$teaching_id_find";
			   	 	echo $class_data->query();	
				}
				$num_mid++;

		}
		for ($z=0; $z < 1 ; $z++) {	
			if ($arr_id_value_score_final[$num_final]=='ร') {
				$arr_id_value_score_final[$num_final]=-1;
			}
			$class_data->sql ="SELECT  count(*) as num_row_chk
						FROM tbl_final_exam_score 
						WHERE stdID='{$arr_std_id_all_exam[$i]}'
						AND course_teachingID=$teaching_id_find
								";
				$class_data->select();
				$class_data->setRows();	
				$num_row_chk=$class_data->rows[0]['num_row_chk'];
				if ($num_row_chk==0) {
					$class_data->sql ="INSERT INTO tbl_final_exam_score(course_teachingID,stdID,score) 
									VALUES($teaching_id_find,
											'{$arr_std_id_all_exam[$i]}',
											 $arr_id_value_score_final[$num_final])";
			   	 	echo $class_data->query();	
				}else{
					$class_data->sql ="UPDATE tbl_final_exam_score SET score=$arr_id_value_score_final[$num_final] WHERE stdID='$arr_std_id_all_exam[$i]' AND course_teachingID=$teaching_id_find";
			   	 	echo $class_data->query();	
				}
				$num_final++;

		}
	}
echo json_encode($arr_id_value_score_mid);

}
if(isset($_POST['acc_action']) and $_POST['acc_action'] == "save_objective_score_std"){	
	$_SESSION['status_active']=$_POST['status'];

	$std_id_all=$_POST['std_id_all'];
	$registed_courseID=$_POST['registed_courseID'];
	
	//$length_list_val=$_POST['length_list_val'];
	$value_score=$_POST['value_score'];
	$data_objectiveID_of_title=$_POST['data_objectiveID_of_title'];
	
	//list($start_data,$end_data) = split('[-]', $length_list_val);
	$arr_id_value_score = explode(",", $value_score);
	$arr_data_objectiveID_of_title = explode("-", $data_objectiveID_of_title);
	$arr_std_id_all = explode("-", $std_id_all);
	$num_arr_id_value_score=count($arr_id_value_score);
	$num=0;
	for ($i=0; $i <count($arr_std_id_all) ; $i++) { 
		for ($j=0; $j < count($arr_data_objectiveID_of_title) ; $j++) {	
				if ($arr_id_value_score[$num]=='ร') {
					$arr_id_value_score[$num]=-1;
				}
				$class_data->sql ="SELECT  count(*) as num_row_chk
						FROM tbl_objective_score_std 
						WHERE staID='{$arr_std_id_all[$i]}'
						AND objectiveID=$arr_data_objectiveID_of_title[$j]
						AND registed_courseID=$registed_courseID
								";
				$class_data->select();
				$class_data->setRows();	
				$num_row_chk=$class_data->rows[0]['num_row_chk'];
				if ($num_row_chk==0) {
					$class_data->sql ="INSERT INTO tbl_objective_score_std(objectiveID,registed_courseID,staID,score) 
									VALUES($arr_data_objectiveID_of_title[$j],
											$registed_courseID,
											'{$arr_std_id_all[$i]}',
											 $arr_id_value_score[$num])";
			   	 	echo $class_data->query();	

				}else{
					$class_data->sql ="UPDATE tbl_objective_score_std SET score=$arr_id_value_score[$num] WHERE staID='$arr_std_id_all[$i]' AND objectiveID=$arr_data_objectiveID_of_title[$j] AND registed_courseID=$registed_courseID";
			   	 	echo $class_data->query();	
				}
				$num++;
		}
		
	}
	echo json_encode();
	//echo $class_data->save_objective_score_std($objective_list);
}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "open_edit_score"){	
	$objective_list=$_GET['objective_list'];
	echo $class_data->open_edit_score($objective_list);
}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "set_col_header"){	
	$length_list_val=$_GET['length_list_val'];
	echo $class_data->set_col_header($length_list_val);
}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_objective_list"){	
	unset($_SESSION['status_active']);
	$room_search=$_GET['room_search'];
	$coures_id_list_val=$_GET['coures_id_list_val'];
	$length_list_val=$_GET['length_list_val'];
	$legth_score=$_GET['legth_score'];
	$user_status=$_SESSION['ss_status'];
	if ($user_status==1) {
		echo $class_data->get_objective_list($coures_id_list_val,$length_list_val,$room_search,$legth_score);
	}elseif($user_status==2){
		$term_data=$_GET['term_data'];
		$year_data=$_GET['year_data'];
		echo $class_data->get_objective_list_admin($coures_id_list_val,$length_list_val,$room_search,$legth_score,$term_data,$year_data);
	}
	
}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_config"){	
	$legth_score=$_GET['legth_score'];
	$coures_id_list_val=$_GET['coures_id_list_val'];
	$room_search=$_GET['room_search'];
	$term_data=$_GET['term_data'];
	$year_data=$_GET['year_data'];
	echo $class_data->get_config($legth_score,$coures_id_list_val,$room_search,$term_data,$year_data);
}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "search_course_detail"){	
	$coures_id_list=$_GET['coures_id_list'];
	$room_search=$_GET['room_search'];
	$room_search=$_GET['room_search'];
	echo $class_data->search_course_detail($coures_id_list,$room_search);
}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_class_level"){	
	$coures_id_list_val=$_GET['coures_id_list_val'];
	$user_status=$_SESSION['ss_status'];
	if ($user_status==1) {
		echo $class_data->get_class_level($coures_id_list_val);
	}elseif($user_status==2){
		$term_data=$_GET['term_data'];
		$year_data=$_GET['year_data'];
		echo $class_data->get_class_level_admin($coures_id_list_val,$term_data,$year_data);
	}
	
}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_coures_id_list"){	
	$user_status=$_SESSION['ss_status'];
	if ($user_status==1) {
		echo $class_data->get_coures_id_list();
	}elseif($user_status==2){
		$term_data=$_GET['term_data'];
		$year_data=$_GET['year_data'];
		echo $class_data->get_coures_id_list_admin($term_data,$year_data);
	}
	
}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_year"){	
	echo $class_data->get_year();
}<file_sep>/modules/news/add.js
document.write(' <script type="text/javascript" src="assets/js/wyzz.php"></script>');
var opPage = 'news';
$(document).ready(function() {


}); 

 $(document).delegate('#btn_add_news', 'click', function(event) {
	$("#btn_submit").click();
 });

function loadFile1() {
    var reader = new FileReader();
    reader.onload = function(){
      var output = document.getElementById('output1');
      output.src = reader.result;
    };
    reader.readAsDataURL(event.target.files[0]);
 };
 function loadFile2() {
    var reader = new FileReader();
    reader.onload = function(){
      var output = document.getElementById('output2');
      output.src = reader.result;
    };
    reader.readAsDataURL(event.target.files[0]);
 };

function loadFile3() {
    var reader = new FileReader();
    reader.onload = function(){
      var output = document.getElementById('output3');
      output.src = reader.result;
    };
    reader.readAsDataURL(event.target.files[0]);
 };

function loadFile4() {
    var reader = new FileReader();
    reader.onload = function(){
      var output = document.getElementById('output4');
      output.src = reader.result;
    };
    reader.readAsDataURL(event.target.files[0]);
 };

function loadFile5() {
    var reader = new FileReader();
    reader.onload = function(){
      var output = document.getElementById('output5');
      output.src = reader.result;
    };
    reader.readAsDataURL(event.target.files[0]);
 };

<file_sep>/modules/conclusion/form/header_table_department.php
<?php
	
	$header_table='
			<thead>
					            <tr class="text-middle">
					              <th rowspan="2" class="rotate" style="width: 2%;height: 0px;text-align: center;">
					                <div >ที่</div>
					              </th>
					              <th rowspan="2" class="rotate" style="width: 5%;height: 0px;text-align: center;">
					                <div >ระดับชั้น</div>
					              </th>
					              <th rowspan="2" class="rotate" style="width: 12%;height: 0px;text-align: center;">
					                <div >รหัสวิชา</div>
					              </th>
					              <th colspan="10" class="rotate" style="height: 0px;text-align: center;">
					                <div >ระดับผลการเรียน</div>
					              </th>
					              <th colspan="4" class="rotate" style="height: 0px;text-align: center;">
					                <div >คุณลักษณะฯ</div>
					              </th>
					              <th colspan="4" class="rotate" style="height: 0px;text-align: center;">
					                <div >อ่าน เขียน คิดฯ</div>
					              </th>
					               <th rowspan="2" class="rotate" style="width: 3%;height: 0px;text-align: center;">
					                <div >รวม</div>
					              </th>
					            </tr> 
					            <tr class="text-middle">
					            	<th style="width: 4%;height: 0px;text-align: center;">4</th>
					            	<th style="width: 4%;height: 0px;text-align: center;">3.5</th>
					            	<th style="width: 4%;height: 0px;text-align: center;">3</th>
					            	<th style="width: 4%;height: 0px;text-align: center;">2.5</th>
					            	<th style="width: 4%;height: 0px;text-align: center;">2</th>
					            	<th style="width: 4%;height: 0px;text-align: center;">1.5</th>
					            	<th style="width: 4%;height: 0px;text-align: center;">1</th>
					            	<th style="width: 4%;height: 0px;text-align: center;">0</th>
					            	<th style="width: 4%;height: 0px;text-align: center;">ร</th>
					            	<th style="width: 4%;height: 0px;text-align: center;">มส</th>
					            	<th style="width: 4%;height: 0px;text-align: center;">3</th>
					            	<th style="width: 4%;height: 0px;text-align: center;">2</th>
					            	<th style="width: 4%;height: 0px;text-align: center;">1</th>
					            	<th style="width: 4%;height: 0px;text-align: center;">0</th>	
					            	<th style="width: 4%;height: 0px;text-align: center;">3</th>
					            	<th style="width: 4%;height: 0px;text-align: center;">2</th>
					            	<th style="width: 4%;height: 0px;text-align: center;">1</th>
					            	<th style="width: 4%;height: 0px;text-align: center;">0</th>
					            </tr>
					            
					          </thead>
';
<file_sep>/modules/maneger_student/class_modules.php
<?php 

class ClassData extends Databases {
	public function chk_id($std_ID,$card_ID){
		$data_response = array();
		$sql = "SELECT count(*) as num_std_ID 
				FROM tbl_student
				WHERE std_ID='$std_ID'		
				";
		$this->sql = $sql;
		$this->select();
		$this->setRows();
		$data_response['num_std_ID']=unchkhtmlspecialchars($this->rows[0]['num_std_ID']);

		$sql = "SELECT count(*) as num_card_ID
				FROM tbl_student
				WHERE card_ID='$card_ID'		
				";
		$this->sql = $sql;
		$this->select();
		$this->setRows();
		$data_response['num_card_ID']=unchkhtmlspecialchars($this->rows[0]['num_card_ID']);

		return json_encode($data_response);
	}
	public function update_data($update,$arr_sql_class_room,$data_id){
		$this->sql = "UPDATE tbl_student SET ".implode(",",$update)." WHERE std_ID='".$data_id."'";
		$this->query();
		$new_id = $this->insertID();
		$this->sql = "UPDATE tbl_std_class_room SET ".implode(",",$arr_sql_class_room)." WHERE std_ID='".$data_id."'";
		$this->query();
		return json_encode($new_id);
	}
	public function get_extra_data($data_id){
		$data_response = array();
		$sql = "SELECT * 
				FROM tbl_student
				WHERE std_ID='$data_id'		
				";
		$this->sql = $sql;
		$this->select();
		$this->setRows();

		$birthday=unchkhtmlspecialchars($this->rows[0]['birthday']);
		$time  = strtotime($birthday);
		$day   = date('d',$time);
		$month = date('m',$time);
		$year  = date('Y',$time)+543;
		if ($month==1 || $month==3 || $month==5 || $month==7 || $month==8 || $month==10 || $month==12) {
			for ($i=1; $i <=31 ; $i++) { 
				if ($day==$i) {
					$day_data.='<option selected value="'.$i.'">'.$i.'</option> ';
				}else{
					$day_data.='<option value="'.$i.'">'.$i.'</option> ';
				}
				
			}
		}elseif($month==4 || $month==6 || $month==9 || $month==11){
			for ($i=1; $i <=30 ; $i++) { 
				if ($day==$i) {
					$day_data.='<option selected value="'.$i.'">'.$i.'</option> ';
				}else{
					$day_data.='<option value="'.$i.'">'.$i.'</option> ';
				}
			}
		}else{
			for ($i=1; $i <=29 ; $i++) { 
				if ($day==$i) {
					$day_data.='<option selected value="'.$i.'">'.$i.'</option> ';
				}else{
					$day_data.='<option value="'.$i.'">'.$i.'</option> ';
				}
			}
		}
		$data_response['day']=$day_data;
		$data_response['month']=$month;
		$data_response['year']=$year;
	

		return $data_response;
	}
	public function get_data_form($data_id,$new_data_id){
		$data_response = array();
		$this->sql ="SELECT  *
					FROM tbl_set_term_year 			
							";
		$this->select();
		$this->setRows();
		
		$year_set=$this->rows[0]['year'];
		if (isset($new_data_id) && $new_data_id!="") {
			$sql = "SELECT * 
				FROM tbl_student
				WHERE std_ID='$new_data_id'		
				";
			$sql_class = "SELECT * 
				FROM tbl_std_class_room
				WHERE std_ID='$new_data_id'
				AND year='$year_set'	
				";
		}else{
			$sql = "SELECT * 
				FROM tbl_student
				WHERE std_ID='$data_id'		
				";
			$sql_class = "SELECT * 
				FROM tbl_std_class_room
				WHERE std_ID='$data_id'	
				AND year='$year_set'	
				";
		}
		$this->sql = $sql;
		$this->select();
		$this->setRows();
		$data_response['std_ID']=unchkhtmlspecialchars($this->rows[0]['std_ID']);
		$data_response['card_ID']=unchkhtmlspecialchars($this->rows[0]['card_ID']);
		
		$data_response['name_title']=unchkhtmlspecialchars($this->rows[0]['name_title']);
		$data_response['fname']=unchkhtmlspecialchars($this->rows[0]['fname']);
		$data_response['lname']=unchkhtmlspecialchars($this->rows[0]['lname']);		
		$data_response['blood_group']=unchkhtmlspecialchars($this->rows[0]['blood_group']);
		$data_response['address']=unchkhtmlspecialchars($this->rows[0]['address']);
		$data_response['parent_name_title']=unchkhtmlspecialchars($this->rows[0]['parent_name_title']);
		$data_response['parent_fname']=unchkhtmlspecialchars($this->rows[0]['parent_fname']);
		$data_response['parent_lname']=unchkhtmlspecialchars($this->rows[0]['parent_lname']);
		$data_response['tell']=unchkhtmlspecialchars($this->rows[0]['tell']);
		$data_response['parent_address']=unchkhtmlspecialchars($this->rows[0]['parent_address']);
		$data_response['status']=unchkhtmlspecialchars($this->rows[0]['status']);
		
		$this->sql = $sql_class;
		$this->select();
		$this->setRows();
		$data_response['class_level']=unchkhtmlspecialchars($this->rows[0]['class_level']);
		$data_response['room']=unchkhtmlspecialchars($this->rows[0]['room']);
		$data_response['status_alive']=unchkhtmlspecialchars($this->rows[0]['status']);
		return json_encode($data_response);
	}
	public function get_years(){
		$data_response = array();
		$years_now=intval(date("Y"));+
		$years_now=$years_now+543;
		for ($i=$years_now; $i >= 2480  ; $i--) { 
			$data_response['set_years'].='<option value="'.$i.'">'.$i.'</option>';
		}
		echo json_encode($data_response);
	}
	public function get_day($mouth){
		$data_response = array();
		
		for ($i=1; $i <= 29 ; $i++) { 
			$day_make_29.='<option value="'.$i.'">'.$i.'</option>';
		}
		for ($i=1; $i <= 30 ; $i++) { 
			$day_make_30.='<option value="'.$i.'">'.$i.'</option>';
		}
		for ($i=1; $i <= 31 ; $i++) { 
			$day_make_31.='<option value="'.$i.'">'.$i.'</option>';
		}
		if ($mouth==1 || $mouth==3 || $mouth==5 || $mouth==7 || $mouth==8 || $mouth==10 || $mouth==12) {
			$data_response['day_set']=$day_make_31;
		}elseif($mouth==4 || $mouth==6 || $mouth==9 || $mouth==11){
			$data_response['day_set']=$day_make_30;
		}else{
			$data_response['day_set']=$day_make_29;
		}

	echo json_encode($data_response);
	}
	public function get_data_delete($data_val){
		$arr_id = explode(",", $data_val);
		$num=0;
		for ($i=0; $i < count($arr_id) ; $i++) { 
            $this->sql ="DELETE FROM tbl_student WHERE std_ID = '{$arr_id[$i]}'";
	        $this->query();

           $num=$num+$i;
		}
		return $num;
	}
	public function get_class_level($class_level_data){
		if ($class_level_data=="p1") {
			$class_level="ป.1";
		}elseif($class_level_data=="p2"){
			$class_level="ป.2";	
		}elseif($class_level_data=="p3"){
			$class_level="ป.3";	
		}elseif($class_level_data=="p4"){
			$class_level="ป.4";	
		}elseif($class_level_data=="p5"){
			$class_level="ป.5";	
		}elseif($class_level_data=="p6"){
			$class_level="ป.6";	
		}elseif($class_level_data=="m1"){
			$class_level="ม.1";	
		}elseif($class_level_data=="m2"){
			$class_level="ม.2";	
		}elseif($class_level_data=="m3"){
			$class_level="ม.3";	
		}elseif($class_level_data=="m4"){
			$class_level="ม.4";	
		}elseif($class_level_data=="m5"){
			$class_level="ม.5";	
		}elseif($class_level_data=="m6"){
			$class_level="ม.6";	
		}
		return $class_level;
	}
	public function get_name_title($name_title_data){
		if ($name_title_data=="dekchai") {
			$name_title="เด็กชาย";
		}elseif($name_title_data=="dekying"){
			$name_title="เด็กหญิง";
		}elseif($name_title_data=="nai"){
			$name_title="นาย";
		}elseif($name_title_data=="nangsaw"){
			$name_title="นางสาว";
		}
		return $name_title;
	}
	public function data_year_search_student($arr_search_val){
		$data_response = array();
		$this->sql ="SELECT  *
					FROM tbl_set_term_year 			
							";
		$this->select();
		$this->setRows();
		
		$year_set=$this->rows[0]['year'];
		$data_class_search = $arr_search_val['data_class_search'];
		$data_room_search = $arr_search_val['data_room_search'];
		
		$sql = "SELECT tbl_student.std_ID,tbl_student.name_title,tbl_student.fname,tbl_student.lname,tbl_std_class_room.class_level,tbl_std_class_room.room
				FROM tbl_student,tbl_std_class_room
				WHERE tbl_student.std_ID=tbl_std_class_room.std_ID
				AND tbl_std_class_room.year ='$year_set' 
				AND tbl_std_class_room.status =1
				AND tbl_std_class_room.class_level='$data_class_search'
				AND tbl_std_class_room.room='$data_room_search'
				ORDER BY tbl_std_class_room.class_level,tbl_std_class_room.room,
				CASE
					WHEN name_title LIKE '%dekchai%' THEN 0
			        WHEN name_title LIKE '%nai%' THEN 1
			        WHEN name_title LIKE '%dekying%' THEN 2
			        WHEN name_title LIKE '%nangsaw%'THEN 3
			        WHEN tbl_student.std_ID THEN 4      
			    END
				";
		$this->sql = $sql;
		$this->select();
		$this->setRows();
		
		foreach($this->rows as $key => $value) {
			$std_ID= $value['std_ID'];	
			$name_title_data= $value['name_title'];
			$name_title=$this->get_name_title($name_title_data);
			$fname= $value['fname'];	
			$lname= $value['lname'];	
			$class_level_data= $value['class_level'];
			$class_level=$this->get_class_level($class_level_data);
			$room= $value['room'];

			$data_response['table_list'].='
								<tr >                                
                                  <td style="text-align: center;">'.$std_ID.'</td>
                                  <td style="text-align: left;padding-left:7%;">'.$name_title.$fname.'</td>
                                  <td style="text-align: left;padding-left:7%;">'.$lname.'</td>
                                  <td style="text-align: center;">'.$class_level.'</td>
                                  <td style="text-align: center;">'.$room.'</td>
                                  <td style="text-align: center;">
                                  <a href="index.php?op=maneger_student-edit&id='.$std_ID.'">
                                    <span class="glyphicon glyphicon-edit edit-icon-table" ari a-hidden="true" ></span>
                                  </a>
                                  </td>
                                
                                </tr>
			';

			}
		
		if($data_response['table_list']==''){
			$data_response['table_list']='';
		}
		
		return json_encode($data_response);
	}
	public function get_data($arr_search_val){
		$data_response = array();
		$this->sql ="SELECT  *
					FROM tbl_set_term_year 			
							";
		$this->select();
		$this->setRows();
		
		$year_set=$this->rows[0]['year'];

		$data_response = array();
		$sql_condition = "tbl_student.std_ID is not null ";
		$name_id_search = $arr_search_val['name_id_search'];

		if (isset($name_id_search) && $name_id_search != "") {
			$sql_condition .= " AND ( tbl_student.std_ID LIKE '%{$name_id_search}%')  
								AND tbl_student.std_ID IN(
									SELECT std_ID
									FROM tbl_std_class_room 
									WHERE year='$year_set'
									AND status=1
								) 
								OR ( tbl_student.fname LIKE '%{$name_id_search}%') 
								AND tbl_student.std_ID IN(
									SELECT std_ID
									FROM tbl_std_class_room 
									WHERE year='$year_set'
									AND status=1
								) 
								OR ( tbl_student.lname LIKE '%{$name_id_search}%') 
								AND tbl_student.std_ID IN(
									SELECT std_ID
									FROM tbl_std_class_room 
									WHERE year='$year_set'
									AND status=1
								) 
								";
		}else{
			$sql_condition .= " 
							AND tbl_student.std_ID IN(
									SELECT std_ID
									FROM tbl_std_class_room 
									WHERE year='$year_set'
									AND status=1
								) 
								";
		}	
		$sql = "SELECT count(*) as num_row_count
				FROM tbl_student
				WHERE $sql_condition
				";
		$this->sql = $sql;
		$this->select();
		$this->setRows();		
		$num_row_count=$this->rows[0]['num_row_count'];

		$sql = "
				SELECT tbl_student.std_ID,tbl_student.name_title,tbl_student.fname,tbl_student.lname,tbl_std_class_room.class_level,tbl_std_class_room.room
				FROM tbl_student,tbl_std_class_room
				WHERE tbl_student.std_ID=tbl_std_class_room.std_ID
				AND $sql_condition
				ORDER BY tbl_std_class_room.class_level,tbl_std_class_room.room,
				CASE
					WHEN name_title LIKE '%dekchai%' THEN 0
			        WHEN name_title LIKE '%nai%' THEN 1
			        WHEN name_title LIKE '%dekying%' THEN 2
			        WHEN name_title LIKE '%nangsaw%'THEN 3
			        WHEN tbl_student.std_ID THEN 4      
			    END
				";
		$this->sql = $sql;
		$this->select();
		$this->setRows();
		if ($num_row_count!=0) {
		foreach($this->rows as $key => $value) {
			$std_ID= $value['std_ID'];	
			$name_title_data= $value['name_title'];
			$name_title=$this->get_name_title($name_title_data);
			$fname= $value['fname'];	
			$lname= $value['lname'];	
			$class_level_data= $value['class_level'];
			$class_level=$this->get_class_level($class_level_data);
			$room= $value['room'];

			$data_response['table_list'].='
								<tr >                                
                                  <td style="text-align: center;">'.$std_ID.'</td>
                                  <td style="text-align: left;padding-left:7%;">'.$name_title.$fname.'</td>
                                  <td style="text-align: left;padding-left:7%;">'.$lname.'</td>
                                  <td style="text-align: center;">'.$class_level.'</td>
                                  <td style="text-align: center;">'.$room.'</td>
                                  <td style="text-align: center;">
                                  <a href="index.php?op=maneger_student-edit&id='.$std_ID.'">
                                    <span class="glyphicon glyphicon glyphicon-edit edit-icon-table" ari a-hidden="true" ></span>
                                  </a>
                                  </td>
                                 
                                </tr>
			';

			}
		}else{
			$data_response['table_list'].='';
		}
		return json_encode($data_response);
	}
}<file_sep>/modules/up_class/class_modules.php
<?php 

class ClassData extends Databases {
	
	public function reverse_upclass($data_year_old,$data_year_new,$log_upclass_id){
		$this->sql = "DELETE FROM tbl_std_class_room WHERE year='$data_year_new'";
		$this->query();
		$this->sql = "UPDATE tbl_std_class_room SET status=1 WHERE year='$data_year_old' AND status=0 
					  AND class_level='p1' OR class_level='p2' OR class_level='p3' OR class_level='p4' OR class_level='p5' OR class_level='m1' OR class_level='m2' OR class_level='m4' OR class_level='m5'";
		$this->query();
		$this->sql = "DELETE FROM tbl_log_upclass WHERE DataID=$log_upclass_id";
		$this->query();
		return json_encode($log_upclass_id);
	}
	public function insert_log_upclass($std_year_new,$std_year_old){
		$user_add=$_SESSION['ss_user_id'];
		$c_date=date("Y-m-d");
		$this->sql = "INSERT INTO tbl_log_upclass(user_add,c_date,std_year_old,std_year_new) 
					  VALUES($user_add,'$c_date','$std_year_old','$std_year_new')";
		$this->query();
	}
	public function chk_before_status($std_ID,$set_class_before){
		$data_response = array();	
		$sql = "SELECT COUNT(*) AS num_row
				FROM tbl_std_class_room
				WHERE std_ID=$std_ID
				AND class_level='$set_class_before'
				AND status=0
				";
		$this->sql = $sql;
		$this->select();
		$this->setRows();	
	
		return $this->rows[0]['num_row'];
	}
	public function up_class_p($i){
 
		$set_class_p_number=$i-1;
		$set_class_p_number_before=$i-2;
		$set_class_p_find='p'.$set_class_p_number;
		$set_class_p_new='p'.$i;
		$set_class_p_before='p'.$set_class_p_number_before;
		$this->sql ="SELECT tbl_std_class_room.DataID as std_class_room_id, tbl_student.std_ID,tbl_std_class_room.room,tbl_std_class_room.year
					FROM tbl_student,tbl_std_class_room
					WHERE tbl_student.std_ID=tbl_std_class_room.std_ID
					AND tbl_std_class_room.status=1
					AND tbl_std_class_room.class_level='$set_class_p_find'
						";
		$this->select();
		$this->setRows();
		foreach($this->rows as $key => $value) {
			$std_class_room_id= $value['std_class_room_id'];
			$std_ID= $value['std_ID'];
			$class_level=$set_class_p;
			$room= $value['room'];
			$year= $value['year'];
			$set_year=$year+1;
				$this->sql = "INSERT INTO tbl_std_class_room(std_ID,class_level,room,year,status) VALUES('$std_ID','$set_class_p_new','$room','$set_year',99)";
				$this->query();
				$this->sql = "UPDATE tbl_std_class_room SET status=0 WHERE DataID=$std_class_room_id";
				$this->query();	
		}
		if ($i==1) {
			$this->sql = "UPDATE tbl_std_class_room SET status=1 WHERE status=99";
			$this->query();
			$this->insert_log_upclass($set_year,$year);
		}
		return json_encode(1);
	}
	public function up_class_m($i){
		
		$set_class_m_number=$i-1;
		$set_class_m_number_before=$i-2;
		$set_class_m_find='m'.$set_class_m_number;
		$set_class_m_new='m'.$i;
		$set_class_m_before='m'.$set_class_m_number_before;
		$this->sql ="SELECT tbl_std_class_room.DataID as std_class_room_id, tbl_student.std_ID,tbl_std_class_room.room,tbl_std_class_room.year
					FROM tbl_student,tbl_std_class_room
					WHERE tbl_student.std_ID=tbl_std_class_room.std_ID
					AND tbl_std_class_room.status=1
					AND tbl_std_class_room.class_level='$set_class_m_find'

						";
		$this->select();
		$this->setRows();
		$num_row_set=0;
		foreach($this->rows as $key => $value) {
			$std_class_room_id= $value['std_class_room_id'];
			$std_ID= $value['std_ID'];
			$class_level=$set_class_m;
			$room= $value['room'];
			$year= intval($value['year']);
			$set_year=$year+1;
				$this->sql = "INSERT INTO tbl_std_class_room(std_ID,class_level,room,year,status) VALUES('$std_ID','$set_class_m_new','$room','$set_year',99)";
				$this->query();
				$this->sql = "UPDATE tbl_std_class_room SET status=0 WHERE DataID=$std_class_room_id";
				$this->query();
				$num_row_set++;
			}
		
		if ($i==6) {
			$this->sql = "UPDATE tbl_std_class_room SET status=1 WHERE status=99";
			$this->query();
			
		}
		return json_encode(1);
	}
	public function data_upclassed(){
		$data_response = array();	
		$sql = "SELECT *
				FROM tbl_log_upclass
				ORDER BY std_year_new DESC
				";
		$this->sql = $sql;
		$this->select();
		$this->setRows();	
		foreach($this->rows as $key => $value) {
			$DataID= $value['DataID'];
			$user_add_set= $value['user_add'];
			$c_date_set= $value['c_date'];
			$old_form_date = strtotime($c_date_set);
			$c_date=date('d/m/Y', $old_form_date); 
			$std_year_old= $value['std_year_old'];
			$std_year_new= $value['std_year_new'];
			$user_add=$this->get_user_add($user_add_set);
			if ($key==0) {
				$btn_reverse='
					<img class="edit-icon-table btn_reverse" data-id="'.$DataID.'" data-text="'.$std_year_new.' เป็น '.$std_year_old.'" data-year-old="'.$std_year_old.'" data-year-new="'.$std_year_new.'" style="width:16px;margin:0 auto;" src="assets/images/glyphicons-366-restart.png" data-toggle="modal" data-target="#modalReverse">
                           	
				';
			}else{
				$btn_reverse='';
			}
			$data_response.='
						<tr>                                
                          <td style="text-align: center;">
                            จาก '.$std_year_old.' เป็น '.$std_year_new.'
                          </td>
                          <td style="text-align: center;">'.$user_add.'</td>
                          <td style="text-align: center;">'.$c_date.'</td>
                          <td style="text-align: center;">
                            '.$btn_reverse.'
                          </td>
                        </tr>
			';
		}
		echo json_encode($data_response);
	}
	public function get_user_add($user_id){
		$data_response = array();	
		$sql = "SELECT *
				FROM tbl_regis_teacher
				WHERE DataID=$user_id
				";
		$this->sql = $sql;
		$this->select();
		$this->setRows();	
		$fname_th=$this->rows[0]['fname_th'];
		$lname_th=$this->rows[0]['lname_th'];
		return $fname_th.' '.$lname_th;
	}
	public function get_year(){
		$data_response = array();	
		$sql = "
				SELECT DISTINCT(year) AS year
				FROM tbl_student,tbl_std_class_room
				WHERE tbl_student.std_ID=tbl_std_class_room.std_ID
				AND tbl_std_class_room.status=1
				AND tbl_std_class_room.class_level='p1'
				OR tbl_std_class_room.class_level='p2' OR tbl_std_class_room.class_level='p3' OR tbl_std_class_room.class_level='p4' OR tbl_std_class_room.class_level='m1' OR tbl_std_class_room.class_level='m2' OR tbl_std_class_room.class_level='m4' OR tbl_std_class_room.class_level='m5'
			
				";
		$this->sql = $sql;
		$this->select();
		$this->setRows();		
		$year=$this->rows[0]['year'];
		echo json_encode($year); 
	}
	public function data_year_search_student($data_class_search){
		$data_response = array();
		$this->sql ="SELECT  year
					FROM tbl_set_term_year
					
							";
		$this->select();
		$this->setRows();
		$year=$this->rows[0]['year'];

		$sql = "SELECT count(*) as num_row_count
				FROM tbl_student
				WHERE std_ID in(
						SELECT std_ID
						FROM tbl_std_class_room
						WHERE status=1 
						AND class_level='$data_class_search'
					)
				";
		$this->sql = $sql;
		$this->select();
		$this->setRows();		
		$num_row_count=$this->rows[0]['num_row_count'];
		$sql = "
			    SELECT tbl_student.std_ID,tbl_student.name_title,tbl_student.fname,tbl_student.lname,tbl_std_class_room.room
				FROM tbl_student,tbl_std_class_room
				WHERE tbl_student.std_ID=tbl_std_class_room.std_ID
				AND tbl_std_class_room.status=1
				AND tbl_std_class_room.class_level='$data_class_search'
				ORDER BY tbl_std_class_room.class_level,tbl_std_class_room.room,
				CASE
					WHEN name_title LIKE '%dekchai%' THEN 0
			        WHEN name_title LIKE '%nai%' THEN 1
			        WHEN name_title LIKE '%dekying%' THEN 2
			        WHEN name_title LIKE '%nangsaw%'THEN 3
			        WHEN tbl_student.std_ID THEN 4      
			    END
				
				";
		$this->sql = $sql;
		$this->select();
		$this->setRows();
		if ($num_row_count!=0) {
		foreach($this->rows as $key => $value) {
			$std_ID= $value['std_ID'];	
			$name_title_data= $value['name_title'];
			$name_title=$this->get_name_title($name_title_data);
			$fname= $value['fname'];	
			$lname= $value['lname'];	
			$class_level=$this->get_class_level($data_class_search);
			$room= $value['room'];

			$data_response['table_list'].='
								<tr >                                
                                  <td style="text-align: center;">'.$std_ID.'</td>
                                  <td style="text-align: left;padding-left:7%;">'.$name_title.$fname.'</td>
                                  <td style="text-align: left;padding-left:7%;">'.$lname.'</td>
                                  <td style="text-align: center;">'.$class_level.'</td>
                                  <td style="text-align: center;">'.$room.'</td>
                                  <td style="text-align: center;">
                                 	'.$year.'
                                  </td>
                                  
                                </tr>
			';

			}
		}else{
			$data_response['table_list'].='';
		}
		return json_encode($data_response);
	}	
	public function get_name_title($name_title_data){
		if ($name_title_data=="dekchai") {
			$name_title="เด็กชาย";
		}elseif($name_title_data=="dekying"){
			$name_title="เด็กหญิง";
		}elseif($name_title_data=="nai"){
			$name_title="นาย";
		}elseif($name_title_data=="nangsaw"){
			$name_title="นางสาว";
		}
		return $name_title;
	}
	public function get_class_level($class_level_data){
		if ($class_level_data=="p1") {
			$class_level="ป.1";
		}elseif($class_level_data=="p2"){
			$class_level="ป.2";	
		}elseif($class_level_data=="p3"){
			$class_level="ป.3";	
		}elseif($class_level_data=="p4"){
			$class_level="ป.4";	
		}elseif($class_level_data=="p5"){
			$class_level="ป.5";	
		}elseif($class_level_data=="p6"){
			$class_level="ป.6";	
		}elseif($class_level_data=="m1"){
			$class_level="ม.1";	
		}elseif($class_level_data=="m2"){
			$class_level="ม.2";	
		}elseif($class_level_data=="m3"){
			$class_level="ม.3";	
		}elseif($class_level_data=="m4"){
			$class_level="ม.4";	
		}elseif($class_level_data=="m5"){
			$class_level="ม.5";	
		}elseif($class_level_data=="m6"){
			$class_level="ม.6";	
		}
		return $class_level;
	}
}<file_sep>/modules/save_score/class_modules.php
<?php 

class ClassData extends Databases {
	
	public function get_end_data_find($start_data,$end_data){
		$end_data_last=$end_data+1;
		return $end_data_last-$start_data;
	}
	public function set_col_header($length_list_val){
		$data_response = array();	
		list($start_data,$end_data) = split('[-]', $length_list_val);
		$data_response['end_data_find']=$this->get_end_data_find($start_data,$end_data);
		return json_encode($data_response);
	}
	public function get_score_col_total($std_ID,$registed_courseID,$set_status){
		if($set_status=='before'){
			$condition='WHERE proportion_status=1';
		}elseif($set_status=='after'){
			$condition='WHERE proportion_status=2';
		}
		$num_of_i=0;
		$this->sql ="SELECT  count(score) as num_of_i
					FROM tbl_objective_score_std 	
					WHERE staID='$std_ID'
					AND registed_courseID=$registed_courseID
					AND score=-1
					AND objectiveID IN(
						SELECT DataID
						FROM tbl_objective_conclude
						$condition
					)
					";
			$this->select();
			$this->setRows();	
			$num_of_i=$this->rows[0]['num_of_i'];
		$this->sql ="SELECT  SUM(score) as score_total
					FROM tbl_objective_score_std 	
					WHERE staID='$std_ID'
					AND registed_courseID=$registed_courseID
					AND objectiveID IN(
						SELECT DataID
						FROM tbl_objective_conclude
						$condition
					)
					";
			$this->select();
			$this->setRows();	
			$score_total_data=$this->rows[0]['score_total'];
			if ($score_total_data==0) {
				$score_total=0;	
			}else{
				$score_total=$score_total_data;	
			}
			return $score_total+$num_of_i;
	}
	public function get_total_proportion($data_id){
		$data_response = array();	
		$this->sql ="SELECT  *
					FROM tbl_proportion 	
					WHERE courseID=$data_id				
					";
			$this->select();
			$this->setRows();	
			$data_response['mid_exam'] =$this->rows[0]['mid_exam'];	
			$data_response['final_exam'] =$this->rows[0]['final_exam'];
			return $data_response;
	}
	public function get_total_ob_conclude($data_objective_ob){
		$this->sql ="SELECT  score
					FROM tbl_objective_conclude 	
					WHERE DataID=$data_objective_ob					
					";
			$this->select();
			$this->setRows();	
			return $this->rows[0]['score'];	
	}

	public function get_score_col($std_ID,$data_objective,$registed_courseID,$start_data,$no_std){
		$arr_id = explode("-", $data_objective);
		$no_order_ext=1;
		for ($i=0; $i < count($arr_id) ; $i++) { 
			if ($arr_id[$i]=='') {
				$arr_id[$i]=0;
			}else{
				$arr_id[$i]=$arr_id[$i];
			}
			$total_ob_conclude=$this->get_total_ob_conclude($arr_id[$i]);
			

			$this->sql ="SELECT  no_order
					FROM tbl_objective_conclude 	
					WHERE DataID={$arr_id[$i]}
					
					";
			$this->select();
			$this->setRows();	
			$no_order=$this->rows[0]['no_order'];

			$this->sql ="SELECT  *
					FROM tbl_objective_score_std 	
					WHERE staID='$std_ID'
					AND objectiveID={$arr_id[$i]}
					AND registed_courseID=$registed_courseID
					";
			$this->select();
			$this->setRows();	
			$DataID=$this->rows[0]['DataID'];	
			$score=$this->rows[0]['score'];	
			if ($score=='' || $score==0) {
				$score=0;
			}else{
				if ($score==-1) {
					$score='ร';
				}else{
					$score=$score;
				}				
			}
			$data_response.='<td class="relative" ><input style="text-align: center;" onkeyup="chk_score_over(this,this.value)" class_name_change="'.$DataID.'" value_set="'.$score.'" data_main_chk_over="'.$total_ob_conclude.'" name="objective_score_std[]" disabled="disabled" class="select-table-form class_col_set_new class_name_'.$DataID.' class_col_'.$no_order_ext.$no_order.'" type="text"  value="'.$score.'"></td>';
			$start_data++;
			$no_order_ext++;
		}
		return $data_response;
	}	
	public function get_detail_std($coures_id_list_val,$registed_courseID,$data_objective,$start_data,$room_search,$set_status,$term_set,$year_set){
		if ($term_set=='' && $year_set=='') {
			$this->sql ="SELECT  *
					FROM tbl_set_term_year 			
							";
			$this->select();
			$this->setRows();
			$term_set=$this->rows[0]['term'];
			$year_set=$this->rows[0]['year'];
		}
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 	
					WHERE DataID=$coures_id_list_val					
					";
		$this->select();
		$this->setRows();
		$class_level=$this->rows[0]['class_level'];

		if ($class_level=='p1' || $class_level=='p2' || $class_level=='p3' || $class_level=='p4' || $class_level=='p5' || $class_level=='p6') {
			$term_set='1,2';
		}
		$this->sql ="SELECT  *
					FROM tbl_student 	
					WHERE std_ID in(
						SELECT std_ID
						FROM tbl_std_class_room
						WHERE room='$room_search'
						AND year='$year_set'
					)	
					AND std_ID in(
						SELECT stdID
					    FROM tbl_course_teaching_std
					    WHERE registed_courseID IN(
					    	SELECT DataID
					        FROM tbl_registed_course
					        WHERE courseID=$coures_id_list_val
					        AND term='$term_set'
					        AND year='$year_set'
					    )
					)
					ORDER BY
					CASE
						WHEN name_title LIKE '%dekchai%' THEN 0
				        WHEN name_title LIKE '%nai%' THEN 1
				        WHEN name_title LIKE '%dekying%' THEN 2
				        WHEN name_title LIKE '%nangsaw%'THEN 3
				        WHEN std_ID THEN 4      
				    END
					";
		$this->select();
		$this->setRows();		
		$no_std=1;
		foreach($this->rows as $key => $value) {
			$std_ID=$value['std_ID'];
			$fname=$value['fname'];
			$lname=$value['lname'];
			$name_title_data=$value['name_title'];
			$name_title=$this->get_name_title($name_title_data);
			$class_level_status=$this->get_class_level_status($coures_id_list_val);
			$score_col=$this->get_score_col($std_ID,$data_objective,$registed_courseID,$start_data,$no_std);
			$score_col_total=$this->get_score_col_total($std_ID,$registed_courseID,$set_status);
			$data_response.='<tr>
										<td>'.$no_std.'</td>
										<td>'.$std_ID.'</td>
						                  <td style="text-align:left;padding-left:4%;">'.$name_title.$fname.' '.$lname.'</td>
						                  '.$score_col.'
						                 <td>'.$score_col_total.'</td>
						             </tr>
			';
					
			$no_std++;
			
		}
		return $data_response;
	}
	public function get_class_level_status($coures_id_list_val){
		$data_response = array();	
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 	
					WHERE DataID=$coures_id_list_val
					";
		$this->select();
		$this->setRows();		
		$class_level=$this->rows[0]['class_level'];	
		if ($class_level=='p1' || $class_level=='p2' || $class_level=='p3' || $class_level=='p4' || $class_level=='p5' || $class_level=='p6') {
			$data='p';
		}else{
			$data='m';
		}
		return $data;
	}
	public function get_std_id_all($coures_id_list_val,$room_search,$term_set,$year_set){
		if ($term_set=='' && $year_set=='') {
			$this->sql ="SELECT  *
					FROM tbl_set_term_year 			
							";
			$this->select();
			$this->setRows();
			$term_set=$this->rows[0]['term'];
			$year_set=$this->rows[0]['year'];	
		}
		
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 	
					WHERE DataID=$coures_id_list_val					
					";
		$this->select();
		$this->setRows();
		$class_level=$this->rows[0]['class_level'];
		if ($class_level=='p1' || $class_level=='p2' || $class_level=='p3' || $class_level=='p4' || $class_level=='p5' || $class_level=='p6') {
			$term_set='1,2';
		}

		$this->sql ="SELECT  count(*) as num_row_std
					FROM tbl_student 
					WHERE std_ID in(
						SELECT std_ID
						FROM tbl_std_class_room
						WHERE room='$room_search'
						
						AND year='$year_set'
					)	
					AND std_ID in(
						SELECT stdID
						FROM tbl_course_teaching_std
						WHERE registed_courseID in(
							SELECT DataID
							FROM tbl_registed_course
							WHERE courseID=$coures_id_list_val
							AND term='$term_set'
					        AND year='$year_set'
						)
					)
					";
		$this->select();
		$this->setRows();
		$num_row_std=$this->rows[0]['num_row_std'];			
		$this->sql ="SELECT  *
					FROM tbl_student 
					WHERE std_ID in(
						SELECT std_ID
						FROM tbl_std_class_room
						WHERE room='$room_search'
						
						AND year='$year_set'
					)	
					AND std_ID in(
						SELECT stdID
						FROM tbl_course_teaching_std
						WHERE registed_courseID in(
							SELECT DataID
							FROM tbl_registed_course
							WHERE courseID=$coures_id_list_val
							AND term='$term_set'
					        AND year='$year_set'
						)
					)
					ORDER BY
					CASE
						WHEN name_title LIKE '%dekchai%' THEN 0
				        WHEN name_title LIKE '%nai%' THEN 1
				        WHEN name_title LIKE '%dekying%' THEN 2
				        WHEN name_title LIKE '%nangsaw%'THEN 3
				        WHEN std_ID THEN 4      
				    END
					";
		$this->select();
		$this->setRows();		
		$no_std=1;
		foreach($this->rows as $key => $value) {
			$std_ID=$value['std_ID'];		
			if ($num_row_std==$no_std) {
				$std_id_all.=$std_ID;
			}else{
				$std_id_all.=$std_ID.'-';
			}
			
			$no_std++;
			
		}
		$data_response=$std_id_all;
		return $data_response;
	}

	public function get_proportion_cumulative($coures_id_list_val,$set_status){
		switch ($set_status) {
			case 'before':
				$sql_con="cumulative_before_mid";
				break;
			case 'after':
				$sql_con="cumulative_after_mid";
				break;
			default:
				$sql_co="courseID";
				break;
		}
		$this->sql ="SELECT  $sql_con as cumulative_sum
					FROM tbl_proportion 	
					WHERE courseID=$coures_id_list_val
					";
		$this->select();
		$this->setRows();	
		return $this->rows[0]['cumulative_sum'];
	}
	public function get_objective_list_admin($coures_id_list_val,$length_list_val,$room_search,$legth_score,$term_data,$year_data){
		$data_response = array();		
		//$data_response['proportion_cumulative']=$this->get_proportion_cumulative($coures_id_list_val);
		list($start_data, $end_data) = split('[-]', $length_list_val);
		$find_start=$start_data-1;
		$find_end=$end_data-$find_start;
		if($legth_score=='save-score-pick-before'){
			$condition="proportion_status=1";
			$set_status='before';
		}elseif($legth_score=='save-score-pick-after'){
			$condition="proportion_status=2";
			$set_status='after';
		}
		$this->sql ="SELECT  *
					FROM tbl_objective_conclude 	
					WHERE courseID=$coures_id_list_val
					AND $condition
					ORDER BY no_order
					LIMIT $find_start,$find_end

					";
		$this->select();
		$this->setRows();	
		$chk_loop=1;	
		$no_order_ext=1;
		foreach($this->rows as $key => $value) {
			$DataID=$value['DataID'];
			$no_order=$value['no_order'];
			$score=$value['score'];
			$data_response['objective_list'].=' <option value="'.$no_order_ext.$no_order.'">ข้อที่ '.$no_order.'</option>';
			$data_response['ob_title_table_col'].='<td>'.$no_order.'</td>';		
			$data_response['ob_score_max_table_col'].='<td>'.$score.'</td>';	

			if ($find_end==$chk_loop) {
				$data_objective.=$DataID; 
			}else{
				$data_objective.=$DataID.'-'; 
			}
			
			$chk_loop++;
			$no_order_ext++;
		}
		$data_response['ob_score_max_table_col'].='<td style="background-color:#f3e7f9;">'.$this->get_proportion_cumulative($coures_id_list_val,$set_status).'</td>';
		$registed_courseID=$this->get_registed_courseID($coures_id_list_val,$term_data,$year_data);
		$data_response['registed_courseID']=$registed_courseID;
		$data_response['detail_std']=$this->get_detail_std($coures_id_list_val,$registed_courseID,$data_objective,$start_data,$room_search,$set_status,$term_data,$year_data);	
		$data_response['std_id_all']=$this->get_std_id_all($coures_id_list_val,$room_search,$term_data,$year_data);
		$data_response['data_objectiveID_of_title']=$data_objective;
		return json_encode($data_response);
	}
	public function get_objective_list($coures_id_list_val,$length_list_val,$room_search,$legth_score){
		$data_response = array();		
		//$data_response['proportion_cumulative']=$this->get_proportion_cumulative($coures_id_list_val);
		list($start_data, $end_data) = split('[-]', $length_list_val);
		$find_start=$start_data-1;
		$find_end=$end_data-$find_start;
		if($legth_score=='save-score-pick-before'){
			$condition="proportion_status=1";
			$set_status='before';
		}elseif($legth_score=='save-score-pick-after'){
			$condition="proportion_status=2";
			$set_status='after';
		}
		$this->sql ="SELECT  *
					FROM tbl_objective_conclude 	
					WHERE courseID=$coures_id_list_val
					AND $condition
					ORDER BY no_order
					LIMIT $find_start,$find_end

					";
		$this->select();
		$this->setRows();	
		$chk_loop=1;	
		$no_order_ext=1;
		foreach($this->rows as $key => $value) {
			$DataID=$value['DataID'];
			$no_order=$value['no_order'];
			$score=$value['score'];
			$data_response['objective_list'].=' <option value="'.$no_order_ext.$no_order.'">ข้อที่ '.$no_order.'</option>';
			$data_response['ob_title_table_col'].='<td>'.$no_order.'</td>';		
			$data_response['ob_score_max_table_col'].='<td>'.$score.'</td>';	

			if ($find_end==$chk_loop) {
				$data_objective.=$DataID; 
			}else{
				$data_objective.=$DataID.'-'; 
			}
			
			$chk_loop++;
			$no_order_ext++;
		}
		$data_response['ob_score_max_table_col'].='<td style="background-color:#f3e7f9;">'.$this->get_proportion_cumulative($coures_id_list_val,$set_status).'</td>';
		$registed_courseID=$this->get_registed_courseID($coures_id_list_val);
		$data_response['registed_courseID']=$registed_courseID;
		$data_response['detail_std']=$this->get_detail_std($coures_id_list_val,$registed_courseID,$data_objective,$start_data,$room_search,$set_status);	
		$data_response['std_id_all']=$this->get_std_id_all($coures_id_list_val,$room_search);
		$data_response['data_objectiveID_of_title']=$data_objective;
		return json_encode($data_response);
	}

	public function get_registed_courseID($coures_id_list_val,$term_set,$year_set){
		if ($term_set=='' && $year_set=='') {
			$this->sql ="SELECT  *
					FROM tbl_set_term_year 			
							";
			$this->select();
			$this->setRows();
			$term_set=$this->rows[0]['term'];
			$year_set=$this->rows[0]['year'];	
		}
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 	
					WHERE DataID=$coures_id_list_val					
					";
		$this->select();
		$this->setRows();
		$class_level=$this->rows[0]['class_level'];
		if ($class_level=='p1' || $class_level=='p2' || $class_level=='p3' || $class_level=='p4' || $class_level=='p5' || $class_level=='p6') {
			$term_set='1,2';
		}
		$this->sql ="SELECT  *
					FROM tbl_registed_course 	
					WHERE courseID=$coures_id_list_val
					AND term='$term_set'	
					AND year='$year_set'				
					";
		$this->select();
		$this->setRows();
		return $this->rows[0]['DataID'];
	}
	public function get_config($legth_score,$coures_id_list_val,$room_search,$term_data,$year_data){
		$data_response = array();	
		if ($legth_score=="save-score-pick-before") {
			$data_response=$this->get_pick($coures_id_list_val,'before');
		}elseif($legth_score=="save-score-pick-after"){
			$data_response=$this->get_pick($coures_id_list_val,'after');
		}elseif($legth_score=="save-score-exam"){
			$data_response=$this->get_exam($coures_id_list_val,$room_search,$term_data,$year_data);
		}elseif($legth_score=="save-score-desirable"){
			$data_response=$this->get_desirable($coures_id_list_val,$room_search,$term_data,$year_data);
		}elseif($legth_score=="save-score-read"){
			$data_response=$this->get_read($coures_id_list_val,$room_search,$term_data,$year_data);
		}
		return json_encode($data_response);
	}

	public function get_selected($num_loop_class){
		if (isset($_SESSION['status_active'])) {
			$active_length=$_SESSION['status_active'];
			$text='chk_active_'.$num_loop_class;
			if($active_length==$text){
				return "selected";
			}
		}
		
	}
	public function search_course_detail($coures_id_list,$room_search){
		$data_response = array();	
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 	
					WHERE DataID=$coures_id_list
					";
		$this->select();
		$this->setRows();		
		$data_response['courseID']=$this->rows[0]['courseID'];	
		$data_response['name']=$this->rows[0]['name'];	
		
		$data_response['hr_learn']=$this->rows[0]['hr_learn'];	
		$data_response['status']=$this->rows[0]['status'];	
		$class_level_data=$this->rows[0]['class_level'];
		$class_level=$this->get_class_level_new($class_level_data);
		$data_response['class_level']=$class_level_data;
		
		$status=$this->rows[0]['status'];
		$status_form=$this->rows[0]['status_form'];
		if ($status==1) {
			$data_response['unit']=$this->rows[0]['unit'];	
			$data_response['class_level_co']=$class_level.'/'.$room_search;
		}elseif($status==2){
			if ($status_form==25 || $status_form==26 || $status_form==27) {
				$data_response['class_level_co']=$class_level.'/'.$room_search;
			}else{
				$data_response['class_level_co']=$class_level;
			}
			$data_response['unit']='-';	
		}
		return json_encode($data_response);
	}
	public function get_class_level($coures_id_list_val){
		$this->sql ="SELECT  *
					FROM tbl_set_term_year 			
							";
		$this->select();
		$this->setRows();
		$term_set=$this->rows[0]['term'];
		$year_set=$this->rows[0]['year'];
		$data_response = array();	
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 	
					WHERE DataID=$coures_id_list_val
					
					";
		$this->select();
		$this->setRows();
		$class_level_data=$this->rows[0]['class_level'];	
		$status=$this->rows[0]['status'];
		$status_form=$this->rows[0]['status_form'];
		$data_response['status']=$status;
		$data_response['status_form']=$status_form;
		$data_response['class_level']=$this->get_class_level_new($class_level_data);
		if ($class_level_data=='p1' || $class_level_data=='p2' || $class_level_data=='p3' || $class_level_data=='p4' || $class_level_data=='p5' || $class_level_data=='p6') {
			$term_set='1,2';
		}
		$user_status=$_SESSION['ss_status'];
		$user_id=$_SESSION['ss_user_id'];
		if ($user_status==1) {
			$this->sql ="SELECT room
					FROM tbl_room_teacher 
					WHERE course_teacherID in(
						SELECT DataID
						FROM tbl_course_teacher
						WHERE teacher_id=$user_id
						AND regis_course_id in(
							SELECT DataID
							FROM tbl_registed_course
							WHERE courseID=$coures_id_list_val
                            AND term='$term_set'
                            AND year='$year_set'
						)
						
					)	
					ORDER BY room ASC
						";
		}else{
			$this->sql ="
						SELECT distinct room
						FROM tbl_std_class_room
						WHERE std_ID in(
							SELECT std_ID
							FROM tbl_student 
							WHERE std_ID in(
								SELECT stdID
								FROM tbl_course_teaching_std
								WHERE registed_courseID in(
									SELECT DataID
									FROM tbl_registed_course
									WHERE courseID=$coures_id_list_val
	                                AND term='$term_set'
	                                AND year='$year_set'
									)
							)
						)
						ORDER BY room ASC
							";
		}
			$this->select();
			$this->setRows();
			foreach($this->rows as $key => $value) {
				$room=$value['room'];
				$chk_room_export=$this->get_chk_room_export($room,$term_set,$year_set,$coures_id_list_val);
				if ($chk_room_export==0) {
					$data_response['room'].=' <option>'.$room.'</option>';
				}
				
			}
		return json_encode($data_response);
	}
	public function get_class_level_admin($coures_id_list_val,$term_set,$year_set){
		$data_response = array();	
		$this->sql ="SELECT class_level,status,status_form
					FROM tbl_add_delete_course 	
					WHERE DataID=$coures_id_list_val
					";
		$this->select();
		$this->setRows();
		$class_level_data=$this->rows[0]['class_level'];	
		$status=$this->rows[0]['status'];
		$status_form=$this->rows[0]['status_form'];
		$data_response['status']=$status;
		$data_response['status_form']=$this->rows[0]['status_form'];
		$data_response['class_level']=$this->get_class_level_new($class_level_data);
		if ($status==2){
			if ($status_form==25 || $status_form==26 || $status_form==27) {
				$sql="SELECT  distinct room
						FROM tbl_room_export 
						WHERE status=1
						AND registed_courseID in(
							SELECT DataID
							FROM tbl_registed_course
							WHERE year='$year_set'
							AND term='$term_set'
							AND courseID=$coures_id_list_val
						)
						ORDER BY room ASC
							";
				$this->sql=$sql;
				$this->select();
				$this->setRows();
				foreach($this->rows as $key => $value) {
					$room=$value['room'];
					$data_response['room'].=' <option>'.$room.'</option>';
				}
			}else{
				$this->sql ="SELECT distinct room
						FROM tbl_std_class_room
						WHERE std_ID in(
							SELECT stdID
							FROM tbl_course_teaching_std
							WHERE registed_courseID in(
								SELECT DataID
								FROM tbl_registed_course
								WHERE courseID=$coures_id_list_val
								AND term='$term_set'
								AND year='$year_set'
							)
						)
							";
				$this->select();
				$this->setRows();
				foreach($this->rows as $key => $value) {
					$room=$value['room'];
					$data_response['room'].=' <option>'.$room.'</option>';
				}
			}
			
		}else{

			$sql="SELECT  distinct room
						FROM tbl_room_export 
						WHERE status=1
						AND registed_courseID in(
							SELECT DataID
							FROM tbl_registed_course
							WHERE year='$year_set'
							AND term='$term_set'
							AND courseID=$coures_id_list_val
						)
						ORDER BY room ASC
							";
			$this->sql=$sql;
			$this->select();
			$this->setRows();
			foreach($this->rows as $key => $value) {
				$room=$value['room'];
				$data_response['room'].=' <option>'.$room.'</option>';
			}
		}
		
		return json_encode($data_response);
	}
	public function get_data_dicision($DataID,$courseID_long,$class_level,$status,$term_set,$year_set){
		if ($class_level=='p1' || $class_level=='p2' || $class_level=='p3' || $class_level=='p4' || $class_level=='p5' || $class_level=='p6') {
			$term_set='1,2';
		}
		/*$this->sql ="SELECT  COUNT(*) as num_row
					FROM tbl_registed_course,tbl_room_export
					WHERE tbl_registed_course.DataID=tbl_room_export.registed_courseID
					AND tbl_registed_course.courseID=$DataID
					AND tbl_registed_course.term='$term_set'
					AND tbl_registed_course.year='$year_set'
					AND tbl_room_export.sended_status=99
							";*/
		$this->sql ="SELECT  COUNT(*) as num_row_not_in
					FROM tbl_registed_course
					WHERE courseID=$DataID
					AND term='$term_set'
					AND year='$year_set'
					AND DataID not in(
						SELECT registed_courseID
						FROM tbl_room_export
					)
				";
		$this->select();
		$this->setRows();
		$num_row_not_in=$this->rows[0]['num_row_not_in'];

		$this->sql ="SELECT  COUNT(*) as num_row_in_99
					FROM tbl_registed_course
					WHERE courseID=$DataID
					AND term='$term_set'
					AND year='$year_set'
					AND DataID in(
						SELECT registed_courseID
						FROM tbl_room_export
						WHERE sended_status=99
					)
				";
		$this->select();
		$this->setRows();
		$num_row_in_99=$this->rows[0]['num_row_in_99'];
		if ($num_row_not_in>0 && $num_row_in_99==0) {//no have both in room export
			$data_response='<option value="'.$DataID.'">'.$courseID_long.'</option>';
		}elseif($num_row_not_in==0){//have in room export
			$this->sql ="SELECT  COUNT(*) as num_row_not_99
					FROM tbl_registed_course
					WHERE courseID=$DataID
					AND term='$term_set'
					AND year='$year_set'
					AND DataID in(
						SELECT registed_courseID
						FROM tbl_room_export
						WHERE sended_status!=99
					)
				";
			$this->select();
			$this->setRows();
			$num_row_not_99=$this->rows[0]['num_row_not_99'];
			if ($num_row_in_99>0 && $num_row_not_99==0) {//have only 99 in room export
				$data_response='<option value="'.$DataID.'">'.$courseID_long.'</option>';
			}elseif($num_row_not_99>0){//have only another in room export
				$this->sql ="
						SELECT distinct room
						FROM tbl_std_class_room
						
						WHERE std_ID in(
							SELECT std_ID
							FROM tbl_student 
							WHERE std_ID in(
								SELECT stdID
								FROM tbl_course_teaching_std
								WHERE registed_courseID in(
									SELECT DataID
									FROM tbl_registed_course
									WHERE courseID=$DataID
	                                AND term='$term_set'
	                                AND year='$year_set'
									)
							)
						)
						ORDER BY room ASC
							";
				$this->select();
				$this->setRows();
				$set_amount=0;
				$room_amount=0;
				foreach($this->rows as $key => $value) {
					$room=$value['room'];
					$chk_room_export=$this->get_chk_room_export($room,$term_set,$year_set,$DataID);
					if ($chk_room_export==1) {
						$set_amount++;
					}
					$room_amount++;
				}
				if ($set_amount<$room_amount) {
					$data_response='<option value="'.$DataID.'">'.$courseID_long.'</option>';
				}
				
			}
		}
		return $data_response;	
	}
	public function get_chk_room_export($room,$term_set,$year_set,$courseID){
		$this->sql ="SELECT COUNT(*) as num_row
					FROM tbl_room_export
					WHERE room=$room
					AND sended_status!=99
					AND registed_courseID IN(
						SELECT DataID
						FROM tbl_registed_course
						WHERE term='$term_set'
						AND year='$year_set'
						AND courseID=$courseID
					)
				";
		$this->select();
		$this->setRows();
		return $this->rows[0]['num_row'];
	}
	public function get_data_dicision_admin($DataID,$courseID_long,$class_level,$status,$term_set,$year_set){
		$this->sql ="SELECT  COUNT(*) AS num_row
					FROM tbl_room_export 
					WHERE status=1
					AND registed_courseID in(
						SELECT DataID
						FROM tbl_registed_course
						WHERE year='$year_set'
						AND term='$term_set'
						AND courseID=$DataID
					)
							";
		$this->select();
		$this->setRows();
		$num_row=$this->rows[0]['num_row'];
			if ($num_row>0) {
				$data_response='<option value="'.$DataID.'">'.$courseID_long.'</option>';
			}
		return $data_response;
			
	}
	public function get_coures_id_list_admin($term_set,$year_set){
		$user_id=$_SESSION['ss_user_id'];
		$data_response = array();	
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 		
                    WHERE DataID in(
                    	SELECT courseID
                        FROM tbl_registed_course
                        WHERE year='$year_set'                                       
                        AND DataID IN(
                        	SELECT registed_courseID
                            FROM tbl_registed_course_teaching
                        )              
                    )
					ORDER BY courseID ASC	
							";
		$this->select();
		$this->setRows();
		foreach($this->rows as $key => $value) {
			$DataID=$value['DataID'];
			$courseID_long=$value['courseID'];
			$status=$value['status'];
			$class_level=$value['class_level'];
			$data_dicision=$this->get_data_dicision_admin($DataID,$courseID_long,$class_level,$status,$term_set,$year_set);

			$data_response['coures_id_list'].=$data_dicision;
		}
		if ($data_response['coures_id_list']=='') {
			$data_response['coures_id_list']='<option value="">ไม่พบรายวิชา</option>';
		}
		return json_encode($data_response);
	}
	public function get_coures_id_list(){
		$user_id=$_SESSION['ss_user_id'];
		$data_response = array();	
		$this->sql ="SELECT  *
					FROM tbl_set_term_year 			
							";
		$this->select();
		$this->setRows();
		$term_set=$this->rows[0]['term'];
		$year_set=$this->rows[0]['year'];
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 		
                    WHERE DataID in(
                    	SELECT courseID
                        FROM tbl_registed_course
                        WHERE year='$year_set'                   
                        AND DataID IN(
                        	SELECT registed_courseID
                            FROM tbl_registed_course_teaching    
                        )
                        AND DataID in(
                            	SELECT regis_course_id
								FROM tbl_course_teacher
								WHERE teacher_id=$user_id
                            )
                    )
					ORDER BY courseID ASC	
							";
		$this->select();
		$this->setRows();
		foreach($this->rows as $key => $value) {
			$DataID=$value['DataID'];
			
			$courseID_long=$value['courseID'];
			$status=$value['status'];
			$class_level=$value['class_level'];
			$data_dicision=$this->get_data_dicision($DataID,$courseID_long,$class_level,$status,$term_set,$year_set);
			$data_response['coures_id_list'].=$data_dicision;
		}
		echo json_encode($data_response);
	}
	public function get_course_teachingID($DataID,$term_set,$year_set){
		$this->sql ="SELECT  *
					FROM tbl_registed_course_teaching 			
					WHERE registed_courseID in(
						SELECT DataID
						FROM tbl_registed_course
						WHERE courseID=$DataID
						AND term='$term_set'
						AND year='$year_set'
					)
							";
		$this->select();
		$this->setRows();
		return $this->rows[0]['DataID'];	
	}
	public function get_class_level_new($class_level_data){
		if ($class_level_data=="p1") {
			$class_level="ป.1";
		}elseif($class_level_data=="p2"){
			$class_level="ป.2";	
		}elseif($class_level_data=="p3"){
			$class_level="ป.3";	
		}elseif($class_level_data=="p4"){
			$class_level="ป.4";	
		}elseif($class_level_data=="p5"){
			$class_level="ป.5";	
		}elseif($class_level_data=="p6"){
			$class_level="ป.6";	
		}elseif($class_level_data=="m1"){
			$class_level="ม.1";	
		}elseif($class_level_data=="m2"){
			$class_level="ม.2";	
		}elseif($class_level_data=="m3"){
			$class_level="ม.3";	
		}elseif($class_level_data=="m4"){
			$class_level="ม.4";	
		}elseif($class_level_data=="m5"){
			$class_level="ม.5";	
		}elseif($class_level_data=="m6"){
			$class_level="ม.6";	
		}
		return $class_level;
	}
	public function get_propotion_total($coures_id_list_val){
		$data_response = array();	
		$this->sql ="SELECT  *
					FROM tbl_proportion 			
					WHERE courseID=$coures_id_list_val";
		$this->select();
		$this->setRows();
		$data_response['mid_exam']=$this->rows[0]['mid_exam'];
		$data_response['final_exam']=$this->rows[0]['final_exam'];
		$mid_exam=$this->rows[0]['mid_exam'];
		$final_exam=$this->rows[0]['final_exam'];
		$data_response['total']=$mid_exam+$final_exam;
		return $data_response;
	}
	public function get_std_exam($coures_id_list_val,$course_teachingID,$room_search,$term_set,$year_set){
		$total_total_proportion=$this->get_total_proportion($coures_id_list_val);

		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 	
					WHERE DataID=$coures_id_list_val					
					";
		$this->select();
		$this->setRows();
		
		$class_level=$this->rows[0]['class_level'];
		if ($class_level=='p1' || $class_level=='p2' || $class_level=='p3' || $class_level=='p4' || $class_level=='p5' || $class_level=='p6') {
			$term_set='1,2';
		}
		$this->sql ="SELECT  COUNT(*) as num_row_std
					FROM tbl_student 	
					WHERE std_ID in(
						SELECT std_ID
						FROM tbl_std_class_room
						WHERE room='$room_search'
						AND year='$year_set'
					)	
					AND std_ID in(
						SELECT stdID
					    FROM tbl_course_teaching_std
					    WHERE registed_courseID IN(
					    	SELECT DataID
					        FROM tbl_registed_course
					        WHERE courseID=$coures_id_list_val
					        AND term='$term_set'
					        AND year='$year_set'
					    )
					)

					";
		$this->select();
		$this->setRows();
		$num_row_std=$this->rows[0]['num_row_std'];
		$this->sql ="SELECT  *
					FROM tbl_student 	
					WHERE std_ID in(
						SELECT std_ID
						FROM tbl_std_class_room
						WHERE room='$room_search'
						AND year='$year_set'
					)	
					AND std_ID in(
						SELECT stdID
					    FROM tbl_course_teaching_std
					    WHERE registed_courseID IN(
					    	SELECT DataID
					        FROM tbl_registed_course
					        WHERE courseID=$coures_id_list_val
					        AND term='$term_set'
					        AND year='$year_set'

					    )
					)
					ORDER BY
					CASE
						WHEN name_title LIKE '%dekchai%' THEN 0
				        WHEN name_title LIKE '%nai%' THEN 1
				        WHEN name_title LIKE '%dekying%' THEN 2
				        WHEN name_title LIKE '%nangsaw%'THEN 3
				        WHEN std_ID THEN 4      
				    END
					";
		$this->select();
		$this->setRows();
		$num_set=1;
		foreach($this->rows as $key => $value) {
			$std_ID=$value['std_ID'];
			$name_title_data=$value['name_title'];
			$name_title=$this->get_name_title($name_title_data);
			$score_mid_exam=$this->get_score_mid_exam($std_ID,$course_teachingID);
			$score_final_exam=$this->get_score_final_exam($std_ID,$course_teachingID);
			$score_total=$score_mid_exam['score']+$score_final_exam['score'];
			$fname=$value['fname'];
			$lname=$value['lname'];
			if ($num_row_std==$num_set) {
				$std_id_all_exam.=$std_ID;
			}else{
				$std_id_all_exam.=$std_ID.'-';
			}
			$data_response.='							
						 		<tr>
                                  	<td>'.$num_set.'</td>
                                  	<td>'.$std_ID.'</td>
                                  	<td style="text-align:left;padding-left:10%;">'.$name_title.$fname.' '.$lname.'</td>
                                 	 <td class="relative "><input onkeyup="chk_score_over(this,this.value)" class_name_change="1'.$score_mid_exam['DataID'].'" data_main_chk_over="'.$total_total_proportion['mid_exam'].'" value_set="'.$score_mid_exam['score'].'"   name="score_mid_exam[]" disabled="disabled" class="class_name_1'.$score_mid_exam['DataID'].' select-table-form value_score_mid class_col_set_new_edit class_col_exam_mid text-center" type="text"  value="'.$score_mid_exam['score'].'"></td>
                                 	  <td class="relative"><input onkeyup="chk_score_over(this,this.value)" class_name_change="2'.$score_final_exam['DataID'].'" data_main_chk_over="'.$total_total_proportion['final_exam'].'" value_set="'.$score_final_exam['score'].'"  name="score_final_exam[]" disabled="disabled" class="class_name_2'.$score_final_exam['DataID'].' select-table-form value_score_final class_col_set_new_edit class_col_exam_final text-center" type="text"  value="'.$score_final_exam['score'].'"></td>
                                  	<td>'.$score_total.'</td>                
                                </tr>
			';
			$num_set++;
		}
		$data_response.='<input id="std_id_all_exam" type="text" hidden="hidden" value="'.$std_id_all_exam.'" name="">';
		return $data_response;
	}
	public function get_score_final_exam($std_ID,$course_teachingID){
		$data_response = array();
		$this->sql ="SELECT  *
					FROM tbl_final_exam_score 			
					WHERE course_teachingID=$course_teachingID
					AND stdID='$std_ID'
					";
		$this->select();
		$this->setRows();
		$data_response['DataID']=$this->rows[0]['DataID'];
		$score=$this->rows[0]['score'];
		if ($score=='' || $score==0) {
				$data_response['score']=0;
			}else{
				if ($score==-1) {
					$data_response['score']='ร';
				}else{
					$data_response['score']=$score;
				}				
			}
		return $data_response;
	}
	public function get_score_mid_exam($std_ID,$course_teachingID){
		$data_response = array();
		$this->sql ="SELECT  *
					FROM tbl_mid_exam_score 			
					WHERE course_teachingID=$course_teachingID
					AND stdID='$std_ID'
					";
		$this->select();
		$this->setRows();
		$data_response['DataID']=$this->rows[0]['DataID'];
		$score=$this->rows[0]['score'];
		if ($score=='' || $score==0) {
				$data_response['score']=0;
			}else{
				if ($score==-1) {
					$data_response['score']='ร';
				}else{
					$data_response['score']=$score;
				}				
			}
		return $data_response;
	}
	public function get_name_title($name_title_data){
		if ($name_title_data=="dekchai") {
			$name_title="เด็กชาย";
		}elseif($name_title_data=="dekying"){
			$name_title="เด็กหญิง";
		}elseif($name_title_data=="nai"){
			$name_title="นาย";
		}elseif($name_title_data=="nangsaw"){
			$name_title="นางสาว";
		}
		return $name_title;
	}
	public function get_score_desirable_1($std_ID,$course_teachingID){
		$data_response = array();
		$this->sql ="SELECT  *
					FROM tbl_desirable_1 			
					WHERE course_teachingID=$course_teachingID
					AND stdID='$std_ID'
					";
		$this->select();
		$this->setRows();
		$data_response['DataID']=$this->rows[0]['DataID'];
		$score=$this->rows[0]['score'];
		if ($score=='') {
			$data_response['score']=0;
		}else{
			$data_response['score']=$score;
		}
		return $data_response;
	}
	public function get_score_desirable_2($std_ID,$course_teachingID){
		$data_response = array();
		$this->sql ="SELECT  *
					FROM tbl_desirable_2 			
					WHERE course_teachingID=$course_teachingID
					AND stdID='$std_ID'
					";
		$this->select();
		$this->setRows();
		$data_response['DataID']=$this->rows[0]['DataID'];
		$score=$this->rows[0]['score'];
		if ($score=='') {
			$data_response['score']=0;
		}else{
			$data_response['score']=$score;
		}
		return $data_response;
	}
	public function get_score_desirable_3($std_ID,$course_teachingID){
		$data_response = array();
		$this->sql ="SELECT  *
					FROM tbl_desirable_3 			
					WHERE course_teachingID=$course_teachingID
					AND stdID='$std_ID'
					";
		$this->select();
		$this->setRows();
		$data_response['DataID']=$this->rows[0]['DataID'];
		$score=$this->rows[0]['score'];
		if ($score=='') {
			$data_response['score']=0;
		}else{
			$data_response['score']=$score;
		}
		return $data_response;
	}
	public function get_score_desirable_4($std_ID,$course_teachingID){
		$data_response = array();
		$this->sql ="SELECT  *
					FROM tbl_desirable_4 			
					WHERE course_teachingID=$course_teachingID
					AND stdID='$std_ID'
					";
		$this->select();
		$this->setRows();
		$data_response['DataID']=$this->rows[0]['DataID'];
		$score=$this->rows[0]['score'];
		if ($score=='') {
			$data_response['score']=0;
		}else{
			$data_response['score']=$score;
		}
		return $data_response;
	}
	public function get_score_desirable_5($std_ID,$course_teachingID){
		$data_response = array();
		$this->sql ="SELECT  *
					FROM tbl_desirable_5 			
					WHERE course_teachingID=$course_teachingID
					AND stdID='$std_ID'
					";
		$this->select();
		$this->setRows();
		$data_response['DataID']=$this->rows[0]['DataID'];
		$score=$this->rows[0]['score'];
		if ($score=='') {
			$data_response['score']=0;
		}else{
			$data_response['score']=$score;
		}
		return $data_response;
	}
	public function get_score_desirable_6($std_ID,$course_teachingID){
		$data_response = array();
		$this->sql ="SELECT  *
					FROM tbl_desirable_6 			
					WHERE course_teachingID=$course_teachingID
					AND stdID='$std_ID'
					";
		$this->select();
		$this->setRows();
		$data_response['DataID']=$this->rows[0]['DataID'];
		$score=$this->rows[0]['score'];
		if ($score=='') {
			$data_response['score']=0;
		}else{
			$data_response['score']=$score;
		}
		return $data_response;
	}
	public function get_score_desirable_7($std_ID,$course_teachingID){
		$data_response = array();
		$this->sql ="SELECT  *
					FROM tbl_desirable_7 			
					WHERE course_teachingID=$course_teachingID
					AND stdID='$std_ID'
					";
		$this->select();
		$this->setRows();
		$data_response['DataID']=$this->rows[0]['DataID'];
		$score=$this->rows[0]['score'];
		if ($score=='') {
			$data_response['score']=0;
		}else{
			$data_response['score']=$score;
		}
		return $data_response;
	}
	public function get_score_desirable_8($std_ID,$course_teachingID){
		$data_response = array();
		$this->sql ="SELECT  *
					FROM tbl_desirable_8 			
					WHERE course_teachingID=$course_teachingID
					AND stdID='$std_ID'
					";
		$this->select();
		$this->setRows();
		$data_response['DataID']=$this->rows[0]['DataID'];
		$score=$this->rows[0]['score'];
		if ($score=='') {
			$data_response['score']=0;
		}else{
			$data_response['score']=$score;
		}
		return $data_response;
	}
	
	public function get_room_std($std_ID,$year_set){
		$data_response = array();
		$this->sql ="SELECT  room
					FROM tbl_std_class_room 			
					WHERE std_ID='$std_ID'
					AND year=$year_set
					";
		$this->select();
		$this->setRows();
		$room=$this->rows[0]['room'];
		
		return $room;
	}
	public function get_std_desirable($coures_id_list_val,$course_teachingID,$room_search,$status,$status_form,$class_level,$term_set,$year_set){
		
		if ($class_level=='p1' || $class_level=='p2' || $class_level=='p3' || $class_level=='p4' || $class_level=='p5' || $class_level=='p6') {
			$term_set='1,2';
		}
		if ($status==1) {
			$sql_condition="
						WHERE room='$room_search'
						AND
			";
			$sql_condition_join="
						AND tbl_std_class_room.room='$room_search'
						AND tbl_std_class_room.status=1 
			";
		}else{
			if ($status_form==25 || $status_form==26 || $status_form==27) {
				$sql_condition="
						WHERE room='$room_search'
						AND
			";
			$sql_condition_join="
						AND tbl_std_class_room.room='$room_search'
						AND tbl_std_class_room.status=1 
			";
			}else{
				$sql_condition="
						WHERE 
			";
			$sql_condition_join="AND tbl_std_class_room.status=1 ";
			}
		}
		$this->sql ="SELECT  COUNT(*) as num_row_std
					FROM tbl_student 	
					WHERE std_ID in(
						SELECT std_ID
						FROM tbl_std_class_room
						$sql_condition
						 year='$year_set'
					)	
					AND std_ID in(
						SELECT stdID
					    FROM tbl_course_teaching_std
					    WHERE registed_courseID IN(
					    	SELECT DataID
					        FROM tbl_registed_course
					        WHERE courseID=$coures_id_list_val
					        AND term='$term_set'
					        AND year='$year_set'
					    )
					)

					";
		$this->select();
		$this->setRows();
		$num_row_std=$this->rows[0]['num_row_std'];
		$this->sql ="SELECT  *
					FROM tbl_student,tbl_course_teaching_std,tbl_std_class_room,tbl_registed_course
					WHERE tbl_student.std_ID=tbl_course_teaching_std.stdID
					AND tbl_course_teaching_std.stdID=tbl_std_class_room.std_ID
					AND tbl_course_teaching_std.registed_courseID=tbl_registed_course.DataID
					AND tbl_registed_course.courseID=$coures_id_list_val
					AND tbl_registed_course.term='$term_set'
					AND tbl_registed_course.year='$year_set'
					AND tbl_std_class_room.year='$year_set'
					$sql_condition_join
					ORDER BY tbl_std_class_room.room,
					CASE
						WHEN name_title LIKE '%dekchai%' THEN 0
				        WHEN name_title LIKE '%nai%' THEN 1
				        WHEN name_title LIKE '%dekying%' THEN 2
				        WHEN name_title LIKE '%nangsaw%'THEN 3
				        WHEN tbl_student.std_ID THEN 4      
				    END
					";
		$this->select();
		$this->setRows();
		$num_set=1;
		foreach($this->rows as $key => $value) {
			$std_ID=$value['std_ID'];
			$name_title_data=$value['name_title'];
			$name_title=$this->get_name_title($name_title_data);
			$score_desirable_1=$this->get_score_desirable_1($std_ID,$course_teachingID);
			$score_desirable_2=$this->get_score_desirable_2($std_ID,$course_teachingID);
			$score_desirable_3=$this->get_score_desirable_3($std_ID,$course_teachingID);
			$score_desirable_4=$this->get_score_desirable_4($std_ID,$course_teachingID);
			$score_desirable_5=$this->get_score_desirable_5($std_ID,$course_teachingID);
			$score_desirable_6=$this->get_score_desirable_6($std_ID,$course_teachingID);
			$score_desirable_7=$this->get_score_desirable_7($std_ID,$course_teachingID);
			$score_desirable_8=$this->get_score_desirable_8($std_ID,$course_teachingID);
			$score_total=round(($score_desirable_1['score']+$score_desirable_2['score']+$score_desirable_3['score']+$score_desirable_4['score']+$score_desirable_5['score']+$score_desirable_6['score']+$score_desirable_7['score']+$score_desirable_8['score'])/8,2);
			$fname=$value['fname'];
			$lname=$value['lname'];
			if ($num_row_std==$num_set) {
				$std_id_all_desirable.=$std_ID;
			}else{
				$std_id_all_desirable.=$std_ID.'-';
			}
			if ($status_form!=25 && $status_form!=26 && $status_form!=27) {
				$room_std=$this->get_room_std($std_ID,$year_set);
				$room_row='<td>'.$room_std.'</td>';
			}
			$data_response.='							
						 		<tr>
                                  	<td>'.$num_set.'</td>
                                  	<td>'.$std_ID.'</td>
                                  	'.$room_row.'
                                  	<td style="text-align:left;padding-left:4%;">'.$name_title.$fname.' '.$lname.'</td>
                                 	<td class="relative "><input name="score_final_desirable_1[]" value_set="'.$score_desirable_1['score'].'" onkeyup="chk_score_over_fix(this,this.value)" class_name_change="1'.$score_desirable_1['DataID'].'"   disabled="disabled" class="class_name_1'.$score_desirable_1['DataID'].' select-table-form value_score_desirable_1 class_col_set_new_edit class_col_desirable_1 text-center" type="text"  value="'.$score_desirable_1['score'].'"></td>

                                 	<td class="relative"><input name="score_final_desirable_2[]" value_set="'.$score_desirable_2['score'].'" onkeyup="chk_score_over_fix(this,this.value)" class_name_change="2'.$score_desirable_1['DataID'].'" disabled="disabled" class="class_name_2'.$score_desirable_2['DataID'].' select-table-form value_score_desirable_2 class_col_set_new_edit class_col_desirable_2 text-center" type="text"  value="'.$score_desirable_2['score'].'"></td>
                                 	<td class="relative"><input name="score_final_desirable_3[]" value_set="'.$score_desirable_3['score'].'" onkeyup="chk_score_over_fix(this,this.value)" class_name_change="3'.$score_desirable_1['DataID'].'" disabled="disabled" class="class_name_3'.$score_desirable_3['DataID'].' select-table-form value_score_desirable_3 class_col_set_new_edit class_col_desirable_3 text-center" type="text"  value="'.$score_desirable_3['score'].'"></td>
                                 	<td class="relative"><input name="score_final_desirable_4[]" value_set="'.$score_desirable_4['score'].'" onkeyup="chk_score_over_fix(this,this.value)" class_name_change="4'.$score_desirable_1['DataID'].'" disabled="disabled" class="class_name_4'.$score_desirable_4['DataID'].' select-table-form value_score_desirable_4 class_col_set_new_edit class_col_desirable_4 text-center" type="text"  value="'.$score_desirable_4['score'].'"></td>
                                 	<td class="relative"><input name="score_final_desirable_5[]" value_set="'.$score_desirable_5['score'].'" onkeyup="chk_score_over_fix(this,this.value)" class_name_change="5'.$score_desirable_1['DataID'].'" disabled="disabled" class="class_name_5'.$score_desirable_1['DataID'].' select-table-form value_score_desirable_5 class_col_set_new_edit class_col_desirable_5 text-center" type="text"  value="'.$score_desirable_5['score'].'"></td>
                                 	<td class="relative"><input name="score_final_desirable_6[]" value_set="'.$score_desirable_6['score'].'" onkeyup="chk_score_over_fix(this,this.value)" class_name_change="6'.$score_desirable_1['DataID'].'" disabled="disabled" class="class_name_6'.$score_desirable_6['DataID'].' select-table-form value_score_desirable_6 class_col_set_new_edit class_col_desirable_6 text-center" type="text"  value="'.$score_desirable_6['score'].'"></td>
                                 	<td class="relative"><input name="score_final_desirable_7[]" value_set="'.$score_desirable_7['score'].'" onkeyup="chk_score_over_fix(this,this.value)" class_name_change="7'.$score_desirable_1['DataID'].'" disabled="disabled" class="class_name_7'.$score_desirable_7['DataID'].' select-table-form value_score_desirable_7 class_col_set_new_edit class_col_desirable_7 text-center" type="text"  value="'.$score_desirable_7['score'].'"></td>
                                 	<td class="relative"><input name="score_final_desirable_8[]" value_set="'.$score_desirable_8['score'].'" onkeyup="chk_score_over_fix(this,this.value)" class_name_change="8'.$score_desirable_1['DataID'].'" disabled="disabled" class="class_name_8'.$score_desirable_8['DataID'].' select-table-form value_score_desirable_8 class_col_set_new_edit class_col_desirable_8 text-center" type="text"  value="'.$score_desirable_8['score'].'"></td>
                           
                                  	<td>'.$score_total.'</td>            
                                </tr>
			';
			$num_set++;
		}
		$data_response.='<input id="std_id_all_desirable" type="text" hidden="hidden" value="'.$std_id_all_desirable.'" name="">';
		return $data_response;
	}
	public function get_score_read($std_ID,$course_teachingID){
		$data_response = array();
		$this->sql ="SELECT  *
					FROM tbl_read_score 			
					WHERE course_teachingID=$course_teachingID
					AND stdID='$std_ID'
					";
		$this->select();
		$this->setRows();
		$data_response['DataID']=$this->rows[0]['DataID'];
		$score=$this->rows[0]['score'];
		if ($score=='') {
			$data_response['score']=0;
		}else{
			$data_response['score']=$score;
		}
		return $data_response;
	}
	public function get_score_write($std_ID,$course_teachingID){
		$data_response = array();
		$this->sql ="SELECT  *
					FROM tbl_write_score 			
					WHERE course_teachingID=$course_teachingID
					AND stdID='$std_ID'
					";
		$this->select();
		$this->setRows();
		$data_response['DataID']=$this->rows[0]['DataID'];
		$score=$this->rows[0]['score'];
		if ($score=='') {
			$data_response['score']=0;
		}else{
			$data_response['score']=$score;
		}
		return $data_response;
	}
	public function get_score_think($std_ID,$course_teachingID){
		$data_response = array();
		$this->sql ="SELECT  *
					FROM tbl_think_score 			
					WHERE course_teachingID=$course_teachingID
					AND stdID='$std_ID'
					";
		$this->select();
		$this->setRows();
		$data_response['DataID']=$this->rows[0]['DataID'];
		$score=$this->rows[0]['score'];
		if ($score=='') {
			$data_response['score']=0;
		}else{
			$data_response['score']=$score;
		}
		return $data_response;
	}
	public function get_score_rtw_4($std_ID,$course_teachingID){
		$data_response = array();
		$this->sql ="SELECT  *
					FROM tbl_rtw_4_score 			
					WHERE course_teachingID=$course_teachingID
					AND stdID='$std_ID'
					";
		$this->select();
		$this->setRows();
		$data_response['DataID']=$this->rows[0]['DataID'];
		$score=$this->rows[0]['score'];
		if ($score=='') {
			$data_response['score']=0;
		}else{
			$data_response['score']=$score;
		}
		return $data_response;
	}
	public function get_score_rtw_5($std_ID,$course_teachingID){
		$data_response = array();
		$this->sql ="SELECT  *
					FROM tbl_rtw_5_score 			
					WHERE course_teachingID=$course_teachingID
					AND stdID='$std_ID'
					";
		$this->select();
		$this->setRows();
		$data_response['DataID']=$this->rows[0]['DataID'];
		$score=$this->rows[0]['score'];
		if ($score=='') {
			$data_response['score']=0;
		}else{
			$data_response['score']=$score;
		}
		return $data_response;
	}
	public function get_std_read($coures_id_list_val,$course_teachingID,$room_search,$status,$status_form,$class_level,$term_set,$year_set){

		if ($class_level=='p1' || $class_level=='p2' || $class_level=='p3' || $class_level=='p4' || $class_level=='p5' || $class_level=='p6') {
			$term_set='1,2';
		}
		if ($status==1) {
			$sql_condition="
						WHERE room='$room_search'
						AND
			";
		}else{
			if ($status_form==25 || $status_form==26 || $status_form==27) {
				$sql_condition="
						WHERE room='$room_search'
						AND
						
			";
			}else{
				$sql_condition="
						WHERE
			";
			}
		}
		$this->sql ="SELECT  COUNT(*) as num_row_std
					FROM tbl_student 	
					WHERE std_ID in(
						SELECT std_ID
						FROM tbl_std_class_room
						$sql_condition
						 year='$year_set'
					)	
					AND std_ID in(
						SELECT stdID
					    FROM tbl_course_teaching_std
					    WHERE registed_courseID IN(
					    	SELECT DataID
					        FROM tbl_registed_course
					        WHERE courseID=$coures_id_list_val
					        AND term='$term_set'
					        AND year='$year_set'
					    )
					)

					";
		$this->select();
		$this->setRows();
		$num_row_std=$this->rows[0]['num_row_std'];
		$this->sql ="SELECT  *
					FROM tbl_student 	
					WHERE std_ID in(
						SELECT std_ID
						FROM tbl_std_class_room
						$sql_condition
						 year='$year_set'
					)	
					AND std_ID in(
						SELECT stdID
					    FROM tbl_course_teaching_std
					    WHERE registed_courseID IN(
					    	SELECT DataID
					        FROM tbl_registed_course
					        WHERE courseID=$coures_id_list_val
					        AND term='$term_set'
					        AND year='$year_set'

					    )
					)
					ORDER BY 
					CASE
						WHEN name_title LIKE '%dekchai%' THEN 0
				        WHEN name_title LIKE '%nai%' THEN 1
				        WHEN name_title LIKE '%dekying%' THEN 2
				        WHEN name_title LIKE '%nangsaw%'THEN 3
				        WHEN std_ID THEN 4      
				    END
					";
		$this->select();
		$this->setRows();
		$num_set=1;
		foreach($this->rows as $key => $value) {
			$std_ID=$value['std_ID'];
			$name_title_data=$value['name_title'];
			$name_title=$this->get_name_title($name_title_data);
			$get_score_read=$this->get_score_read($std_ID,$course_teachingID);
			$get_score_write=$this->get_score_write($std_ID,$course_teachingID);
			$get_score_think=$this->get_score_think($std_ID,$course_teachingID);
			$get_score_rtw_4=$this->get_score_rtw_4($std_ID,$course_teachingID);
			$get_score_rtw_5=$this->get_score_rtw_5($std_ID,$course_teachingID);
			$score_total=round(($get_score_read['score']+$get_score_write['score']+$get_score_think['score']+$get_score_rtw_4['score']+$get_score_rtw_5['score'])/5,2);
			$fname=$value['fname'];
			$lname=$value['lname'];
			if ($num_row_std==$num_set) {
				$std_id_all_read.=$std_ID;
			}else{
				$std_id_all_read.=$std_ID.'-';
			}
			$data_response.='							
						 		<tr>
                                  	<td>'.$num_set.'</td>
                                  	<td>'.$std_ID.'</td>
                                  	<td style="text-align:left;padding-left:10%;">'.$name_title.$fname.' '.$lname.'</td>
                                 	<td class="relative "><input onkeyup="chk_score_over_fix(this,this.value)" value_set="'.$get_score_read['score'].'" class_name_change="1'.$get_score_read['DataID'].'" name="score_read[]" disabled="disabled" class="class_name_1'.$get_score_read['DataID'].' select-table-form value_score_read class_col_set_new_edit class_col_read text-center" type="text"  value="'.$get_score_read['score'].'"></td>

                                 	<td class="relative"><input onkeyup="chk_score_over_fix(this,this.value)" value_set="'.$get_score_write['score'].'" class_name_change="2'.$get_score_write['DataID'].'" name="score_write[]" disabled="disabled" class="class_name_2'.$get_score_write['DataID'].' select-table-form value_score_write class_col_set_new_edit class_col_write text-center" type="text"  value="'.$get_score_write['score'].'"></td>
                                 	<td class="relative"><input onkeyup="chk_score_over_fix(this,this.value)" value_set="'.$get_score_think['score'].'" class_name_change="3'.$get_score_think['DataID'].'" name="score_think[]" disabled="disabled" class="class_name_3'.$get_score_think['DataID'].' select-table-form value_score_think class_col_set_new_edit class_col_think text-center" type="text"  value="'.$get_score_think['score'].'"></td>
                                 	<td class="relative"><input onkeyup="chk_score_over_fix(this,this.value)" value_set="'.$get_score_rtw_4['score'].'" class_name_change="4'.$get_score_rtw_4['DataID'].'" name="score_rtw_4[]" disabled="disabled" class="class_name_4'.$get_score_rtw_4['DataID'].' select-table-form value_score_rtw_4 class_col_set_new_edit class_col_rtw_4 text-center" type="text"  value="'.$get_score_rtw_4['score'].'"></td>
                                 	<td class="relative"><input onkeyup="chk_score_over_fix(this,this.value)" value_set="'.$get_score_rtw_5['score'].'" class_name_change="5'.$get_score_rtw_5['DataID'].'" name="score_rtw_5[]" disabled="disabled" class="class_name_5'.$get_score_rtw_5['DataID'].' select-table-form value_score_rtw_5 class_col_set_new_edit class_col_rtw_5 text-center" type="text"  value="'.$get_score_rtw_5['score'].'"></td>

                                                        
                                  	<td>'.$score_total.'</td>            
                                </tr>
			';
			$num_set++;
		}
		$data_response.='<input id="std_id_all_read" type="text" hidden="hidden" value="'.$std_id_all_read.'" name="">';
		return $data_response;
	}
	public function get_read($coures_id_list_val,$room_search,$term_set,$year_set){
		$data_response = array();
		if ($term_set=='' && $year_set=='') {
			$this->sql ="SELECT  *
					FROM tbl_set_term_year 			
							";
			$this->select();
			$this->setRows();
			$term_set=$this->rows[0]['term'];
			$year_set=$this->rows[0]['year'];
		}
		
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 	
					WHERE DataID=$coures_id_list_val					
					";
		$this->select();
		$this->setRows();
		$class_level=$this->rows[0]['class_level'];
		$status=$this->rows[0]['status'];
		$status_form=$this->rows[0]['status_form'];
		if ($class_level=='p1' || $class_level=='p2' || $class_level=='p3' || $class_level=='p4' || $class_level=='p5' || $class_level=='p6') {
			$term_set='1,2';
		}
		if ($class_level=='p1' || $class_level=='p2' || $class_level=='p3') {
			$text_rtw_desc='
							<tr>
			                    <td width="110px" style="vertical-align: top;">ตัวชี้วัดที่ 1</td>		
			                    <td>สามารถอ่านและหาประสบการณ์จากสื่อที่หลากหลาย</td>			
			                 </tr>
			                 <tr>
			                    <td width="110px" style="vertical-align: top;">ตัวชี้วัดที่ 2</td>		
			                    <td>สามารถจับประเด็นสำคัญ ข้อเท็จจริง ความคิดเห็นเรื่องที่อ่าน</td>			
			                 </tr>
			                 <tr>
			                    <td width="110px" style="vertical-align: top;">ตัวชี้วัดที่ 3</td>		
			                    <td>สามารถเปรียบเทียบแง่มุมต่างๆ เช่น ข้อดี ข้อเสีย ประโยชน์ โทษ ความเหมาะสม ไม่เหมาะสม</td>			
			                 </tr>
			                 <tr>
			                    <td width="110px" style="vertical-align: top;">ตัวชี้วัดที่ 4</td>		
			                    <td>สามารถแสดงความคิดเห็นต่อเรื่องที่อ่าน โดยมีเหตุผลประกอบ</td>			
			                 </tr>
			                 <tr>
			                    <td width="110px" style="vertical-align: top;">ตัวชี้วัดที่ 5</td>		
			                    <td>สามารถถ่ายทอดความคิดเห็นความรู้สึกจากเรื่องที่อ่านโดยการเขียน</td>			
			                 </tr>
			';
		}elseif($class_level=='p4' || $class_level=='p5' || $class_level=='p6') {
			$text_rtw_desc='
							<tr>
			                    <td width="110px" style="vertical-align: top;">ตัวชี้วัดที่ 1</td>		
			                    <td>สามารถอ่านเพื่อหาข้อมูลสารสนเทศเสริมประสบการณ์จากสื่อประเภทต่างๆ</td>			
			                 </tr>
			                 <tr>
			                    <td width="110px" style="vertical-align: top;">ตัวชี้วัดที่ 2</td>		
			                    <td>สามารถจับประเด็นสำคัญ เปรียบเทียบ เชื่อมโยงความเป็นเหตุเป็นผลจากเรื่องที่อ่าน</td>			
			                 </tr>
			                 <tr>
			                    <td width="110px" style="vertical-align: top;">ตัวชี้วัดที่ 3</td>		
			                    <td>สามารถเชื่อมโยงความสัมพันธ์ของเรื่องราว เหตุการณ์ของเรื่องที่อ่าน</td>			
			                 </tr>
			                 <tr>
			                    <td width="110px" style="vertical-align: top;">ตัวชี้วัดที่ 4</td>		
			                    <td>สามารถแสดงความคิดเห็นต่อเรื่องที่อ่านโดยมีเหตุผลสนับสนุน</td>			
			                 </tr>
			                 <tr>
			                    <td width="110px" style="vertical-align: top;">ตัวชี้วัดที่ 5</td>		
			                    <td>สามารถถ่ายทอดความเข้าใจ ความคิดเห็น คุณค่าจากเรื่องที่อ่านโดยการเขียน</td>			
			                 </tr>
			';
		}elseif($class_level=='m1' || $class_level=='m2' || $class_level=='m3') {
			$text_rtw_desc='
							<tr>
			                    <td width="110px" style="vertical-align: top;">ตัวชี้วัดที่ 1</td>		
			                    <td >สามารถคัดสรรสื่อที่ต้องการอ่านเพื่อหาข้อมูลสารสนเทศได้ตามวัตถุประสงค์ สามารถสร้างความเข้าใจและประยุกต์ใช้ความรู้จากการอ่าน</td>			
			                 </tr>
			                 <tr>
			                    <td width="110px" style="vertical-align: top;">ตัวชี้วัดที่ 2</td>		
			                    <td>สามารถจับประเด็นสำคัญและประเด็นสนับสนุน โต้แย้ง</td>			
			                 </tr>
			                 <tr>
			                    <td width="110px" style="vertical-align: top;">ตัวชี้วัดที่ 3</td>		
			                    <td>สามารถวิเคราะห์ วิจารณ์ ความสมเหตุสมผล ความน่าเชื่อถือ ลำดับความและความเป็นไปได้ของเรื่องที่อ่าน</td>			
			                 </tr>
			                 <tr>
			                    <td width="110px" style="vertical-align: top;">ตัวชี้วัดที่ 4</td>		
			                    <td>สามารถสรุปคุณค่า แนวคิด แง่คิดที่ได้จากการอ่าน</td>			
			                 </tr>
			                 <tr>
			                    <td width="110px" style="vertical-align: top;">ตัวชี้วัดที่ 5</td>		
			                    <td>สามารถสรุป อภิปราย ขยายความ แสดงความคิดเห็น โต้แย้ง สนับสนุน โน้มน้าว โดยการเขียนสื่อสารในรูปแบบต่าง ๆ เช่น ผังความคิด เป็นต้น</td>			
			                 </tr>
			';
		}elseif($class_level=='m4' || $class_level=='m5' || $class_level=='m6') {
			$text_rtw_desc='
							<tr>
			                    <td width="110px" style="vertical-align: top;">ตัวชี้วัดที่ 1</td>		
			                    <td>สามารถอ่านเพื่อการศึกษาค้นคว้า เพิ่มพูนความรู้ ประสบการณ์ และการประยุกต์ใช้ในชีวิตประจำวัน</td>			
			                 </tr>
			                 <tr>
			                    <td width="110px" style="vertical-align: top;">ตัวชี้วัดที่ 2</td>		
			                    <td>สามารถจับประเด็นสำคัญลำดับเหตุการณ์จากการอ่านสื่อที่มีความซับซ้อน</td>			
			                 </tr>
			                 <tr>
			                    <td width="110px" style="vertical-align: top;">ตัวชี้วัดที่ 3</td>		
			                    <td>สามารถวิเคราะห์สิ่งที่ผู้เขียนต้องการสื่อสารกับผู้อ่าน และสามารถวิพากษ์ ให้ข้อเสนอแนะในแง่มุมต่าง ๆ</td>			
			                 </tr>
			                 <tr>
			                    <td width="110px" style="vertical-align: top;">ตัวชี้วัดที่ 4</td>		
			                    <td>สามารถประเมินความน่าเชื่อถือ คุณค่า แนวคิดที่ได้จากสิ่งที่อ่านอย่างหลากหลาย</td>			
			                 </tr>
			                 <tr>
			                    <td width="110px" style="vertical-align: top;">ตัวชี้วัดที่ 5</td>		
			                    <td>สามารถเขียนแสดงความคิดเห็นโต้แย้ง สรุป โดยมีข้อมูลอธิบายสนับสนุนอย่างเพียงพอและสมเหตุสมผล</td>			
			                 </tr>
			';
		}

		$course_teachingID=$this->get_course_teachingID($coures_id_list_val,$term_set,$year_set);
		$std_read=$this->get_std_read($coures_id_list_val,$course_teachingID,$room_search,$status,$status_form,$class_level,$term_set,$year_set);
		$data_response='
					<input id="teaching_id_find" type="text" hidden="hidden" name="" value='.$course_teachingID.'>
					 <div  id="hr-co-text-depart_course" class="row">
				      <div class="hr-co-text-depart"></div> 
				    </div>
                     <div class="row pd-50 stage-set" >                  
                        <div class="col-sm-12 col-xs-12 mt-nega-20">                        
                          <div class="set-line">
                                  <p class="text-bold text-inline">คะแนนอ่าน  คิดวิเคราะห์ และเขียน</p>
                                 
                          </div>
                        </div>
                      </div>
                      <div class="ml-36 mr-50 mt-nega-50" >               
                        <div class="col-sm-12 col-xs-12">                        
                          <div class="set-line">                               
                                  <p class="text-inline">คะแนน</p>
                                  <select onchange="open_edit_read()" id="read_select" name="read_select" class="form-control search-drop-sub-id mr-30">
                                    <option value="read">ตัวชี้วัดที่ 1</option>
                                    <option value="write">ตัวชี้วัดที่ 2</option>
                                    <option value="think">ตัวชี้วัดที่ 3</option>
                                    <option value="rtw_4">ตัวชี้วัดที่ 4</option>
                                    <option value="rtw_5">ตัวชี้วัดที่ 5</option>
                                  </select>
                                  <p class=" text-inline" >ระบุคะแนนทั้งหมดเป็น</p>
                                  <div class="input-group form-serch-width-small">
                                    <input id="input_set_data_seem_read" type="text" class="form-control form-set-search"  aria-describedby="basic-addon1">
                                  </div>
                                  <div class="btn-search-save-score">
                                    <div id="btn_set_data_seem_read" class="btn-search">
                                      <span class="glyphicon glyphicon-arrow-right" aria-hidden="true"></span>
                                    </div>  
                                  </div>
                          </div>
                        </div>
                      </div>     
                      <div class=" ml-50 mr-50 mt-30" >
                    
                         <div class="row">
                          <div class="col-md-12">
             
                            <table class="table table-striped-violet border-set-violet" style="text-align: center;">
                              <thead class="header-table">
                                 <tr class="text-middle">
                                    <td  rowspan = "4" width="8%" style="  vertical-align: middle;">เลขที่</td>
                                    <td  rowspan = "4" width="8%" style="  vertical-align: middle;">รหัส</td>
                                    <td rowspan = "4" width="40%" style="  vertical-align: middle;">ชื่อ-สกุล</td>                                  
                                  </tr>
                                  <tr>
                                    <td colspan="10">คะแนนอ่าน คิดวิเคราะห์ และเขียน</td>                                  
                                  </tr>
                                 <tr>
                                    <td width="120px">ตัวชี้วัดที่ 1</td>
                                    <td width="120px">ตัวชี้วัดที่ 2</td>
                                    <td width="120px">ตัวชี้วัดที่ 3</td>  
                                    <td width="120px">ตัวชี้วัดที่ 4</td>
                                    <td width="120px">ตัวชี้วัดที่ 5</td>         
                                    <td width="120px">รวมเฉลี่ย</td>
                                                             
                                 </tr>
                                 <tr class="table-bg-white">
                                    <td>3</td>
                                    <td>3</td>
                                    <td>3</td> 
                                    <td>3</td>
                                    <td>3</td>
                                    <td>3.00</td>
                                    

                                 </tr>
                              </thead>
                              <tbody class="body-table">
                                
                                '.$std_read.'                         
                              </tbody>
                            </table> 
                          
                          </div>                                     
                        </div> 

                        <div class="btn-group-set-add-delete row pd-30 ">                                                     
                             <a href="index.php">                                                
                              <div class="btn-grey">
                                ยกเลิก
                              </div>    
                            </a>   
                              <div data-toggle="modal" data-target="#modalReadScore" class="btn-violet">
                                บันทึก
                              </div>                   
                        </div>  
                    </div>
                    <div class=" ml-50 mr-50 ">
						      <div class="row">
						        <div class="col-md-12">
						        <table>
					                <tbody class="border-none">
					                	'.$text_rtw_desc.'
			
					                </tbody>
					              </table>
						        </div>
						       </div>
						    </div>
		';
		return $data_response;
	}
	public function get_desirable($coures_id_list_val,$room_search,$term_set,$year_set){
		$data_response = array();
		if ($term_set=='' && $year_set=='') {
			$this->sql ="SELECT  *
					FROM tbl_set_term_year 			
							";
			$this->select();
			$this->setRows();
			$term_set=$this->rows[0]['term'];
			$year_set=$this->rows[0]['year'];
		}
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 	
					WHERE DataID=$coures_id_list_val					
					";
		$this->select();
		$this->setRows();
		$class_level=$this->rows[0]['class_level'];
		$status=$this->rows[0]['status'];
		$status_form=$this->rows[0]['status_form'];
		if ($class_level=='p1' || $class_level=='p2' || $class_level=='p3' || $class_level=='p4' || $class_level=='p5' || $class_level=='p6') {
			$term_set='1,2';
		}
		$course_teachingID=$this->get_course_teachingID($coures_id_list_val,$term_set,$year_set);
		$std_desirable=$this->get_std_desirable($coures_id_list_val,$course_teachingID,$room_search,$status,$status_form,$class_level,$term_set,$year_set);
		if ($status_form!=25 && $status_form!=26 && $status_form!=27 ) {
			$text_room_header='<td  rowspan = "4" width="8%" style="  vertical-align: middle;">ห้อง</td>';
		}
		$data_response='
					<input id="teaching_id_find" type="text" hidden="hidden" name="" value='.$course_teachingID.'>
					 <div  id="hr-co-text-depart_course" class="row">
				      <div class="hr-co-text-depart"></div> 
				    </div>
					<div class="row pd-50 stage-set" >                  
                        <div class="col-sm-12 col-xs-12 mt-nega-20">                        
                          <div class="set-line">
                                  <p class="text-bold text-inline">คะแนนคุณลักษณะอันพึงประสงค์</p>
                                 
                          </div>
                        </div>
                      </div>
                      <div class="ml-36 mr-50 mt-nega-50" >               
                        <div class="col-sm-12 col-xs-12">                        
                          <div class="set-line">                               
                                  <p class="text-inline">คะแนน</p>
                                  <select onchange="open_edit_desirable()" id="desirable_select" name="desirable_select" class="form-control search-drop-sub-id mr-30">
                                    <option value="desirable_1">ข้อที่ 1</option>
                                    <option value="desirable_2">ข้อที่ 2</option>
                                    <option value="desirable_3">ข้อที่ 3</option>
                                    <option value="desirable_4">ข้อที่ 4</option>
                                    <option value="desirable_5">ข้อที่ 5</option>
                                    <option value="desirable_6">ข้อที่ 6</option>
                                    <option value="desirable_7">ข้อที่ 7</option>
                                    <option value="desirable_8">ข้อที่ 8</option>
                                  </select>
                                  <p class=" text-inline" >ระบุคะแนนทั้งหมดเป็น</p>
                                  <div class="input-group form-serch-width-small">
                                    <input id="input_set_data_seem_desirable" type="text" class="form-control form-set-search"  aria-describedby="basic-addon1">
                                  </div>
                                  <div class="btn-search-save-score">
                                    <div id="btn_set_data_seem_desirable" class="btn-search">
                                      <span class="glyphicon glyphicon-arrow-right" aria-hidden="true"></span>
                                    </div>  
                                  </div>
                          </div>
                        </div>
                      </div>  
                       <div class=" ml-50 mr-50 mt-30" >
 
                         <div class="row">
                          <div class="col-md-12">
             
                            <table class="table table-striped-violet border-set-violet" style="text-align: center;">
                              <thead class="header-table">
                                 <tr class="text-middle">
                                    <td  rowspan = "4" width="8%" style="  vertical-align: middle;">เลขที่</td>
                                    <td  rowspan = "4" width="8%" style="  vertical-align: middle;">รหัส</td>
                                    '.$text_room_header.'
                                    <td rowspan = "4" width="35%" style="  vertical-align: middle;">ชื่อ-สกุล</td>                                  
                                  </tr>
                                  <tr>
                                    <td colspan="10">คะแนนคุณลักษณะอันพึงประสงค์</td>                                  
                                  </tr>
                                 <tr>
                                    <td>ข้อที่ 1</td>
                                    <td>ข้อที่ 2</td>
                                    <td>ข้อที่ 3</td>     
                                    <td>ข้อที่ 4</td>
                                    <td>ข้อที่ 5</td>
                                    <td>ข้อที่ 6</td>
                                    <td>ข้อที่ 7</td>
                                    <td>ข้อที่ 8</td> 
                                    <td>รวมเฉลี่ย</td>                           
                                 </tr>
                                 <tr class="table-bg-white">
                                    <td>3</td>
                                    <td>3</td>
                                    <td>3</td> 
                                    <td>3</td>
                                    <td>3</td>
                                    <td>3</td>
                                    <td>3</td>
                                    <td>3</td>
                                    <td>3.00</td>  

                                 </tr>
                              </thead>
                              <tbody class="body-table">
                                
                                '.$std_desirable.'
                              </tbody>
                            </table> 
                          
                          </div>                                     
                        </div>   
                        <div class="btn-group-set-add-delete row pd-30 ">     
                        	<a href="index.php">                                                
                              <div class="btn-grey">
                                ยกเลิก
                              </div>    
                            </a>
                              <div data-toggle="modal" data-target="#modalDesirableScore" class="btn-violet">
                                บันทึก
                              </div>                   
                            </div>  
                        </div>
		';
		return $data_response;
	}
	public function get_exam($coures_id_list_val,$room_search,$term_set,$year_set){
		$data_response = array();
		if ($term_set=='' && $year_set=='') {
			$this->sql ="SELECT  *
					FROM tbl_set_term_year 			
							";
			$this->select();
			$this->setRows();
			$term_set=$this->rows[0]['term'];
			$year_set=$this->rows[0]['year'];
		}
		
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 	
					WHERE DataID=$coures_id_list_val					
					";
		$this->select();
		$this->setRows();
		$class_level=$this->rows[0]['class_level'];
		if ($class_level=='p1' || $class_level=='p2' || $class_level=='p3' || $class_level=='p4' || $class_level=='p5' || $class_level=='p6') {
			$term_set='1,2';
		}
		$propotion_total=$this->get_propotion_total($coures_id_list_val);
		$course_teachingID=$this->get_course_teachingID($coures_id_list_val,$term_set,$year_set);
		$std_exam=$this->get_std_exam($coures_id_list_val,$course_teachingID,$room_search,$term_set,$year_set);

		$this->sql ="SELECT *
					FROM tbl_objective_conclude 	
					WHERE courseID=$coures_id_list_val
					AND DataID in(
						SELECT objective_conclude
						FROM tbl_exam_final_object
						WHERE courseID=$coures_id_list_val
					)
					ORDER BY no_order ASC
					";
		$this->select();
		$this->setRows();	
		foreach($this->rows as $key => $value) {
			$no_order=$value['no_order'];
			$detail=$value['detail'];
			$objective_final_conclude_desc.='
									<tr>
					                    <td width="80px">ตัวชี้วัดที่ '.$no_order.'</td>		
					                    <td >'.$detail.'</td>			                    
					                 </tr>
			';
		}
		$this->sql ="SELECT *
					FROM tbl_objective_conclude 	
					WHERE courseID=$coures_id_list_val
					AND DataID in(
						SELECT objective_conclude
						FROM tbl_exam_mid_object
						WHERE courseID=$coures_id_list_val
					)
					ORDER BY no_order ASC
					";
		$this->select();
		$this->setRows();	
		foreach($this->rows as $key => $value) {
			$no_order=$value['no_order'];
			$detail=$value['detail'];
			$objective_mid_conclude_desc.='
									<tr>
					                    <td width="80px">ตัวชี้วัดที่ '.$no_order.'</td>		
					                    <td >'.$detail.'</td>			                    
					                 </tr>
			';
		}
		$data_response='
				 <input id="teaching_id_find" type="text" hidden="hidden" name="" value='.$course_teachingID.'>
					<div  id="hr-co-text-depart_course" class="row">
				      <div class="hr-co-text-depart"></div> 
				    </div>
			    <div id="course_detal_box" class="ml-50 mr-50 mt-10" >
			      <div class="row">
			        <div class="box-search-depart">
				     <table>
                  		<tbody style="border: none;">
                  			<tr >
		                      <td class="text-before-box3 text-bold" style="float: right;padding-left:45px;">
		                        คะแนน
		                      </td> 
		                      <td width="200px">
		                        <form>
		                          	<select onchange="open_edit_exam()" id="exam_score_select" name="exam_score_select" class="form-control search-drop-length-ob mt-5">
		                          		<option value="mid">กลางภาค</option>     
		                          		<option value="final">ปลายภาค</option>                                  
		                        	</select> 
		                        </form>
		                        
		                      </td>
		                     
		                    </tr>
                  		</tbody>
                  	<table>
                  	</div>
                  	</div>
                  	</div>
						<div class=" ml-50 mr-50 mt-30" >
                        
                         <div class="row">
                          <div class="col-md-12">
             
                            <table class="table table-striped-violet border-set-violet" style="text-align: center;">
                              <thead class="header-table">
                                 <tr class="text-middle">
                                    <td  rowspan = "4" width="8%" style="  vertical-align: middle;">เลขที่</td>
                                    <td  rowspan = "4" width="8%" style="  vertical-align: middle;">รหัส</td>
                                    <td rowspan = "4" width="60%" style="  vertical-align: middle;">ชื่อ-สกุล</td>                                  
                                  </tr>
                                  <tr>
                                    <td colspan="10">คะแนนสอบ</td>                                  
                                  </tr>
                                 <tr>
                                    <td>กลางภาค</td>
                                    <td>ปลายภาค</td>
                                    <td>รวม</td>                                 
                                 </tr>
                                 <tr class="table-bg-white">
                                    <td>'.$propotion_total['mid_exam'].'</td>
                                    <td>'.$propotion_total['final_exam'].'</td>
                                    <td>'.$propotion_total['total'].'</td>                                    
                                 </tr>
                              </thead>
                              <tbody class="body-table">
                                '.$std_exam.'
                              </tbody>
                            </table> 
                          
                          </div>                                     
                        </div>   
                        <div class="btn-group-set-add-delete row pd-60 ">                                                     
                              <a href="index.php">                                                
                              <div class="btn-grey">
                                ยกเลิก
                              </div>    
                            </a>   
                              <div data-toggle="modal" data-target="#modalExamScore" class="btn-violet">
                                บันทึก
                              </div>                   
                            </div>  
                        </div>
                        <div class="mr-50 " style="margin-left:80px;">
                        	<p class="text-bold">ตัวชี้วัดกลางถาค</p>
                        </div>
                        <div class="mr-50 mb-30" style="margin-left:100px;">
						      <div class="row">
						        <div class="col-md-12">
						        <table>
					                <tbody class="border-none">
					                  
									'.$objective_mid_conclude_desc.'
			
					                </tbody>
					              </table>
						        </div>
						       </div>
						    </div>
						<div class="mr-50 " style="margin-left:80px;">
                        	<p class="text-bold">ตัวชี้วัดปลายถาค</p>
                        </div>
                        <div class="mr-50 " style="margin-left:100px;">
						      <div class="row">
						        <div class="col-md-12">
						        <table>
					                <tbody class="border-none">
					                  
									'.$objective_final_conclude_desc.'
			
					                </tbody>
					              </table>
						        </div>
						       </div>
						    </div>
		';
		return $data_response;
	}
	
	
	
	public function get_pick($coures_id_list_val,$active_length){
		$data_response = array();	
		if($active_length=='before'){
			$condition="proportion_status=1";
		}elseif($active_length=='after'){
			$condition="proportion_status=2";
		}
		$this->sql ="SELECT  count(*) as num_row
					FROM tbl_objective_conclude 	
					WHERE courseID=$coures_id_list_val
					AND $condition
					";
		$this->select();
		$this->setRows();	

		$num_row=$this->rows[0]['num_row'];
			$num=0;
			$loop_set=ceil($num_row/10);
			$scrap=$num_row%10;
			if ($num_row<=10) {
					if ($num_row==10) {
						$length_list="<option class=\"chk_active_1\" status=\"chk_active_1\" value=\"1-10\">ตัวชี้วัดข้อที่ 1-10 </option>" ;
					}elseif($num_row<10){
						if ($num_row==1) {
							$length_list="<option class=\"chk_active_1\" status=\"chk_active_1\" value=\"1-1\">ตัวชี้วัดข้อที่ 1</option>" ;
						}else{
							$length_list="<option class=\"chk_active_1\" status=\"chk_active_1\" value=\"1-{$num_row}\">ตัวชี้วัดข้อที่ 1-{$num_row} </option>" ;
						}
						
					}				
				}else{
					$num_loop_class=1;
					for ($i=1; $i <=$loop_set ; $i++) { 

							if ($i==1) {
								$length_list.="<option class=\"chk_active_1\" status=\"chk_active_1\" value=\"1-10\">ตัวชี้วัดข้อที่ 1-10 </option>" ;
							}else{
								if ($loop_set==$i) {
									if ($scrap==0) {
											$length_list.="<option {$this->get_selected($num_loop_class)} class=\"chk_active_{$num_loop_class}\" status=\"chk_active_{$num_loop_class}\" value=\"{$num}1-{$loop_set}0\">ตัวชี้วัดข้อที่ {$num}1-{$loop_set}0 </option>" ;
									}else{
										if ($scrap==1) {
											$length_list.="<option {$this->get_selected($num_loop_class)} class=\"chk_active_{$num_loop_class}\" status=\"chk_active_{$num_loop_class}\" value=\"{$num}1-{$num}1\">ตัวชี้วัดข้อที่ {$num}1 </option>" ;
										}else{
											$length_list.="<option {$this->get_selected($num_loop_class)}  class=\"chk_active_{$num_loop_class}\" status=\"chk_active_{$num_loop_class}\" value=\"{$num}1-{$num}{$scrap}\">ตัวชี้วัดข้อที่ {$num}1-{$num}{$scrap} </option>" ;
										}										
									}									
								}else{
									$length_list.="<option {$this->get_selected($num_loop_class)} class=\"chk_active_{$num_loop_class}\" status=\"chk_active_{$num_loop_class}\" value=\"{$num}1-{$i}0\">ตัวชี้วัดข้อที่ {$num}1-{$i}0 </option>" ;
								}							
							}	
						$num++;
						$num_loop_class++;
					}					
				}
		$this->sql ="SELECT  no_order,detail
					FROM tbl_objective_conclude 	
					WHERE courseID=$coures_id_list_val
					AND $condition
					ORDER BY no_order ASC
					";
		$this->select();
		$this->setRows();	
		foreach($this->rows as $key => $value) {
			$no_order=$value['no_order'];
			$detail=$value['detail'];
			$objective_conclude_desc.='
									<tr>
					                    <td width="80px">ตัวชี้วัดที่ '.$no_order.'</td>		
					                    <td >'.$detail.'</td>			                    
					                 </tr>
			';
		}
		$data_response='
						<div  id="hr-co-text-depart_course" class="row">
				      <div class="hr-co-text-depart"></div> 
				    </div>
						<div id="text_header_config" class="row pd-50 stage-set" >                  
						      <div class="col-sm-12 col-xs-12 mt-nega-20">                        
						        <div class="set-line">
						          <p class="text-bold text-before-box fs-18">คะแนนเก็บ</p>

						        </div>
						      </div>
						    </div>
						     <div id="course_config_box" class="ml-36 mr-50 mt-nega-50" >               
						      <div class="col-sm-12 col-xs-12">                        
						        <div class="set-line"> 
						          <div id="rate_score_box" class="col-sm-12 col-xs-12" style="display: block;">  
						            <div class="row">

						              <table>
						                <tbody style="border: none;">
						                  <tr >
						                    <td class="text-before-box3 text-bold" style="float: right;">
						                      ช่วงคะแนน
						                    </td>
						                    <td width="250px">
						                      <select onchange="get_objective_list()"  id="length_list_val" name="length_list_val"  class="form-control search-drop-length-ob mt-5">
						                       '.$length_list.'   	   
						                      </select> 
						                    </td>  

						                  </tr>
						                  <tr >
						                    <td class="text-before-box3 text-bold" style="float: right;">
						                      คะแนน
						                    </td>
						                    <td width="200px">
						                      <select onchange="open_edit_score()" id="objective_list" name="objective_list" class="form-control search-drop-length-ob mt-5">
						                                          	      
						                      </select> 
						                    </td>  

						                    <td class="text-before-box3 text-bold" style="float: right;">
						                      ระบุคะแนนทั้งหมดเป็น
						                    </td>
						                    <td>
						                      <div class="input-group form-serch-width-small">
						                        <input id="input_set_data_seem" type="text" class="form-control form-set-search"  aria-describedby="basic-addon1">
						                      </div>
						                    </td>
						                    <td>
						                      <div class="btn-search-save-score ">
						                        <div id="btn_set_data_seem" class="btn-search">						                        
						                            <span class="glyphicon glyphicon-arrow-right" aria-hidden="true"></span>						                      
						                        </div>                                                                           
						                      </div>  
						                    </td>
						                  </tr>
						                </tbody>                                         
						              </table>
						            </div>                               
						          </div>                        
						        </div>
						      </div>
						    </div>
						    <!--table-->
						    <div class=" ml-50 mr-50 mt-80" >
						      <div class="row">
						        <div class="col-md-12">
						          <div class="table-responsive">
						            <table class="table table-striped-violet border-set-violet" style="text-align: center;">
						              <thead class="header-table">
						                <tr class="text-middle">
						                  <td  rowspan = "5" width="4%" style="  vertical-align: middle;">เลขที่</td>
						                  <td  rowspan = "5" width="4%" style="  vertical-align: middle;">รหัส</td>
						                  <td rowspan = "5" width="30%" style="  vertical-align: middle;">ชื่อ-สกุล</td>
						                  <td colspan="11">คะแนนเก็บ</td>      
						                </tr>
						                <tr>
						                  <td id="end_data_find" colspan="10">ตัวชี้วัดทื่/คะแนน</td> 
						                  <td rowspan = "2">รวม</td>
						                </tr>
						                <tr id="ob_title_table_col">
						               
						                </tr>
						               	<tr id="ob_score_max_table_col" class="table-bg-white">
						               
						                </tr>
						              </thead>
						              <form id="frm_objective_score_std">
						              <tbody id="detail_std" class="body-table">
						              	
						              </tbody>
						              </form>
						            </table> 
						          </div>
						        </div>                                     
						      </div>   
						      <div class="btn-group-set-add-delete row pd-30 ">                                                     
						        <a href="index.php">                                                
                              <div class="btn-grey">
                                ยกเลิก
                              </div>    
                            </a>   
						        <div data-toggle="modal" data-target="#modalConScore" class="btn-violet">
						          บันทึก
						        </div>                   
						      </div>  
						    </div>
							<div class=" ml-50 mr-50 " >
						      <div class="row">
						        <div class="col-md-12">
						        <table>
					                <tbody class="border-none">
					                  '.$objective_conclude_desc.'
					                </tbody>
					              </table>
						        </div>
						       </div>
						    </div>
		';
		return $data_response;
	}
	public function get_year(){
		$this->sql ="SELECT  distinct(year) as year
					FROM tbl_pp6
					ORDER BY year DESC
							";
		$this->select();
		$this->setRows();
		foreach($this->rows as $key => $value) {
			$year=  $value['year'];	
			if($key==0){	
			$data_response.='
					 <option selected="selected" value="'.$year.'">'.$year.'</option>
			';
			}else{
				$data_response.='
					 <option  value="'.$year.'">'.$year.'</option>
			';
			}
			
		}
		return json_encode($data_response);
	}
	
}
?><file_sep>/modules/report/level_form.php
<link href="../../assets/css/bootstrap.css" rel="stylesheet" type="text/css">
<link href="../../assets/css/custom.css" rel="stylesheet" type="text/css">
<link href="../../assets/css/margin-padding.css" rel="stylesheet" type="text/css">
<link href="../../assets/css/responsive.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
 table {
    border-collapse: collapse;
}

td, th {
    border: 1px solid black;
    padding: 5px;
}
-->
</style>
<?php
 @session_start();
    include('logo.php');
    require_once('../../init.php');
    include('class_modules.php');
    $class_data = new ClassData();
  ?>
<page orientation="landscape">
    <img style="margin :10px 0px 10px 495px;display:block;width: 80px;height: 80px;"src="<?php echo $image_logo ?>">
   	<br>
   	<div class="col-sm-12 text-center " style="font-size: 22px;margin-top: -5px;">
      <p class="text-bold" style="margin-top: -8px;">รายงานการประเมินผลการเรียนตามระดับชั้น</p>
      <p class="text-bold " style="margin-top: -8px;">โรงเรียนเทศบาลวัดสระทอง</p>
      <p style="margin-top: -8px;"> <span class="text-bold">ระดับชั้น </span> มัธยมศึกษาปีที่ 1 <span class="text-bold">ห้อง</span> 1 <span class="text-bold">ภาคเรียนที่</span> 1 <span class="text-bold">ปีการศึกษา</span> 2560</p>
      <p class="text-bold " style="margin-top: 0px;">ครูประจำชั้น ........................................................................</p>
      
    
    </div>
     <table cellspacing="0" style="width: 94%; text-align: center; font-size: 16px;margin-left:40px;border: 1px solid black;margin-top: 35px;">
              <thead >
                
                <tr style="background-color: #e0e0e0;">
                  
                  <td style="width: 4%;height: 65px;">เลขที่</td>
                  <td style="width: 40%;">ชื่อ-สกุล</td>
                  <td style="width: 4%;"><div style="rotate:90;">ท1001</div></td>
                  <td style="width: 4%;"><div style="rotate:90;">ค1001</div></td>
                  <td style="width: 4%;"><div style="rotate:90;">ค1002</div></td>
                  <td style="width: 4%;"><div style="rotate:90;">ส1001</div></td>
                  <td style="width: 4%;"><div style="rotate:90;">ว1001</div></td>
                  <td style="width: 4%;"><div style="rotate:90;">ว1001</div></td>
                  <td style="width: 4%;"><div style="rotate:90;">ว1001</div></td>
                  <td style="width: 4%;"><div style="rotate:90;">ว1001</div></td>
                  <td style="width: 4%;"><div style="rotate:90;">ว1001</div></td>
                  <td style="width: 4%;"><div style="rotate:90;">ว1001</div></td>
                  <td style="width: 4%;"><div style="rotate:90;">คุณลักษณะฯ</div></td>
                  <td style="width: 4%;"><div style="rotate:90;">อ่าน&nbsp;&nbsp;เขียน&nbsp;&nbsp;คิดฯ</div></td>
                  <td style="width: 4%;"><div style="rotate:90;">GPA</div></td>
                  <td style="width: 4%;"><div style="rotate:90;">อันดับที่</div></td>
                  
                
                </tr>
              </thead>
              <tbody>
                <tr>
                  <td >1</td>
                  <td >ด.ช. วันสุข สุดสะบาย</td>
                  <td >4</td>
                  <td >4</td>
                  <td >4</td>
                  <td >4</td>
                  <td >4</td>
                  <td >4</td>                
                  <td >4</td>
                  <td >4</td>
                  <td >4</td>
                  <td >4</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                 
                </tr>
                <tr>
                  <td >1</td>
                  <td >ด.ช. วันสุข สุดสะบาย</td>
                  <td >4</td>
                  <td >4</td>
                  <td >4</td>
                  <td >4</td>
                  <td >4</td>
                  <td >4</td>                
                  <td >4</td>
                  <td >4</td>
                  <td >4</td>
                  <td >4</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                 
                </tr>
                <tr>
                  <td >1</td>
                  <td >ด.ช. วันสุข สุดสะบาย</td>
                  <td >4</td>
                  <td >4</td>
                  <td >4</td>
                  <td >4</td>
                  <td >4</td>
                  <td >4</td>                
                  <td >4</td>
                  <td >4</td>
                  <td >4</td>
                  <td >4</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                 
                </tr>
                <tr>
                  <td >1</td>
                  <td >ด.ช. วันสุข สุดสะบาย</td>
                  <td >4</td>
                  <td >4</td>
                  <td >4</td>
                  <td >4</td>
                  <td >4</td>
                  <td >4</td>                
                  <td >4</td>
                  <td >4</td>
                  <td >4</td>
                  <td >4</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                 
                </tr>
                <tr>
                  <td >1</td>
                  <td >ด.ช. วันสุข สุดสะบาย</td>
                  <td >4</td>
                  <td >4</td>
                  <td >4</td>
                  <td >4</td>
                  <td >4</td>
                  <td >4</td>                
                  <td >4</td>
                  <td >4</td>
                  <td >4</td>
                  <td >4</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                 
                </tr>
                <tr>
                  <td >1</td>
                  <td >ด.ช. วันสุข สุดสะบาย</td>
                  <td >4</td>
                  <td >4</td>
                  <td >4</td>
                  <td >4</td>
                  <td >4</td>
                  <td >4</td>                
                  <td >4</td>
                  <td >4</td>
                  <td >4</td>
                  <td >4</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                  <td >1</td>
                 
                </tr>
              </tbody>
    </table> 
    <table style="width: 220px;margin-left: 130px;margin-top: 20px;font-size: 16px;" >    
           <thead>
             <tr style="width: 220px;">
               <td style="width: 35%;text-align: center;border: none;">หมายเหตุ : </td>
               <td style="width: 65%;border: none;" colspan="3">วิชากิจกรรมพัฒนาผู้เรียน</td>
             </tr>
           </thead>
           <tbody>
            <tr>
              <td style="border: none;"></td>
              <td style="border: none;">ผ</td>
              <td style="border: none;">หมายถึง</td>
              <td style="border: none;">ผ่าน</td>
            </tr>
            <tr>
              <td style="border: none;"></td>
              <td style="border: none;">มผ</td>
              <td style="border: none;">หมายถึง</td>
              <td style="border: none;">ไม่ผ่าน</td>
            </tr>

           </tbody>

    </table>
    <table style="width: 220px;margin-left: 430px;margin-top: -82.6px;font-size: 16px;" >    
           <thead>
             <tr>
               <td colspan="3" style="width: 100%;text-align: center;border: none;">การประเมินผลคุณลักษณะอันพึงประสงค์</td>
             </tr>
           </thead>
           <tbody>
            <tr>
              <td style="border: none;">3</td>
              <td style="border: none;">หมายถึง</td>
              <td style="border: none;">ดีเยี่ยม</td>
            </tr>
            <tr>
              <td style="border: none;">2</td>
              <td style="border: none;">หมายถึง</td>
              <td style="border: none;">ดี</td>
            </tr>
             <tr>
              <td style="border: none;">1</td>
              <td style="border: none;">หมายถึง</td>
              <td style="border: none;">ผ่าน</td>
            </tr>
             <tr>
              <td style="border: none;">0</td>
              <td style="border: none;">หมายถึง</td>
              <td style="border: none;">ไม่ผ่าน</td>
            </tr>
           </tbody>

    </table>
    <table style="width: 220px;margin-left: 745px;margin-top: -136.5px;font-size: 16px;" >    
           <thead>
             <tr>
               <td colspan="3" style="width: 100%;text-align: center;border: none;">การประเมินผลการอ่าน เขียน คิด วิเคราะห์</td>
             </tr>
           </thead>
           <tbody>
            <tr>
              <td style="border: none;">3</td>
              <td style="border: none;">หมายถึง</td>
              <td style="border: none;">ดีเยี่ยม</td>
            </tr>
            <tr>
              <td style="border: none;">2</td>
              <td style="border: none;">หมายถึง</td>
              <td style="border: none;">ดี</td>
            </tr>
             <tr>
              <td style="border: none;">1</td>
              <td style="border: none;">หมายถึง</td>
              <td style="border: none;">ผ่าน</td>
            </tr>
             <tr>
              <td style="border: none;">0</td>
              <td style="border: none;">หมายถึง</td>
              <td style="border: none;">ไม่ผ่าน</td>
            </tr>
           </tbody>

    </table>
</page>
<page orientation="landscape">
  <table cellspacing="0" style="width: 94%; text-align: center; font-size: 16px;margin-left:40px;border: 1px solid black;margin-top: 35px;">
              <thead >
                
                <tr style="background-color: #e0e0e0;">              
                  <td colspan="12" style="width: 100%;">สรุปการประเมินผลการเรียน</td>
                    
                </tr>
                <tr style="background-color: #e0e0e0;">
                  <td style="width: 25%;">ผลการเรียน (GPA)</td>
                  <td style="width: 6%;">3.51-4.00</td>
                  <td style="width: 6%;">3.01-3.50</td>
                  <td style="width: 6%;">2.51-3.00</td>
                  <td style="width: 6%;">2.01-2.50</td>
                  <td style="width: 6%;">1.51-2.00</td>
                  <td style="width: 6%;">1.01-1.50</td>
                  <td style="width: 6%;">0.00-1.00</td>
                  <td style="width: 6%;">รวม</td>
                  <td style="width: 6%;">ผ</td>
                  <td style="width: 6%;">มผ</td>
                  <td style="width: 6%;">รวม</td>      
                </tr>
              </thead>
              <tbody>
                <tr>
                  <td >จำนวน</td>
                  <td >10</td>
                  <td >10</td>
                  <td >-</td>
                  <td >-</td>
                  <td >-</td>
                  <td >-</td>
                  <td >-</td>                
                  <td >20</td>
                  <td >20</td>
                  <td >-</td>
                  <td >20</td>

                </tr>
                <tr>
                  <td >ร้อยละ</td>
                  <td >50.00</td>
                  <td >50.00</td>
                  <td >-</td>
                  <td >-</td>
                  <td >-</td>
                  <td >-</td>
                  <td >-</td>                
                  <td >100.00</td>
                  <td >100.00</td>
                  <td >-</td>
                  <td >100</td>
                </tr>
                
              </tbody>
    </table> 
    <table cellspacing="0" style="width: 94%; text-align: center; font-size: 16px;margin-left:40px;border: 1px solid black;">
              <thead >
               <tr style="background-color: #e0e0e0;">
                  <td style="width: 27.44%;border-top: none;"></td>
                  <td colspan="5" style="width: 33%;border-top: none;">คุณลักษณะอันพึงประสงค์</td>
                  <td colspan="5" style="width: 39.6%;border-top: none;">อ่าน เขียน คิดวิเคราะห์</td>
                </tr>
                <tr style="background-color: #e0e0e0;">
                  <td >ผลการประเมิน</td>
                  <td style="width: 5%">3</td>
                  <td style="width: 5%">2</td>
                  <td style="width: 5%">1</td>
                  <td style="width: 5%">0</td>
                  <td style="width: 5%">รวม</td>
                  <td style="width: 5%">3</td>
                  <td style="width: 5%">2</td>                
                  <td style="width: 5%">1</td>
                  <td style="width: 5%">0</td>
                  <td style="width: 5%">รวม</td>

                </tr>
              </thead>
              <tbody>
               <tr>
                 <td >จำนวน</td>
                  <td >20</td>
                  <td >-</td>
                  <td >-</td>
                  <td >-</td>
                  <td >20</td>
                  <td >20</td>
                  <td >-</td>                
                  <td >-</td>
                  <td >-</td>
                  <td >20</td>
               </tr>
                <tr>
                 <td >ร้อยละ</td>
                  <td >100.00</td>
                  <td >-</td>
                  <td >-</td>
                  <td >-</td>
                  <td >100.00</td>
                  <td >100.00</td>
                  <td >-</td>                
                  <td >-</td>
                  <td >-</td>
                  <td >100.00</td>
               </tr>
              </tbody>
    </table> 
    <div style="margin-left: 140px;margin-top: 60px;font-size: 16px">
      <p>.................................................................รองผู้อำนวยการฝ่ายวิชาการ </p>
     
      <p style="margin-left: 2px;">(</p> <p style="margin-top: -24px;margin-left:140px;"> )</p>

      <p style="margin-left: 12px;">................/................/...................</p>
    </div>
     <div style="margin-left: 690px;margin-top: -77px;font-size: 16px">
      <p>.................................................................ผู้อำนวยการ </p>
     
      <p style="margin-left: 2px;">(</p> <p style="margin-top: -24px;margin-left:140px;"> )</p>

      <p style="margin-left: 12px;">................/................/...................</p>
    </div>
</page><file_sep>/src/api.payment.php
<?php

class ApiPayment
{
	public function __construct()
	{
		//$this->APP_URL = BASE_URL.'payment/action.php';
	}

	public function test($value='')
	{
		$input = self::demo();
		$data = self::set_request($input);
		return self::order_payment($data);
	}

	public function send_order_payment($input=null)
	{
		$url = $input['action_url'];
		$data = self::set_request($input);
		return apicaller($url,$data);
		//return json_encode($data);// apicaller($url,$data);
	}

	public function set_request($input=null)
	{
		/*
		['acc_action'] = ''; // new_payment_online
		['service_type_name'] = ''; // BookingRoom
		['acc_path_rep'] = '';
		['respurl'] = '';
		['member_id'] = '';

		['contact'] = array([i])
		['items'] = array([j])
		['payment'] = array([k])
		*/

		if(!$input){
			return false;
		}
		
		$i=0;

		$contact = $input['contact_info'];
		$items = $input['items_info'];
		$payments = $input['payments_info'];

// 1 -------------------------------------	
		$send_data = array();
		$send_data['acc_action'] = $input['acc_action'];
		$send_data['acc_path_rep'] = $input['acc_path_rep']; // success.php // URL forwaording

// ---------------------------------
		$send_data['service_type_name'] = $input['service_type_name']; // BookingRoom
		$send_data['service_ref_id'] = $input['service_ref_id']; // item ID
		$send_data['seveice_ref_key_1'] = $input['seveice_ref_key_1']; // (optional)
		$send_data['seveice_ref_key_2'] = $input['seveice_ref_key_2'];
		$send_data['seveice_ref_key_3'] = $input['seveice_ref_key_3'];

		$send_data['server_title'] = $input['server_title']; // BookingRoom : EventID 002
		$send_data['respurl'] = $input['respurl']; // URL callback to from server
		$send_data['member_id'] = $input['member_id']; // member ID

// Contact Info

		// -----
		//$send_data['customer_id'] = '';
		$send_data['customer_code'] = $input['customer_code'];
		$send_data['customer_name'] = $input['customer_name']; // ref contact person name OR company name

		$send_data['io_no'] = $input['io_no'];
		$send_data['business_place'] = $contact[$i++]; // 0
		$send_data['tax_id'] = $contact[$i++];
		$send_data['contact_email'] = $contact[$i++];
		$send_data['contact_tel_no'] = $contact[$i++];
		$send_data['add_building'] = $contact[$i++];
		$send_data['add_house_no'] = $contact[$i++];
		$send_data['add_street'] = $contact[$i++];
		$send_data['add_country'] = $contact[$i++];
		$send_data['add_city'] = $contact[$i++];
		$send_data['add_district'] = $contact[$i++];
		$send_data['add_subdistrict'] = $contact[$i++];
		$send_data['add_postal_code'] = $contact[$i++]; // 11

// Contactn Address (optional)

		$send_data['add_home_building'] = '';
		$send_data['add_home_house_no'] = '';
		$send_data['add_home_street'] = '';
		$send_data['add_home_subdistrict'] = '';
		$send_data['add_home_district'] = '';
		$send_data['add_home_city'] = '';
		$send_data['add_home_country'] = '';
		$send_data['add_home_postal_code'] = '';

// Items List

		$item_count = sizeof($items);
		$send_data['item_count'] = $item_count; // item count [number]
		for ($i=0; $i < $item_count; $i++) { 
			$c=0;
			$send_data['material_on'][] = $items[$i][$c++]; // 0 :รหัสสินค้า : '-'
			$send_data['service_type'][] = $items[$i][$c++]; // BookingRoom : $service_type_name
			$send_data['payment_detail'][] = $items[$i][$c++]; // 11A (Meeting Room) A1101 | Date 12/01/2014 10:00 - 16:00
			$send_data['quantity'][] = $items[$i][$c++];  // จำนวน : 20
			$send_data['unit'][] = $items[$i][$c++]; // หน่วย
			$send_data['unit_price'][] = $items[$i][$c++]; // ราคาต่อหน่วย : 1000
			$send_data['discount'][] = $items[$i][$c++]; // ราคาต่อหน่วย : 500
			$send_data['amount'][] = $items[$i][$c++];  // 7: ราคารวม //: (1000x20)-500 = 19500
		}

// Payment

		$item_count = sizeof($payments);
		$deposit = ($item_count > 1)? 'y':'n';
		$send_data['deposit_status'] = $deposit; //n/y

		for ($i=0; $i < $item_count; $i++) { 
			$c=0;
			$send_data['payment_type'][] = $payments[$i][$c++]; // 0 : creditcard / paypal / billpayment / pos
			$send_data['invoice_date'][] = $payments[$i][$c++]; //days : 0
			$send_data['payment_date'][] = $payments[$i][$c++]; //days : 30
			$send_data['net_price'][] = $payments[$i][$c++]; //THB : 39500
			$send_data['paid'][] = $payments[$i][$c++]; //THB : 27650
			$send_data['whtax'][] = $payments[$i][$c++]; //n/y : n
			$send_data['whtype'][] = $payments[$i][$c++]; //03 (บุคคลธรรมดา) / 53 (นิติบุคคล)
			$send_data['percentwh'][] = $payments[$i][$c++]; // 7 : % Withholding tax : 0
		}

		return $send_data;
		//return apicaller($this->APP_URL,$request_data);

	}


	
//  :: NOT USED :: ---------------------------------------------------------------------------------


	public function demo()
	{
		$data = array();
		$data['action_url'] = 'payment/action.php';
		$data['action_name'] = 'new_payment_online';
		$data['service_name'] = 'BookingRoom';
		$data['forword_url'] = 'payment/test_resp.php';
		$data['callback_url'] = '';

		$data['member_id'] = '1';
		$data['sap_id'] = ''; // customer_code // backoffice admin id
		$data['io_no'] = '';
		$data['ref_id'] = '140342104'; // item ID
		$data['ref_id_1'] = ''; // (optional)
		$data['ref_id_2'] = '';
		$data['ref_id_3'] = '';

		$data['title_name'] = 'BookingRoom : EventID 001';
		$data['customer_name'] = 'บริษัท ไทยเบฟเวอเรจ จำกัด (มหาชน)';// ref contact person name OR company name

		$contact = range(1,12);
		$items = array( range(1,8), range(9,16) );
		$payments = array( range(1,8), range(9,16) );

/*****************************
@Contact Info::
business_place // 0
tax_id
contact_email
contact_tel_no
add_building
add_house_no
add_street
add_subdistrict
add_district
add_city
add_country
add_postal_code // 11
*/

		$data['contact_info'] = $contact;

/*****************************
@Items Info::
material_on // รหัสสินค้า : '-' 
service_type // BookingRoom : $service_type_name
payment_detail // 11A (Meeting Room) A1101 | Date 12/01/2014 10:00 - 16:00
quantity // จำนวน 20
unit // หน่วย
unit_price // ราคาต่อหน่วย : 1000
discount // ราคาต่อหน่วย : 500
amount // 7 : ราคารวม //: (1000x20)-500 = 19500
*/

		$data['items_info'] = $items;

/*****************************
@Payment Info::
payment_type // creditcard / paypal / billpayment / pos
invoice_date // days
payment_date // days
net_price // THB
paid // THB
whtax // n, y
whtype //03 (บุคคลธรรมดา) / 53 (นิติบุคคล)
percentwh // 7 : % Withholding tax : 0
*/

		$data['payments_info'] = $payments;		

		return $data;
	}

	public function test_set_request($input=null)
	{

		if(!$input){
			return false;
		}
			
		$data = array();
		$data['acc_action'] = $input['action_name'];
		$data['service_type_name'] = $input['service_name'];
		$data['acc_path_rep'] = $input['forword_url'];
		$data['respurl'] = $input['callback_url'];

		$data['member_id'] = $input['member_id'];
		$data['customer_code'] = $input['sap_id'];
		$data['io_no'] = $input['io_no'];
		$data['service_ref_id'] = $input['ref_id']; // item ID
		$data['seveice_ref_key_1'] = $input['ref_id_1']; // (optional)
		$data['seveice_ref_key_2'] = $input['ref_id_2'];
		$data['seveice_ref_key_3'] = $input['ref_id_3'];

		$data['server_title'] = $input['title_name'];
		$data['customer_name'] = $input['customer_name']; // ref contact person name OR company name

// @array and value key[i]
		$data['contact_info'] = $input['contact_info'];
		$data['items_info'] = $input['items_info'];
		$data['payments_info'] = $input['payments_info'];

		return $data;
	}	


}






<file_sep>/modules/authen_user/process.php
<?php
@ob_start();
@session_start();

require_once('../../init.php');
include('../../src/class.pagination.php');
include('../../src/class.inputfilter.php');
$InputFilter = new InputFilter();

/////// CLASS ROLE MANAGEMENT /////
require_once('../../src/class_role.php');
$role = new ClassRole();
$user_role_id = (int)$_SESSION['ss_user_id'];

##CLASS_DB_CONNECT##
include('class_modules.php');
$class_data = new ClassData();
##CLASS_DB_CONNECT##
$targetfile =  '../../../file_managers/userprofile/';

if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_data_list"){
	$sort_column = $_GET['sort_column'];
	$sort_by = $_GET['sort_by'];
	$pages_current = $_GET['pages_current'];
	$arr_search_val = array();
	$arr_search_val['data_name'] = $_GET['data_name'];
	$arr_search_val['data_status'] = $_GET['data_status'];
	echo $class_data->get_data_list($arr_search_val,$pages_current,$sort_column,$sort_by);
}

if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_data_from"){
	$data_id = $_GET['data_id'];
	echo $class_data->get_data_from($data_id);
}

if(isset($_POST['acc_action']) and $_POST['acc_action'] == "save_data"){
	$data_id = (int)$_POST['data_id'];
	$ath_tasks = $_POST['ath_tasks'];
	if ($data_id > 0) {
		$arr_sql = array();
		$password = trim($_POST['<PASSWORD>']);
		$arr_sql[]="role_id='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['role_id'])))."'";
		$arr_sql[]="username='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['username'])))."'";
		if ($password != "") { $arr_sql[]="password='".MD5($password)."'"; }
		$arr_sql[]="first_name='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['first_name'])))."'";
		$arr_sql[]="last_name='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['last_name'])))."'";
		$arr_sql[]="status='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['data_status'])))."'";
		$arr_sql[]="mdate=now()"; 
		if ($class_data->update_data($arr_sql,$data_id) == "") {
			if ($ath_tasks != "") { $class_data->update_ath_tasks($ath_tasks,$data_id); }
			echo "Y";
		}else{
			echo "N";
		}
		
	}else{
	    $arr_sql = array();
	    $password = trim($_POST['password']);
		$arr_sql["role_id"]= "'".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['role_id'])))."'";
		$arr_sql["username"]= "'".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['username'])))."'";
		 if ($password != "") { $arr_sql["password"]= "'".MD5($password)."'"; }
		$arr_sql["first_name"]= "'".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['first_name'])))."'";
		$arr_sql["last_name"]= "'".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['last_name'])))."'";
		$arr_sql["status"]= "'".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['data_status'])))."'";
		$arr_sql["cdate"]= "now()"; 
		$arr_sql["mdate"]= "now()"; 
		$data_id = $class_data->insert_data($arr_sql,'0');
		if ($data_id > 0) {
			if ($ath_tasks != "") { $class_data->update_ath_tasks($ath_tasks,$data_id); }
			echo "Y";
		}else{
			echo "N";
		}
	}
}

if(isset($_POST['acc_action']) and $_POST['acc_action'] == "data_remove"){
	$data_val = $_POST['data_val'];
	echo $class_data->get_data_delete($data_val);
}

if(isset($_POST['acc_action']) and $_POST['acc_action'] == "get_role_list"){
	$RoleList = $class_data->fetchRole();
	echo $RoleList;
}

if(isset($_POST['acc_action']) and $_POST['acc_action'] == "get_tasks_list"){
	$data_val = $_POST['data_val'];
	$data_id = (int)$_POST['data_id'];
	echo $class_data->get_tasks_list($data_val,$data_id);
}

if(isset($_POST['acc_action']) and $_POST['acc_action'] == "get_role_reletion_tasks"){
	$role_id = $_POST['role_id'];
	echo $class_data->get_role_reletion_tasks($role_id);
}

if(isset($_POST['acc_action']) and $_POST['acc_action'] == "upload_thumb"){
		// $targetfile = $targetfile."news/";
		if (!empty($_FILES)) {
			$size = getimagesize($_FILES['file']['tmp_name']);
          //   $chk_height = $size[1];

          // if($chk_height<271){
          //     echo $chk_height;
          // }else{

			$new_file_name	=	date('Ymdhis');
			ini_set ( "memory_limit", "80M");
			$StatusSave	= 0;//[0]=Problems [1]=Successfully
			$file_name = ""; // File name in Database

			# Check Type Files 
			$typeaccept 	= array(".jpg",".gif",".jpeg",".png"); 
			// $typeaccept_doc = array(".pdf",".doc",".docx",".ppt",".pptx",".xls",".xlsx"); 
			$fileExt    	= "." . strtolower(end(explode('.', $_FILES['file']['name'])));
			$file_ok		= (in_array($fileExt, $typeaccept)) ? true : false;
			// $document_ok	= (in_array($fileExt, $typeaccept_doc)) ? true : false;
			list($width_n, $height_n, $type_n, $w_n) = getimagesize($_FILES['file']['tmp_name']);
			if($file_ok==true || $document_ok==true)
			{ 
				include ('../../src/class.upload.php');
				// $thumbnail = new Upload($_FILES['file']);
				// if ($thumbnail->uploaded) {   
				// 		$thumbnail->image_convert = 'jpg';
				// 		$thumbnail->jpeg_quality = 100;
				// 		$thumbnail->image_resize  = true;
				// 		$thumbnail->image_ratio_crop = true;
				// 		$thumbnail->image_x = 100; //4:3 Aspect Ratio 
				// 		$thumbnail->image_y = 100; //4:3 Aspect Ratio 
				// 		$thumbnail->file_new_name_body	= $new_file_name;
				// 		$thumbnail->process($targetfile.'thumbnail/'); 
				// 	if ($thumbnail->processed) {   // UPLOAD THUMBNAIL PROCESS END 
				// 		//$thumbnail->clean(); 
				// 		$statussave	=	1;
				// 	}
				// }

				$main_photo = new Upload($_FILES['file']);
				if ($main_photo->uploaded) {   
						$main_photo->image_convert = 'jpg';
						$main_photo->jpeg_quality = 100;
						$main_photo->image_resize  = true;
						$main_photo->image_ratio_crop = true;
						$main_photo->image_x =  400; //4:3 Aspect Ratio 
						$main_photo->image_y = 400; //4:3 Aspect Ratio 
						$main_photo->file_new_name_body	= $new_file_name;
						$main_photo->process($targetfile.'thumbnails/'); 
					if ($main_photo->processed) {   // UPLOAD MAIN PHOTO PROCESS END 
						//$main_photo->clean(); 
						$statussave	=	1;
					}
				}
				$file_name 	= $new_file_name.".jpg";//.$fileExt;
				$filetype	= $fileExt;
			}
			
			# Check Upload Processed Successfully
			if($statussave==1){ 	
				$usersID	=	((int)$_POST['data_id'] == 0) ? 0 : (int)$_POST['data_id']; 
			    $arr_sql["usersID"]= "'{$usersID}'";
			    $arr_sql["FileName"]= "'{$file_name}'"; 
			    $arr_sql["Type"]= "'0'";
			    $arr_sql["sequence"]= "'0'"; 
			    $arr_sql["status"]= "'{$usersID}'"; 
				$arr_sql["create_time"]= "now()";
				$arr_sql["create_ip"]= "'".$ip."'";
				$arr_sql["update_time"]= "now()";
				$arr_sql["update_ip"]= "'".$ip."'";
				$new_par_id = $class_data->ex_add_thumb($arr_sql);
				// echo $usersID;
				echo "successfully";
			}else{
				echo "Problems";
			}
		  // }
		}

	}	

	if(isset($_POST['acc_action']) and $_POST['acc_action'] == "get_thumb"){
		$data_id = $_POST['data_id'];
		echo $class_data->get_thumb($data_id);
	}	
	if(isset($_POST['acc_action']) and $_POST['acc_action'] == "remove_thumb"){
		$data_id = $_POST['data_id'];
		echo $class_data->remove_thumb($data_id);
	}
?><file_sep>/modules/profile/class_modules.php
<?php 

class ClassData extends Databases {
	public function get_img($status_get){
		$user_id=$_SESSION['ss_user_id'];
		$data_response = array();
		$this->sql = "SELECT * FROM tbl_regis_teacher_gallery WHERE regis_teacher_id=$user_id" ;
		$this->select();
		$this->setRows();

		$FileName= $this->rows[0]['FileName'];
		if ($status_get=="index") {
			if ($FileName!="") {
			$data_response['get_profile_img'] ='<img class="circle-profile-index"  src="file_managers/profile/'.$FileName.'">   ';
			}else{
				$data_response['get_profile_img'] ='<div class="circle-profile-index" style="text-align:center;"> <span class="glyphicon glyphicon-picture span-profile mt-40" aria-hidden="true"></span></div>';
			}
		}else{
			if ($FileName!="") {
			$data_response['get_profile_img'] ='<img class="circle-profile"  src="file_managers/profile/'.$FileName.'">   ';
			}else{
				$data_response['get_profile_img'] ='';
			}
		}
		
		
		$data_response['file_name']='file_managers/profile/'.$FileName;
		return json_encode($data_response);
	}
	public function update_data($update){
		$user_id=$_SESSION['ss_user_id'];
		$this->sql = "UPDATE tbl_regis_teacher SET ".implode(",",$update)." WHERE DataID='".$user_id."'";
		$this->query();
	}

	public function get_department($department_data){
		if ($department_data=="1") {
			$department="ภาษาไทย ";
		}elseif($department_data=="2"){
			$department="คณิตศาสตร์";
		}elseif($department_data=="3"){
			$department="วิทยาศาสตร์";
		}elseif($department_data=="4"){
			$department="สังคมศึกษา ศาสนาและวัฒนธรรม";
		}elseif($department_data=="41"){
			$department="สังคมศึกษา";
		}elseif($department_data=="42"){
			$department="ภูมิศาสตร์";
		}elseif($department_data=="43"){
			$department="ประวัติศาสตร์";
		}elseif($department_data=="5"){
			$department="สุขศึกษาและพลศึกษา";
		}elseif($department_data=="6"){
			$department="ศิลปะ";
		}elseif($department_data=="7"){
			$department="การงานอาชีพและเทคโนโลยี";
		}elseif($department_data=="8"){
			$department="ภาษาต่างประเทศ";
		}elseif($department_data=="9"){
			$department="หน้าที่พลเมือง";
		}elseif($department_data=="10"){
			$department="ศิลปะพื้นบ้าน";
		}elseif($department_data=="11"){
			$department="ศักยภาพ";
		}elseif($department_data=="12"){
			$department="ภาษาจีน";
		}else{
			$department="-";
		}
		return $department;
	}
	public function get_gender($birthday_data){
		if ($birthday_data=="male") {
			$gender="ชาย";
		}else{
			$gender="หญิง";
		}
		return $gender;
	}
	public function get_birthday($birthday){
		$time  = strtotime($birthday);
		$day   = date('d',$time);
		$month = date('m',$time);
		$year  = date('Y',$time)+543;

		if ($month==1) {
			$month_data="กรกฎาคม";
		}elseif($month==2){
			$month_data="กุมภาพนธ์";
		}elseif($month==3){
			$month_data="มีนาคม";
		}elseif($month==4){
			$month_data="เมษายน";
		}elseif($month==5){
			$month_data="พฤษภาคม";
		}elseif($month==6){
			$month_data="มิถุนายน";
		}elseif($month==7){
			$month_data="กรกฎาคม";
		}elseif($month==8){
			$month_data="สิงหาคม";
		}elseif($month==9){
			$month_data="กัยายน";
		}elseif($month==10){
			$month_data="ตุลาคม";
		}elseif($month==11){
			$month_data="พฤษจิกายน";
		}elseif($month==12){
			$month_data="ธันวาคม";
		}

		$birthday_result=$day.' '.$month_data.' '.$year;
		return $birthday_result;

	}


	public function get_extra_data(){
		$data_response = array();
		$user_id=$_SESSION['ss_user_id'];
		$sql = "SELECT * 
				FROM tbl_regis_teacher
				WHERE DataID= '$user_id'
				";
		$this->sql = $sql;
		$this->select();
		$this->setRows();
		$data_response['blood_group']=unchkhtmlspecialchars($this->rows[0]['blood_group']);
		$data_response['gender']=unchkhtmlspecialchars($this->rows[0]['gender']);
		$data_response['department']=unchkhtmlspecialchars($this->rows[0]['department']);
		$birthday=unchkhtmlspecialchars($this->rows[0]['birthday']);
		$time  = strtotime($birthday);
		$day   = date('d',$time);
		$month = date('m',$time);
		$year  = date('Y',$time)+543;

		if ($month==1 || $month==3 || $month==5 || $month==7 || $month==8 || $month==10 || $month==12) {
			for ($i=1; $i <=31 ; $i++) { 
				if ($day==$i) {
					$day_data.='<option selected value="'.$i.'">'.$i.'</option> ';
				}else{
					$day_data.='<option value="'.$i.'">'.$i.'</option> ';
				}
				
			}
		}elseif($month==4 || $month==6 || $month==9 || $month==11){
			for ($i=1; $i <=30 ; $i++) { 
				if ($day==$i) {
					$day_data.='<option selected value="'.$i.'">'.$i.'</option> ';
				}else{
					$day_data.='<option value="'.$i.'">'.$i.'</option> ';
				}
			}
		}else{
			for ($i=1; $i <=29 ; $i++) { 
				if ($day==$i) {
					$day_data.='<option selected value="'.$i.'">'.$i.'</option> ';
				}else{
					$day_data.='<option value="'.$i.'">'.$i.'</option> ';
				}
			}
		}
		$data_response['day']=$day_data;
		$data_response['month']=$month;
		$data_response['year']=$year;

		return $data_response;

	}
	public function get_data(){
		$data_response = array();
		$user_id=$_SESSION['ss_user_id'];
		$sql = "SELECT * 
				FROM tbl_regis_teacher
				WHERE DataID= '$user_id'
				";
		$this->sql = $sql;
		$this->select();
		$this->setRows();
		$data_response['positionID'] = unchkhtmlspecialchars($this->rows[0]['positionID']);
		$fname_th = unchkhtmlspecialchars($this->rows[0]['fname_th']);
		$lname_th = unchkhtmlspecialchars($this->rows[0]['lname_th']);
		$data_response['fname_th'] = unchkhtmlspecialchars($this->rows[0]['fname_th']);
		$data_response['lname_th'] = unchkhtmlspecialchars($this->rows[0]['lname_th']);
		$data_response['full_name_th'] = $fname_th.' '.$lname_th;
		$fname_en = unchkhtmlspecialchars($this->rows[0]['fname_en']);
		$lname_en = unchkhtmlspecialchars($this->rows[0]['lname_en']);
		$data_response['fname_en'] = unchkhtmlspecialchars($this->rows[0]['fname_en']);
		$data_response['lname_en'] = unchkhtmlspecialchars($this->rows[0]['lname_en']);
		$data_response['full_name_en'] = $fname_en.' '.$lname_en;
		$data_response['study_history'] = unchkhtmlspecialchars($this->rows[0]['study_history']);

		$birthday_data= unchkhtmlspecialchars($this->rows[0]['birthday']);
		$birthday=$this->get_birthday($birthday_data);				
		$data_response['birthday']=$birthday;


		$gender_data= unchkhtmlspecialchars($this->rows[0]['gender']);
		$gender=$this->get_gender($gender_data);				
		$data_response['gender']=$gender;

		$data_response['blood_group'] = unchkhtmlspecialchars($this->rows[0]['blood_group']);
		$data_response['address'] = unchkhtmlspecialchars($this->rows[0]['address']);
		
		$data_response['position_name'] = unchkhtmlspecialchars($this->rows[0]['position_name']);

		$department_data = unchkhtmlspecialchars($this->rows[0]['department']);
		$department=$this->get_department($department_data);				
		$data_response['department']=$department;

		$data_response['work'] = unchkhtmlspecialchars($this->rows[0]['work']);
		$data_response['more_detail'] = unchkhtmlspecialchars($this->rows[0]['more_detail']);
		$data_response['tell'] = unchkhtmlspecialchars($this->rows[0]['tell']);
		$data_response['email'] = unchkhtmlspecialchars($this->rows[0]['email']);

		echo json_encode($data_response);
	}

	public function get_day($mouth){
		$data_response = array();
		
		for ($i=1; $i <= 29 ; $i++) { 
			$day_make_29.='<option value="'.$i.'">'.$i.'</option>';
		}
		for ($i=1; $i <= 30 ; $i++) { 
			$day_make_30.='<option value="'.$i.'">'.$i.'</option>';
		}
		for ($i=1; $i <= 31 ; $i++) { 
			$day_make_31.='<option value="'.$i.'">'.$i.'</option>';
		}
		if ($mouth==1 || $mouth==3 || $mouth==5 || $mouth==7 || $mouth==8 || $mouth==10 || $mouth==12) {
			$data_response['day_set']=$day_make_31;
		}elseif($mouth==4 || $mouth==6 || $mouth==9 || $mouth==11){
			$data_response['day_set']=$day_make_30;
		}else{
			$data_response['day_set']=$day_make_29;
		}

	echo json_encode($data_response);
	}

}<file_sep>/src/class.packagewifi.php
<?php

// API authen

class Packagewifi 
{
	
	public function __construct()
	{

	}

	public function get_package()
	{
		return self::set_package();
	}

	public function get_package_data()
	{

		$package_wifi = array();
		$result = self::set_package();
		foreach($result['Packages'] as $package){
			$package_wifi[$package['ID']] = $package;
		}

		return $package_wifi;
	}
	
	public function get_package_name()
	{

		$package_wifi = array();
		$result = self::set_package();
		foreach($result['Packages'] as $package){
			$package_wifi[$package['ID']] = $package['Name'];
		}

		return $package_wifi;
	}



	public function create_wifi_account($package_id,$input)
	{
		$data = array(
			'Interface' => 'CloudPOS',//
			'Command' => '9100',//
			'Channel' => 'POS',//
			'Version' => '1.0',//
			'IP' => '192.168.1.1',//
			'PosUsername' => '<EMAIL>',
			'PosPassword' => '<PASSWORD>',
			'PackageID' => $package_id,
			'NoAcc' => 1,//
			'Prefix' => $input[$i++],
			'Postfix' => $input[$i++],
			'MobileNo' => $input[$i++],
			'Email' => $input[$i++],
			'FName' => $input[$i++],
			'Lname' => $input[$i++],
			'IDCard' => $input[$i++], // th only
			'Passport' => $input[$i++], // other only
		);

		return self::output($data);
	}

	public function insert_wifi_account($account_id,$package_id,$input)
	{

		$data=array(
			'', //'Prefix' => 
			'',//'Postfix' => 
			$input['tel'],//'MobileNo' => 
			$input['email'],//'Email' => 
			$input['first_name'],//'FName' => 
			$input['last_name'],//'Lname' => 
			'', // th only//'IDCard' => 
			'', // other only//'Passport' => 
		);

		$result = self::create_wifi_account($package_id,$data);

		$account = $result['Accounts'][0];

		$insert = array(
				'account_id' => $account_id,
				'package_id' => $package_id,
				'username' => $account['Username'],
				'password' => $account['<PASSWORD>'],
				'expire_date' => $account['ExpireDate'],
				'cdate' => DATETIME,
				'mdate' => DATETIME
			);

		return $insert;
		
	}

/*
 Protected
*/

	protected function set_package()
	{
		$data = array(
			'Interface' => 'CloudPOS',
			'Command' => '4400',
			'Channel' => 'POS',
			'Version' => '1.0',
			'IP' => '192.168.1.1',
			'PosUsername' => '<EMAIL>',
			'PosPassword' => '<PASSWORD>',
		);

		return self::output($data);	
	}

	protected function output($data)
	{
		$data_string = json_encode($data);
		//$ch = curl_init('http://11.11.11.18/mediator/');
		$ch = curl_init('http://172.16.17.32:81/mediator/');
		curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
		curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
		//curl_setopt($ch, CURLOPT_PORT, 81);
		curl_setopt($ch, CURLOPT_HTTPHEADER,
		        array(
		                'Content-Type: application/json', 'Content-Length: '
		                . strlen($data_string)
		        ));

		$result = curl_exec($ch);
		if (curl_errno($ch)) {
			die(curl_errno($ch));
		}

		return json_decode($result, TRUE);
	}
	
}

<file_sep>/modules/send_midterm/index.php
<div class="container set-content-pad-20" >
  <div class="bg-whte" style="position: relative;padding-bottom: 60px">
    <div class="circle-bg-violet">
      <img class="head-img-circle" src="assets/images/03.png">
    </div>
    <div class="text-head-title">
      <p>ส่งผลการเรียนกลางปี</p>
    </div>
    <div class="text-head-desc">
      <p>สรุปการประเมินผลการเรียน การประเมินคุณลักษณะอันพึงประสงค์ และการประเมินการอ่าน คิดวิเคราะห์ และเขียน</p>
    </div>
    <div class="row pd-50 pt-60 stage-set" >                  
                      
    </div>

    <div class=" ml-50 mr-50" >
      <div class="row">
        <ul class="nav nav-tabs" role="tablist">
          <?php if ($_SESSION['ss_status']==1){ ?>   
          <li role="presentation" class="active"><a class="text-black" href="#all_sub_tab" aria-controls="all_sub_tab" role="tab" data-toggle="tab">ส่งผลการเรียน</a></li>
          <li role="presentation"><a class="text-black" href="#registed_tab" aria-controls="registed_tab" role="tab" data-toggle="tab">รายวิชาที่ส่งผลการเรียนแล้ว</a></li>
          <?php }else{ ?>
          <li role="presentation" class="active"><a class="text-black" href="#all_sub_tab" aria-controls="all_sub_tab" role="tab" data-toggle="tab">ส่งผลการเรียน</a></li>
          <li role="presentation"><a class="text-black" href="#registed_tab" aria-controls="registed_tab" role="tab" data-toggle="tab">รายวิชาที่ส่งผลการเรียนแล้ว</a></li>
            <li role="presentation" ><a class="text-black" href="#teacher_tab" aria-controls="teacher_tab" role="tab" data-toggle="tab">ยกเลิกการส่งผลการเรียน</a></li>
          <?php } ?>

        </ul>
      </div>
       <div class="tab-content">
        <?php if ($_SESSION['ss_status']==1){ ?>   
        <div role="tabpanel" class="tab-pane fade <?php if ($_SESSION['ss_status']==1){ echo "in active";} ?>" id="all_sub_tab">
          <div class="row mt-30" ">
            <div class="text-title-table">
              <h4 class="text-bold">ส่งผลการเรียน</h4>
            </div>
          </div>
          <div class="row">
            <div class="col-sm-6">       
              <p class="text-search" style="font-weight: bold;">ปีการศึกษา</p>
              <p class="text-search" style="margin-left: 5px;font-weight: bold;">2560</p>   
        
             <!-- <div style="padding: 5px;height: 25px;background-color: #ac68cc;float: left;margin-top: -2px ">
                    <span class="glyphicon glyphicon-search" aria-hidden="true"></span>
              </div>-->
            </div> 

          </div>
          <div class="row mt-10">
            <div class="col-md-12">
              <div class="table-responsive">
                <table class="table table-striped-violet" >
                  <thead class="header-table">
                    <tr>
                      <th><input id="checkbox_all" type="checkbox"></th>
                      <th style="text-align: left;">รหัสวิชา</th>
                      <th style="text-align: left;">รายวิชา</th>
                      <th>ระดับชั้น</th>
                      <th>ห้อง</th>
                    </tr>
                  </thead>
                  <tbody id="table_list" class="body-table">

                  </tbody>
                </table> 
              </div>
            </div>                                     
          </div>   
            <div id="btn_cancel_checked" class="btn-grey">
              ยกเลิก
            </div>    
            <div data-toggle="modal" data-target="#modalAddPp6" class="btn-violet">
              ยืนยัน
            </div>      
        </div>
        <div role="tabpanel" class="tab-pane fade " id="registed_tab">
          <div class="row mt-30" ">
            <div class="text-title-table">
              <h4 class="text-bold">รายวิชาที่ส่งผลการเรียนแล้ว</h4>
            </div>
          </div>
 
          <div class="row mt-10">
            <div class="col-md-12">
              <div class="table-responsive">
                <table class="table table-striped-violet" >
                  <thead class="header-table">
                    <tr>
                      <th></th>
                      <th style="text-align: left;">รหัสวิชา</th>
                      <th style="text-align: left;">รายวิชา</th>
                      <th>ระดับชั้น</th>
                      <th>ห้อง</th>
                    </tr>
                  </thead>
                  <tbody id="table_list_added" class="body-table">

                  </tbody>
                </table> 
              </div>
            </div>                                     
          </div> 
        </div>

      <?php  }else if($_SESSION['ss_status']==2){ ?>
        <div role="tabpanel" class="tab-pane fade in active" id="all_sub_tab">
          <div class="row mt-30" ">
            <div class="text-title-table">
              <h4 class="text-bold">ส่งผลการเรียน</h4>
            </div>
          </div>
          <div class="row">
            <div class="col-sm-6">       
             <form id="frm_data_search_reiged_send">                 
              <p class="text-search" >ภาคเรียนที่</p>
                <select name="data_term_search" id="data_term_search_send" class="form-control search-years-registed">
                  <option value="1">1</option>
                  <option value="2">2</option>
                  <option value="1,2">1,2</option>

                </select> 
                <p class="text-search ml-10" >ปีการศึกษา</p>
                <select name="data_year_search" id="year_data_sum_send" class="form-control search-years-registed data_year_search">

                </select>
                <div class="btn-years-registed" >
                  <div id="get_coures_id_list_send" class="btn-search "><span class="glyphicon glyphicon-search" aria-hidden="true"></span></div> 
                </div>
              </form>       

            </div> 
          </div>
          <div class="row mt-10">
            <div class="col-md-12">
              <div class="table-responsive">
                <table class="table table-striped-violet" >
                  <thead class="header-table">
                    <tr>
                      <th><input id="checkbox_all" type="checkbox"></th>
                      <th style="text-align: left;">รหัสวิชา</th>
                      <th style="text-align: left;">รายวิชา</th>
                      <th>ระดับชั้น</th>
                      <th>ห้อง</th>
                    </tr>
                  </thead>
                  <tbody id="table_list_send" class="body-table">

                  </tbody>
                </table> 
              </div>
            </div>                                     
          </div>   
            <div id="btn_cancel_checked" class="btn-grey">
              ยกเลิก
            </div>    
            <div data-toggle="modal" data-target="#modalAddPp6" class="btn-violet">
              ยืนยัน
            </div>      
        </div>
        <div role="tabpanel" class="tab-pane fade " id="registed_tab">
          <div class="row mt-30" ">
            <div class="text-title-table">
              <h4 class="text-bold">รายวิชาที่ส่งผลการเรียนแล้ว</h4>
            </div>
          </div>
 
          <div class="row mt-10">
            <div class="col-md-12">
              <div class="table-responsive">
                <table id="table_added" class="table table-striped-violet" >
                  <thead class="header-table">
                    <tr>
                      <th></th>
                      <th style="text-align: left;">รหัสวิชา</th>
                      <th style="text-align: left;">รายวิชา</th>
                      <th>ระดับชั้น</th>
                      <th>ห้อง</th>
                      <th>วันที่</th>
                    </tr>
                  </thead>
                  <tbody id="table_list_added" class="body-table">

                  </tbody>
                </table> 
              </div>
            </div>                                     
          </div> 
        </div>
        <div role="tabpanel" class="tab-pane fade " id="teacher_tab">
          <div class="row mt-30" ">
            <div class="text-title-table">
              <h4 class="text-bold">ยกเลิกการส่งผลการเรียน</h4>
            </div>
          </div>
          <div class="row">
             <div class="col-sm-6">       
             <form id="frm_data_search_reiged_edit">                 
              <p class="text-search" >ภาคเรียนที่</p>
                <select name="data_term_search" id="data_term_search" class="form-control search-years-registed">
                  <option value="1">1</option>
                  <option value="2">2</option>
                  <option value="1,2">1,2</option>
                </select> 
                <p class="text-search ml-10" >ปีการศึกษา</p>
                <select name="data_year_search" id="year_data_sum" class="form-control search-years-registed data_year_search">

                </select>
                <div class="btn-years-registed" >
                  <div id="btn_data_year_search_edit" class="btn-search "><span class="glyphicon glyphicon-search" aria-hidden="true"></span></div> 
                </div>
              </form>   
              

            </div>         
          </div>
          <div class="row mt-10">
            <div class="col-md-12">
              <div class="table-responsive">
                <table class="table table-striped-violet" >
                  <thead class="header-table">
                    <tr>
                      <th></th>
                      <th style="text-align: left;">รหัสวิชา</th>
                      <th style="text-align: left;">รายวิชา</th>
                      <th>ระดับชั้น</th>
                      <th>ห้อง</th>
                      <th>ยกเลิก</th>
                    </tr>
                  </thead>
                  <tbody id="table_list_edit" class="body-table">

                  </tbody>
                </table> 
              </div>
            </div>                                     
          </div> 
        </div>
      <?php } ?>
       </div>
  </div>
</div><file_sep>/modules/authen_user/from.js
document.writeln('<script type="text/javascript" src="assets/js/texteditor/texteditor.js"></script>');
document.writeln("<link href='assets/plugins/bootstrap3-wysihtml5/bootstrap3-wysihtml5.min.css' rel='stylesheet' type='text/css' />");
// document.writeln("<script type='text/javascript'  src='http://bp.yahooapis.com/2.4.21/browserplus-min.js'></script>");
document.writeln("<script type='text/javascript'  src='assets/js/plupload/js/plupload.js'></script>");
document.writeln("<script type='text/javascript'  src='assets/js/plupload/js/plupload.gears.js'></script>");
document.writeln("<script type='text/javascript'  src='assets/js/plupload/js/plupload.silverlight.js'></script>");
document.writeln("<script type='text/javascript'  src='assets/js/plupload/js/plupload.flash.js'></script>");
document.writeln("<script type='text/javascript'  src='assets/js/plupload/js/plupload.browserplus.js'></script>");
document.writeln("<script type='text/javascript'  src='assets/js/plupload/js/plupload.html4.js'></script>");
document.writeln("<script type='text/javascript'  src='assets/js/plupload/js/plupload.html5.js'></script>");
document.writeln("<script type='text/javascript'  src='modules/authen_user/upload_boxIV.js'></script>");
document.writeln("<script type='text/javascript'  src='modules/authen_user/upload_award.js'></script>");

var opPage = 'authen_user';
var url_process = 'modules/' + opPage + '/process.php'

var data_id = (typeof _get.id === 'undefined') ? 0 : _get.id;

$(document).ready(function() {
    get_role_list();
    get_data();
    tasks_list();
    get_thumb();
}); 

function get_data(){
	var formData = new Array();
	formData.push({ "name": "acc_action", "value": "get_data_from" }); 
	formData.push({ "name": "data_id", "value": data_id}); 

	$.getJSON(url_process, formData, function(data, textStatus) {
		// alert(data.role_id);
		$('#username').val(data.username);
		$('#first_name').val(data.first_name);
		$('#last_name').val(data.last_name);
		$('#role_id').select2("val",data.role_id); 
		$('#data_status').select2("val",data.status);
	});
	
}


function get_role_list(){
	var formData = new Array();
	formData.push({ "name": "acc_action", "value": "get_role_list" }); 
	$.post(url_process, formData, function(data, textStatus, xhr) {
		$('#role_id').html(data);
	});
}


$(document).delegate('#btn__save', 'click', function(event) {
	var ath_tasks=$("input[name='checkbox_ath_tasks[]']:checked").map(function(n){ if(this.checked){return  this.value;}; }).get().join(',');
	var formData = $( "#frm_data" ).serializeArray();
	formData.push({ "name": "acc_action", "value": "save_data" }); 
	formData.push({ "name": "data_id", "value": data_id}); 
	formData.push({ "name": "ath_tasks", "value": ath_tasks}); 
	$.post(url_process, formData, function(data, textStatus, xhr) {
		window.location = 'index.php?op=authen_user-index&data=success';
	});
});



function tasks_list(){
	var formData = new Array();
	formData.push({ "name": "acc_action", "value": "get_tasks_list" }); 
	formData.push({ "name": "data_id", "value": _get.id}); 
	$.post('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {
		$('.tasks_list').html(data.tasks_list);
	},'JSON');	
}

$(document).delegate('#role_id', 'change', function(event) {
	get_role_reletion_tasks($(this).val());
});

function get_role_reletion_tasks(role_id){
	var formData = new Array();
	formData.push({ "name": "acc_action", "value": "get_role_reletion_tasks" }); 
	formData.push({ "name": "role_id", "value": role_id}); 
	$.post(url_process, formData, function(data, textStatus, xhr) {

		$('.checkbox_data').each(function() { //loop through each checkbox
            this.checked = false; //deselect all checkboxes with class "checkbox1"                       
        }); 
	    $.each(data.task_id, function(k, v) {
	    	$('#ath_tasks_'+v).attr('checked', true);
	    });
	},'json');	
}



<file_sep>/src/#1class.userauthen.php
<?php

// API authen

class UserAuthen 
{
	var $DB;
	var $BY;
	
	var $ss_user_menu;
	var $ss_user_task;
	
	public function __construct()
	{
		$this->DB = new Databases();
		
		$this->BY = ($_SESSION['ssADMIN_ID'])? $_SESSION['ssADMIN_ID']: null;
		$this->ss_user_menu = ($_SESSION['ssADMIN']['MENU'])? $_SESSION['ssADMIN']['MENU']: null;
		$this->ss_user_task = ($_SESSION['ssADMIN']['TASK'])? $_SESSION['ssADMIN']['TASK']: null;
		
		if($this->BY){
			self::result_authentication();
		}
	}
	
	public function __escape($inputVar)
	{
		return mysql_real_escape_string(addslashes(htmlentities($inputVar, ENT_QUOTES))); 	
	}
	
	public function login( $user=null, $pass=null )
	{
		$where = ' where ';
		$where .= ' a.username = "'.self::__escape($user).'" and a.password = "'.self::__escape($pass).'"';
		
		$this->DB->sql = 'select a.*,a.status as status1,b.role_name,b.status as status2 from ath_users as a left join ath_roles as b on (a.role_id=b.role_id) '. $where .' limit 0,1 ';
		$this->DB->select();
		$result = $this->DB->getRows();
		if($result){

			if( $result[0][status1] != 1 ){
				return 1;
			}
			if( $result[0][status2] != 1 ){
				return 2;
			}

			return $result[0];
		}
		return 0;
		
	}

	public function reLogin( $id )
	{
		$where = ' where ';
		$where .= ' a.user_id = '.self::__escape($id).' and a.status=1 and b.status=1 ';
		
		$this->DB->sql = 'select a.*,b.role_name from ath_users as a left join ath_roles as b on (a.role_id=b.role_id) '. $where .' limit 0,1 ';
		$this->DB->select();
		$result = $this->DB->getRows();
		if($result){
			return $result[0];
		}
		return null;
		
	}

	public function task( $task_key=null )
	{

		$data = array();
		if($_SESSION['ssADMIN']['TASK']){
			$data = $_SESSION['ssADMIN']['TASK'];
		}		
		else{
			$result = self::result_authentication();
			$data = $result['task'];
		}		
		
		if($data[$task_key]){
			return true;
		}
		else{
			return false;
		}
	}
	
	public function menu_authen()
	{	
		$data = array();
		if($_SESSION['ssADMIN']['MENU']){
			$data = $_SESSION['ssADMIN']['MENU'];
		}		
		else{
			$result = self::result_authentication();
			$data = $result['menu'];
		}		
		return $data;
	}
	
	protected function result_authentication()
	{
		if( $_SESSION['ssADMIN']['MENU'] && $_SESSION['ssADMIN']['TASK'] ){
			return true;
		}
	
		$this->DB->sql = 'SELECT a.fun_id,a.task_id,a.task_key FROM ath_tasks as a LEFT JOIN ath_user_reletion_tasks as b on(a.task_id=b.task_id) WHERE b.user_id='.$this->BY;
		$this->DB->select();
		$result = $this->DB->getRows();
		
		$fun_data = array();
		$task_data = array();
		$data = array();
		if($result){
			foreach( $result as $rs ){
				$fun_id = $rs['fun_id'];
				$task_key = $rs['task_key'];
			
				$fun_data[$fun_id] = $fun_id;
				$task_data[$task_key] = $rs['task_id'];
			}
			$data['menu'] = $fun_data;
			$data['task'] = $task_data;
			
		}
		$_SESSION['ssADMIN']['MENU'] = $fun_data;
		$_SESSION['ssADMIN']['TASK'] = $task_data;
		
		return $data;		
	}
	
	public function view_tasks()
	{
		$result = self::ath_tasks();
		if(!$result){
			return false;
		}
		// Result
		foreach( $result as $rs ){
			$data[$rs['task_key']] = $rs['task_description'];
		}		
		return $data;
	}
	
	/* public function logout( $url=null )
	{
		// unset
		unset($_SESSION);
		// location
		if($url){
			header('location:'.$url);
		}
		return true;
	} */

	public function update_last_login($id)
	{
		if($id){
			/* $update = array();
			$update['mdate'] = DATETIME;
			
			$where = array();
			$where['user_id'] = $id; */
			
			$this->DB->sql = 'UPDATE ath_users set mdate="'.DATETIME.'" where user_id='.$id;
			$this->DB->update();
			//$this->DB->update( 'ath_users', $update, $where);
		}
	}

// ==================================================================================
	
	/* protected */

	protected function ath_main_function()
	{
	
		$this->DB->sql = 'select * from ath_main_function where status=1 ';
		$this->DB->select();
		$result = $this->DB->getRows();
		
		return $result;	
	}
	
	protected function ath_tasks($key=null)
	{
		$where = null;
		if($key){
			$where = ' where ';
			$where .= ' task_key = "'.self::__escape($key).'" ';
		}
		
		$this->DB->sql = 'select * from ath_tasks '. $where;
		$this->DB->select();
		$result = $this->DB->getRows();
		
		if($key){
			return $result[0];	
		}
		else{
			return $result;	
		}
		
	}
	
}

<file_sep>/modules/graduate/index.js
var opPage = 'graduate';
$(document).ready(function() {
	get_year();
	
}); 
function get_std_list() {
	var formData = $( "#frm_data_search" ).serializeArray();
	formData.push({ "name": "acc_action", "value": "get_std_list" }); 
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {
		$("#table_std_list").html(data.std_list);		
	})
}
function get_year() {
	var formData = new Array();
	formData.push({ "name": "acc_action", "value": "get_year" }); 
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {
		$("#year_search").html(data.year);
		get_std_list();		
	})
}
$(document).delegate('#btn_search_std_list', 'click', function(event) {
	get_std_list();
});

 $(document).delegate('#checkbox_all', 'click', function(event) {
	if(this.checked) { // check select status
        $('.checkbox_data').each(function() { //loop through each checkbox
            this.checked = true;  //select all checkboxes with class "checkbox1"               
        });
    }else{
        $('.checkbox_data').each(function() { //loop through each checkbox
            this.checked = false; //deselect all checkboxes with class "checkbox1"                       
        });         
    }
});
$(document).delegate('#btn__conf_add', 'click', function(event) {
	var tempValue=$("input[name='checkbox_add[]']:checked").map(function(n){ if(this.checked){return  this.value;}; }).get().join(',');
	var formData = new Array();

	formData.push({ "name": "acc_action", "value": "data_add" }); 
	formData.push({ "name": "data_val", "value": tempValue}); 
	$.post('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {
		tempValue='';
		get_std_list();
		$('.modal').modal('hide');
	})
});

$(document).delegate('#btn_edit_status', 'click', function(event) {
 	var class_room_modal_id = $('#status_modal_id').val();
 	var status_val = $('#status_modal').val();

 	var formData = new Array();
	formData.push({ "name": "acc_action", "value": "edit_status" }); 
	formData.push({ "name": "class_room_modal_id", "value": class_room_modal_id });
	formData.push({ "name": "status_val", "value": status_val });  
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {
		get_std_list();
		$('.modal').modal('hide');
		status_val='';
		class_room_modal_id='';
	});
});
 $(document).delegate('.btn_getdata_edit', 'click', function(event) {
 	var data_id = $(this).attr('data-id');
 	var formData = new Array();
	formData.push({ "name": "acc_action", "value": "getdata_edit" }); 
	formData.push({ "name": "data_id", "value": data_id }); 
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {
		$('#status_modal').val(data.status);
		$('#status_modal_id').val(data_id);
		data_id='';
	});
});<file_sep>/includes/class_modules.php
<?php 

class ClassData extends Databases {
	
	public function get_img_tab(){
		$data_response = array();
		$user_id=$_SESSION['ss_user_id'];
		$sql = "SELECT * 
				FROM tbl_regis_teacher_gallery
				WHERE regis_teacher_id= '$user_id'
				";
		$this->sql = $sql;
		$this->select();
		$this->setRows();
		$FileName= unchkhtmlspecialchars($this->rows[0]['FileName']);	

		if (isset($_SESSION['ss_status_std']) && $_SESSION['ss_status_std']==1) {
			$data_response['get_img_tab'] = '<img class="user-profile" src="assets/images/per.png" >';
		}else{
			if ($FileName=='') {
				$data_response['get_img_tab'] = '<img class="user-profile" src="assets/images/per.png" >';
			}else{
				$data_response['get_img_tab'] = '<img class="user-profile" src="file_managers/profile/'.$FileName.'" >';
			}
			
		}
		return json_encode($data_response);
	}
	public function get_name_tab(){
		$user_id=$_SESSION['ss_user_id'];
		$data_response = array();
		if (isset($_SESSION['ss_status_std']) && $_SESSION['ss_status_std']==1) {
			$sql = "SELECT * 
				FROM tbl_student
				WHERE std_ID= '$user_id'
				";
			$this->sql = $sql;
			$this->select();
			$this->setRows();
			$fname_th= unchkhtmlspecialchars($this->rows[0]['fname']);
			$lname_th= unchkhtmlspecialchars($this->rows[0]['lname']);
		}else{
			$sql = "SELECT * 
				FROM tbl_regis_teacher
				WHERE DataID= '$user_id'
				";
			$this->sql = $sql;
			$this->select();
			$this->setRows();
			$fname_th= unchkhtmlspecialchars($this->rows[0]['fname_th']);
			$lname_th= unchkhtmlspecialchars($this->rows[0]['lname_th']);
		}
		
		
		$data_response['full_name_th'] = $fname_th.' '.$lname_th;
		return json_encode($data_response);
	}

}

?><file_sep>/modules/conclusion/process.php
<?php 
@session_start();

require_once('../../init.php');
include('../../src/class.pagination.php');
include('../../src/class.inputfilter.php');
$InputFilter = new InputFilter();

##CLASS_DB_CONNECT##
include('class_modules.php');
$class_data = new ClassData();
##CLASS_DB_CONNECT##

if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_data_list_learning"){	
	$class_level=$_GET['class_level'];
	$room_data=$_GET['room_data'];
	$term_data=$_GET['term_data'];
	$year_data=$_GET['year_data'];
	echo $class_data->get_data_list_learning($class_level,$room_data,$term_data,$year_data);
}

if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_data_list_department"){	
	$class_level=$_GET['class_level'];
	$term_data=$_GET['term_data'];
	$year_data=$_GET['year_data'];
	$department_search=$_GET['department_search'];
	
	echo $class_data->get_data_list_department($class_level,$term_data,$year_data,$department_search);
}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_data_list_level"){	
	$class_level=$_GET['class_level'];
	$term_data=$_GET['term_data'];
	$year_data=$_GET['year_data'];
	echo $class_data->get_data_list_level($class_level,$term_data,$year_data);
}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_data_list_desirable"){	
	$class_level=$_GET['class_level'];
	$term_data=$_GET['term_data'];
	$year_data=$_GET['year_data'];
	echo $class_data->get_data_list_desirable($class_level,$term_data,$year_data);
}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_data_list_rtw"){	
	$class_level=$_GET['class_level'];
	$term_data=$_GET['term_data'];
	$year_data=$_GET['year_data'];
	echo $class_data->get_data_list_rtw($class_level,$term_data,$year_data);
}

if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_year"){	
	echo $class_data->get_year();
}<file_sep>/modules/news/upload.php
<?php
@ob_start();
@session_start();

require_once('../../init.php');
include('../../src/class.pagination.php');
include('../../src/class.inputfilter.php');
$InputFilter = new InputFilter();

##CLASS_DB_CONNECT##
include('class_modules.php');
$class_data = new ClassData();
##CLASS_DB_CONNECT##
		$arr_sql["title"]="'".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['title'])))."'";	
		$arr_sql["detail"]="'".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['detail'])))."'";	
		$arr_sql["author"]="'".$_SESSION['ss_user_id']."'";
		$arr_sql["date"]="'".date("Y-m-d")."'";
		$news_id= $class_data->insert_news($arr_sql);	
		for ($i=1; $i <= 5 ; $i++) { 
			if ($i==1) {
				if(is_uploaded_file($_FILES["img$i"]['tmp_name'])) {

					$ext=pathinfo(basename($_FILES["img$i"]['name']),PATHINFO_EXTENSION);			
						$new_file='file_'.uniqid().".".$ext;
						$oldFileName=$_FILES["img$i"]['name'];

						$sourcePath = $_FILES["img$i"]['tmp_name'];
						$targetPath = "../../file_managers/news/".$new_file;
						$upload=move_uploaded_file($sourcePath,$targetPath);
						if ($upload==false) {
							echo "no";
							exit();
						}
						$class_data->sql="INSERT INTO tbl_news_gallery(newsID,file_name) 
						VALUES($news_id,'$new_file')";
						$class_data->query();
						$new_id= $class_data->insertID();	 
						
								
				}
			}else{
				if(is_uploaded_file($_FILES["img$i"]['tmp_name'])) {

					$ext=pathinfo(basename($_FILES["img$i"]['name']),PATHINFO_EXTENSION);			
						$new_file='file_'.uniqid().".".$ext;
						$oldFileName=$_FILES["img$i"]['name'];

						$sourcePath = $_FILES["img$i"]['tmp_name'];
						$targetPath = "../../file_managers/news_sub/".$new_file;
						$upload=move_uploaded_file($sourcePath,$targetPath);
						if ($upload==false) {
							echo "no";
							exit();
						}
						$class_data->sql="INSERT INTO tbl_news_gallery_sub(newsID,file_name) 
						VALUES($news_id,'$new_file')";
						$class_data->query();
						$new_id= $class_data->insertID();	 
						
								
				}
			}
				
		}
header("location:../../index.php?op=news-index"); 	

<file_sep>/modules/mobile_api/newsheighlight.php
<?php	
	@session_start();

	require_once('config.php');
	require_once('src/database.php');
	include('class_modules.php');
	$class_data = new ClassData();
	##CLASS_DB_CONNECT##
	$condition = false;
	$num=  $class_data->rows[0]['num'];		
	$json = json_decode(file_get_contents('php://input'), true);
	$newsheighlight=$json['newsheighlight'];
	$token=$json['token'];
	$token_set='4939d40bd21d4b987edc18a1911a6b94';
	if (MD5($token)==$token_set) {
		if (!empty($newsheighlight) ) {
	        //$sql = "SELECT DataID,title,detail,date FROM tbl_news WHERE DataID in(SELECT MAX(DataID) FROM tbl_news)";
	        $sql = "SELECT DataID,title,detail,date FROM tbl_news ORDER BY date DESC";
			$class_data->sql = $sql;
			$class_data->select();
	        $class_data->setRows();
	        
	        $DataID=$class_data->rows[0]['DataID'];
	       
	        $data_res['DataID']=$DataID;
	        
			$data_res['title']=strip_tags(htmlspecialchars_decode($class_data->rows[0]['title']));
	        $data_res['detail']=strip_tags(htmlspecialchars_decode($class_data->rows[0]['detail']));
	        $date_set=$class_data->rows[0]['date'];
	        $old_form_date = strtotime($date_set);
	        $data_res['date']=date('d-m-Y', $old_form_date); 
	        $data_res['status']=1;

	        $sql = " SELECT file_name FROM tbl_news_gallery WHERE newsID=$DataID";
	        $class_data->sql =$sql;
	        $class_data->select();
	        $class_data->setRows();
	        
	        $data_res['img_url']='/file_managers/news/'.$class_data->rows[0]['file_name'];
	   
	        
		}else{
	        $data_res['status']=0;
	    }
	}
	echo json_encode($data_res);

   

 ?>
<file_sep>/src/config.php
<?php
	@header( 'Pragma: no-cache' );
	@header( 'Content-Type:text/html;arset=utf-8');
	date_default_timezone_set('Asia/Bangkok');
	$config['page_title'] = "iwind.co.th";
	$config['web_name'] = "iwind.co.th";
	$config['ip_address'] = ipCheck();
	$config['date_now'] = date('Y-m-d H:i:s');
	$config['referrer_page'] = (@eregi($_SERVER["HTTP_HOST"], str_replace("www.", "", strtolower($_SERVER["HTTP_REFERER"])))) ? 1 : 0; //[1]=yes / [0]=no
	
	/*Database Connect *************************************************************/
	define("HostName","localhost");
	define("DBName","tapma_db");
	
	define("DBUsername","tapma_admin");
	define("DBPassword","<PASSWORD>");	
	
	//offline
	//define("HostName","localhost");
	//define("DBName","japan_db");
	
	//define("DBUsername","root");
	//define("DBPassword","<PASSWORD>");	
	
	// Open the base (construct the object):
	$db = new DB(DBName, HostName, DBUsername, DBPassword);

	// Admin Config
	$ADMIN_ID = $_SESSION['ssADMIN_ID'];
	$result = $db->query("SELECT * FROM tbl_admin WHERE admin_id='{$ADMIN_ID}'");
	$line = $db->fetchNextObject($result);
	$PM_LEVEL = $line->LEVEL;
	$ARR_PM_BANNER = explode(",", "1,1,1");//explode(",", $line->PM_BANNER); // [insert],[edit],[remove],[review],[show index],[sequence]
	$ARR_PM_NEWS_ACTIVITY = explode(",", "1,1,1");//explode(",", $line->PM_NEWS_ACTIVITY); // [insert],[edit],[remove],[review],[show index],[sequence]
?><file_sep>/src/class.userauthen.php
<?php

// API authen

class UserAuthen 
{
	var $DB;
	var $BY;
	
	var $ss_user_menu;
	var $ss_user_task;
	
	public function __construct()
	{
		$this->DB = new Databases();
		
		$this->BY = ($_SESSION['ssADMIN_ID'])? $_SESSION['ssADMIN_ID']: null;
		$this->ss_user_menu = ($_SESSION['ssADMIN']['MENU'])? $_SESSION['ssADMIN']['MENU']: null;
		$this->ss_user_task = ($_SESSION['ssADMIN']['TASK'])? $_SESSION['ssADMIN']['TASK']: null;
		
		if($this->BY){
			self::result_authentication();
		}
	}
	
	public function __escape($inputVar)
	{
		return mysql_real_escape_string(addslashes(htmlentities($inputVar, ENT_QUOTES))); 	
	}

	public function ldap_connection($ldaprdn,$ldappass)
	{
		$ldaphost =   'LDAP://scbwadc01.thaibev.com';
		//$ldaprdn  = 'i1026573';
		//$ldappass = '<PASSWORD>'; // 'P@ssw0rd'; // '  
		$domain='thaibev';
		$port=389;

		$ldapconn = ldap_connect($ldaphost, $port)
		or die("Could not conenct to {$host}");

		if ($ldapconn) {

		//echo "$ldapconn, $ldaprdn@$domain, $ldappass <p>" ;
			$bind=@ldap_bind($ldapconn, $ldaprdn .'@' .$domain, $ldappass);

			if ($bind) {
				return 1;
			    //echo("Login correct");
			} else {
				return 4;
			    //echo("Login incorrect");
			}
		}

		return 3;
	}
	
	public function login( $user=null, $pass=null )
	{

		$where = ' where ';
		$where .= ' a.username = "'.self::__escape($user).'" and a.status=1 and b.status=1 ';
		//$where .= ' a.username = "'.self::__escape($user).'" and a.password = "'.self::__escape($pass).'"';
		
		$this->DB->sql = 'select a.*,a.status as status1,b.role_name,b.status as status2 from ath_users as a left join ath_roles as b on (a.role_id=b.role_id) '. $where .' limit 0,1 ';
		$this->DB->select();
		$result = $this->DB->getRows();

		if($result){

			if( $result[0]['status1'] != 1 ){
				return 1;
			}
			if( $result[0]['status2'] != 1 ){
				return 2;
			}

			if($user!='c1000475'){
				// LDAP Connection 
				$check_ldap = self::ldap_connection($user,$pass);
				if( $check_ldap != 1 ){
					return $check_ldap; // connection or user , pass fail 
				}
			}else{
				return $result[0];
			}

			return $result[0];
		}
		return 0;
		
	}

	public function reLogin( $id )
	{
		$where = ' where ';
		$where .= ' a.user_id = '.self::__escape($id).' and a.status=1 and b.status=1 ';
		
		$this->DB->sql = 'select a.*,b.role_name from ath_users as a left join ath_roles as b on (a.role_id=b.role_id) '. $where .' limit 0,1 ';
		$this->DB->select();
		$result = $this->DB->getRows();
		if($result){
			return $result[0];
		}
		return null;
		
	}

	public function task( $task_key=null )
	{

		$data = array();
		if($_SESSION['ssADMIN']['TASK']){
			$data = $_SESSION['ssADMIN']['TASK'];
		}		
		else{
			$result = self::result_authentication();
			$data = $result['task'];
		}		
		
		if($data[$task_key]){
			return true;
		}
		else{
			return false;
		}
	}
	
	public function menu_authen()
	{	
		$data = array();
		if($_SESSION['ssADMIN']['MENU']){
			$data = $_SESSION['ssADMIN']['MENU'];
		}		
		else{
			$result = self::result_authentication();
			$data = $result['menu'];
		}		
		return $data;
	}
	
	protected function result_authentication()
	{
		if( $_SESSION['ssADMIN']['MENU'] && $_SESSION['ssADMIN']['TASK'] ){
			return true;
		}
	
		$this->DB->sql = 'SELECT a.fun_id,a.task_id,a.task_key FROM ath_tasks as a LEFT JOIN ath_user_reletion_tasks as b on(a.task_id=b.task_id) WHERE b.user_id='.$this->BY;
		$this->DB->select();
		$result = $this->DB->getRows();
		
		$fun_data = array();
		$task_data = array();
		$data = array();
		if($result){
			foreach( $result as $rs ){
				$fun_id = $rs['fun_id'];
				$task_key = $rs['task_key'];
			
				$fun_data[$fun_id] = $fun_id;
				$task_data[$task_key] = $rs['task_id'];
			}
			$data['menu'] = $fun_data;
			$data['task'] = $task_data;
			
		}
		$_SESSION['ssADMIN']['MENU'] = $fun_data;
		$_SESSION['ssADMIN']['TASK'] = $task_data;
		
		return $data;		
	}
	
	public function view_tasks()
	{
		$result = self::ath_tasks();
		if(!$result){
			return false;
		}
		// Result
		foreach( $result as $rs ){
			$data[$rs['task_key']] = $rs['task_description'];
		}		
		return $data;
	}
	
	/* public function logout( $url=null )
	{
		// unset
		unset($_SESSION);
		// location
		if($url){
			header('location:'.$url);
		}
		return true;
	} */

	public function update_last_login($id)
	{
		if($id){
			/* $update = array();
			$update['mdate'] = DATETIME;
			
			$where = array();
			$where['user_id'] = $id; */
			
			$this->DB->sql = 'UPDATE ath_users set mdate="'.DATETIME.'" where user_id='.$id;
			$this->DB->update();
			//$this->DB->update( 'ath_users', $update, $where);
		}
	}

	public function insert_log($username,$message,$status=0)
	{
		$insert = array();
		$insert['username'] = $username;
		$insert['ip'] = $_SERVER['REMOTE_ADDR'];
		$insert['status'] = $status;
		$insert['message'] = $message;
		$insert['cdate'] = date('Y-m-d H:i:s');

		self::this_insert('ath_log_login',$insert);
	}
// Timestamp Or Session

	public function checkedTimestamp()
	{
		$where = 'session_id="'.session_id().'"';
		$this->DB->sql = 'select * from ath_log_timestamp where '.$where.' LIMIT 0,1 ';
		$this->DB->select();
		$result = $this->DB->getRows();	
		if($result){
			return 1;
		}
		else{
			return 0;
		}
	}

	public function createTimestamp($user_id)
	{
		$where = 'user_id="'.$user_id.'"';
		$this->DB->sql = 'select * from ath_log_timestamp where '.$where.' LIMIT 0,1 ';
		$this->DB->select();
		$result = $this->DB->getRows();		
		if($result){
			// update
			self::updateTimestamp($user_id);
		}
		else{
			// insert
			self::insertTimestamp($user_id);
		}
	}
	public function insertTimestamp($user_id)
	{
		$insert = array();
		$insert['user_id'] = $user_id;
		$insert['session_id'] = session_id();
		$insert['cdate'] = DATETIME;//date('Y-m-d H:i:s',strtotime(DATETIME.'+30 minute'));;
		
		self::this_insert('ath_log_timestamp',$insert);
		//$this->DB->_insert('ath_log_timestamp',$insert);
	}
	public function updateTimestamp($user_id)
	{
		$where = 'user_id="'.$user_id.'"';

		$update = array();
		$update['session_id'] = session_id();
		$update['cdate'] = DATETIME;//date('Y-m-d H:i:s',strtotime(DATETIME.'+30 minute'));;
		
		self::this_update('ath_log_timestamp',$update,$where);
		//$this->DB->_update('ath_log_timestamp',$update,$where);
	}

// ==================================================================================
	
	/* protected */

	protected function ath_main_function()
	{
	
		$this->DB->sql = 'select * from ath_main_function where status=1 ';
		$this->DB->select();
		$result = $this->DB->getRows();
		
		return $result;	
	}
	
	protected function ath_tasks($key=null)
	{
		$where = null;
		if($key){
			$where = ' where ';
			$where .= ' task_key = "'.self::__escape($key).'" ';
		}
		
		$this->DB->sql = 'select * from ath_tasks '. $where;
		$this->DB->select();
		$result = $this->DB->getRows();
		
		if($key){
			return $result[0];	
		}
		else{
			return $result;	
		}
		
	}
	

	protected function this_insert($table,$insert)
	{
		$keys = array_keys($insert);
		$values = array_values($insert);

		$field = @implode(",",$keys);
		$value_data = @implode("','",$values);

		$this->DB->sql = "INSERT INTO {$table}({$field}) VALUES('{$value_data}')";
		$this->DB->insert();
	}

	protected function this_update( $table=null, $data, $where=null)
	{

		$update = '';
		if( $data ){
			foreach($data as $k => $v){
				$update .= $k.'="'.$v.'",';
			}
			$update = substr($update, 0, -1);
		}

		if( $where ) $where = " WHERE ". $where;
		$this->DB->sql = "UPDATE {$table} SET {$update} {$where}";
		$this->DB->update();
	}
}

<file_sep>/modules/regis_student/class_modules.php
<?php 

class ClassData extends Databases {
	public function get_term_year_now(){
		$data_response = array();	
		$this->sql ="SELECT  *
					FROM tbl_set_term_year 				
							";
		$this->select();
		$this->setRows();

		$data_response['year']=$this->rows[0]['year'];
		$data_response['year_now']=date("Y")+543;
		$data_response['status_rang']=$_SESSION['ss_status_rang'];
		echo json_encode($data_response); 
	}
	public function chk_id($std_ID,$card_ID){
		$data_response = array();
		$sql = "SELECT count(*) as num_std_ID 
				FROM tbl_student
				WHERE std_ID='$std_ID'		
				";
		$this->sql = $sql;
		$this->select();
		$this->setRows();
		$data_response['num_std_ID']=unchkhtmlspecialchars($this->rows[0]['num_std_ID']);

		$sql = "SELECT count(*) as num_card_ID
				FROM tbl_student
				WHERE card_ID='$card_ID'		
				";
		$this->sql = $sql;
		$this->select();
		$this->setRows();
		$data_response['num_card_ID']=unchkhtmlspecialchars($this->rows[0]['num_card_ID']);

		return json_encode($data_response);
	}
	public function insert_data($insert,$arr_sql_class_room){
		$this->sql = "INSERT INTO tbl_student(".implode(",",array_keys($insert)).") VALUES (".implode(",",array_values($insert)).")";
		$this->query();
		$new_id = $this->insertID();
		$this->sql = "INSERT INTO tbl_std_class_room(".implode(",",array_keys($arr_sql_class_room)).") VALUES (".implode(",",array_values($arr_sql_class_room)).")";
		$this->query();
	}
	public function get_years(){
		$data_response = array();
		$years_now=intval(date("Y"));+
		$years_now=$years_now+543;
		for ($i=$years_now; $i >= 2480  ; $i--) { 
			$data_response['set_years'].='<option value="'.$i.'">'.$i.'</option>';
		}
		echo json_encode($data_response);
	}
	public function get_day($mouth){
		$data_response = array();
		
		for ($i=1; $i <= 29 ; $i++) { 
			$day_make_29.='<option value="'.$i.'">'.$i.'</option>';
		}
		for ($i=1; $i <= 30 ; $i++) { 
			$day_make_30.='<option value="'.$i.'">'.$i.'</option>';
		}
		for ($i=1; $i <= 31 ; $i++) { 
			$day_make_31.='<option value="'.$i.'">'.$i.'</option>';
		}
		if ($mouth==1 || $mouth==3 || $mouth==5 || $mouth==7 || $mouth==8 || $mouth==10 || $mouth==12) {
			$data_response['day_set']=$day_make_31;
		}elseif($mouth==4 || $mouth==6 || $mouth==9 || $mouth==11){
			$data_response['day_set']=$day_make_30;
		}else{
			$data_response['day_set']=$day_make_29;
		}

	echo json_encode($data_response);
	}
}<file_sep>/modules/up_class/index.js
var opPage = 'up_class';
$(document).ready(function() {
	get_year();
	get_data_upclassed();
}); 

function up_class_p2() {
	var formData = new Array();
	formData.push({ "name": "acc_action", "value": "up_class_p" });
	formData.push({ "name": "value_set", "value": 2 }); 
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) { $('#text_status_p2').css('display','block');up_class_p3(); });
}
function up_class_p3() {
	var formData = new Array();
	formData.push({ "name": "acc_action", "value": "up_class_p" });
	formData.push({ "name": "value_set", "value": 3 }); 
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) { $('#text_status_p3').css('display','block');up_class_p4(); });
}
function up_class_p4() {
	var formData = new Array();
	formData.push({ "name": "acc_action", "value": "up_class_p" });
	formData.push({ "name": "value_set", "value": 4 }); 
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) { $('#text_status_p4').css('display','block');up_class_p5(); });
}
function up_class_p5() {
	var formData = new Array();
	formData.push({ "name": "acc_action", "value": "up_class_p" });
	formData.push({ "name": "value_set", "value": 5 }); 
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) { $('#text_status_p5').css('display','block');up_class_p6(); });
}
function up_class_p6() {
	var formData = new Array();
	formData.push({ "name": "acc_action", "value": "up_class_p" });
	formData.push({ "name": "value_set", "value": 6 }); 
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) { $('#text_status_p6').css('display','block');up_class_m2(); });
}
function up_class_m2() {
	var formData = new Array();
	formData.push({ "name": "acc_action", "value": "up_class_m" });
	formData.push({ "name": "value_set", "value": 2 }); 
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) { $('#text_status_m2').css('display','block');up_class_m3(); });
}
function up_class_m3() {
	var formData = new Array();
	formData.push({ "name": "acc_action", "value": "up_class_m" });
	formData.push({ "name": "value_set", "value": 3 }); 
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) { $('#text_status_m3').css('display','block');up_class_m5(); });
}
function up_class_m5() {
	var formData = new Array();
	formData.push({ "name": "acc_action", "value": "up_class_m" });
	formData.push({ "name": "value_set", "value": 5 }); 
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) { $('#text_status_m5').css('display','block');up_class_m6(); });
}
function up_class_m6() {
	var formData = new Array();
	formData.push({ "name": "acc_action", "value": "up_class_m" });
	formData.push({ "name": "value_set", "value": 6 }); 
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {
		$('#text_status_m6').css('display','block'); 
		$('#footer_btn').css('display','block'); 
		$('#text_status_header').html('เลื่อนระดับชั้นของนักเรียนทั้งหมดสำเร็จ'); 
		get_data_upclassed();
	});
}
 $(document).delegate('.btn_reverse', 'click', function(event) {
 	
 	var log_upclass_id = $(this).attr('data-id');

 	var data_text = $(this).attr('data-text');
 	var data_year_old = $(this).attr('data-year-old');
 	var data_year_new = $(this).attr('data-year-new');
 	$('#log_upclass_id').val(log_upclass_id);
 	$('#data_text').html(data_text);	
 	$('#data_year_old').val(data_year_old);
 	$('#data_year_new').val(data_year_new);
 	log_upclass_id='';
 	data_text='';
 	data_year_old='';
 	data_year_new='';
});
 $(document).delegate('#btn_reverse_upclass', 'click', function(event) {
 	
 	var log_upclass_id = $('#log_upclass_id').val();
 	var data_year_old = $('#data_year_old').val();
 	var data_year_new = $('#data_year_new').val();
 	var formData = new Array();

	formData.push({ "name": "acc_action", "value": "reverse_upclass" }); 
	
	formData.push({ "name": "log_upclass_id", "value": log_upclass_id });
	formData.push({ "name": "data_year_old", "value": data_year_old });
	formData.push({ "name": "data_year_new", "value": data_year_new });  
	$.post('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {
		$(".modal").modal('hide');
		$("#modalReversed").modal('show');
		get_data_upclassed();
	});
});
$(document).delegate('#btn_upclass', 'click', function(event) {
	$(".modal").modal('hide');
	$("#modalWaitUp").modal('show');
	up_class_p2();
})
function get_year() {
	var formData = new Array();
	formData.push({ "name": "acc_action", "value": "get_year" }); 
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {
		$("#year_set").html(data);
		get_std_list();		
	})
}
function get_data_upclassed() {
	var formData = new Array();
	formData.push({ "name": "acc_action", "value": "data_upclassed" }); 
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {
		$("#table_list_upclassed").html(data);
	})
}<file_sep>/modules/report/index.js
var opPage = 'report';
$(document).ready(function() {
	
}); 
function get_pdf_sara(){
	$( "#form_pdf_sara" ).submit();
}
function get_pdf_desirable(){
	$( "#form_pdf_desirable" ).submit();
}
function get_pdf_major(){
	$( "#form_pdf_major" ).submit();
}
function get_pdf_level(){
	$( "#form_pdf_level" ).submit();
}
function get_pdf_person_p(){
	$( "#form_pdf_person_p" ).submit();
}
function get_pdf_person_m(){
	$( "#form_pdf_person_m" ).submit();
}


<file_sep>/modules/menu/from.js
document.writeln('<script type="text/javascript" src="assets/js/texteditor/texteditor.js"></script>');
document.writeln("<link href='assets/plugins/bootstrap3-wysihtml5/bootstrap3-wysihtml5.min.css' rel='stylesheet' type='text/css' />");
// document.writeln("<script type='text/javascript'  src='http://bp.yahooapis.com/2.4.21/browserplus-min.js'></script>");
document.writeln("<script type='text/javascript'  src='assets/js/plupload/js/plupload.js'></script>");
document.writeln("<script type='text/javascript'  src='assets/js/plupload/js/plupload.gears.js'></script>");
document.writeln("<script type='text/javascript'  src='assets/js/plupload/js/plupload.silverlight.js'></script>");
document.writeln("<script type='text/javascript'  src='assets/js/plupload/js/plupload.flash.js'></script>");
document.writeln("<script type='text/javascript'  src='assets/js/plupload/js/plupload.browserplus.js'></script>");
document.writeln("<script type='text/javascript'  src='assets/js/plupload/js/plupload.html4.js'></script>");
document.writeln("<script type='text/javascript'  src='assets/js/plupload/js/plupload.html5.js'></script>");
document.writeln("<script type='text/javascript'  src='modules/menu/upload_boxIV.js'></script>");
document.writeln("<script type='text/javascript'  src='modules/menu/upload_award.js'></script>");
// document.writeln("<script type='text/javascript'  src='modules/menu/upload_photo.js'></script>");
// document.writeln("<script type='text/javascript'  src='modules/menu/upload_keyword.js'></script>");

var opPage = 'menu';

$(document).ready(function() {
	get_data();
	get_thumb();
	get_award();
	// initMap();
	// get_photo();
	// get_keyword();
}); 

function get_data(){
	var formData = new Array();
	formData.push({ "name": "acc_action", "value": "get_data_from" }); 
	formData.push({ "name": "data_id", "value": _get.id}); 
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus) {
	// console.log(data);
		$('#DataID').val(_get.id);
		$('#boxI_name').val(data.boxI_name);
		$('#boxI_nameEn').val(data.boxI_nameEn);
		$('#boxII_name').val(data.boxII_name);
		$('#boxII_nameEn').val(data.boxII_nameEn);
		$('#boxIII_name').val(data.boxIII_name);
		$('#boxIII_nameEn').val(data.boxIII_nameEn);
		$('#boxIV_name').val(data.boxIV_name);
		$('#boxIV_nameEn').val(data.boxIV_nameEn);
		$('#boxI_desc').val(data.boxI_desc);
		$('#boxI_descEn').val(data.boxI_descEn);
		$('#boxII_desc').val(data.boxII_desc);
		$('#boxII_descEn').val(data.boxII_descEn);
		$('#boxIII_desc').val(data.boxIII_desc);
		$('#boxIII_descEn').val(data.boxIII_descEn);
		$('#boxIV_desc').val(data.boxIV_desc);
		$('#boxIV_descEn').val(data.boxIV_descEn);
		$('#tag_title').val(data.tag_title);
		$('#tag_keyword').val(data.tag_keyword);
		$('#tag_description').val(data.tag_description);
		$('#date_start_value').val(data.date_start_value);
		$('#date_end_value').val(data.date_end_value);
		$('#status').select2("val",data.status);
	});

}

$(document).delegate('#btn__save', 'click', function(event) {
	var formData = $( "#frm_data" ).serializeArray();
	formData.push({ "name": "acc_action", "value": "save_data" }); 
	formData.push({ "name": "data_id", "value": _get.id}); 
	$.post('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {
// console.log(data);
// return false;
window.location = 'index.php?op='+opPage+'-index&data=success';
});

});

$(document).delegate('#btn__preview', 'click', function(event) {
	$( "#frm_data" ).submit();
});



<file_sep>/modules/profile/backup/process.php
<?php
@ob_start();
@session_start();

require_once('../../init.php');
include('../../src/class.pagination.php');
include('../../src/class.inputfilter.php');
$InputFilter = new InputFilter();

##CLASS_DB_CONNECT##
include('class_modules.php');
$class_data = new ClassData();
##CLASS_DB_CONNECT##

if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_img"){

	$status_get=$_GET['status_get'];
	echo $class_data->get_img($status_get);
}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_data"){
	echo $class_data->get_data();

}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_day"){
	$mouth=$_GET['mouth'];
	echo $class_data->get_day($mouth);
}
if(isset($_POST['acc_action']) and $_POST['acc_action'] == "save_data"){
		$day=$_POST['day'];
		$month=$_POST['month'];
		$years=$_POST['years']-543;
		$birthday=$years.'-'.$month.'-'.$day;
		$arr_sql[]="positionID='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['positionID'])))."'";
		$arr_sql[]="fname_th='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['fname_th'])))."'";
		$arr_sql[]="lname_th='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['lname_th'])))."'";
		$arr_sql[]="fname_en='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['fname_en'])))."'";
		$arr_sql[]="lname_en='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['lname_en'])))."'";

		$arr_sql[]="birthday='".chkhtmlspecialchars($InputFilter->clean_script(trim($birthday)))."'";

		$arr_sql[]="study_history='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['study_history'])))."'";
		$arr_sql[]="gender='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['gender'])))."'";
		$arr_sql[]="blood_group='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['blood_group'])))."'";
		$arr_sql[]="address='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['address'])))."'";
		$arr_sql[]="position_name='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['position_name'])))."'";
		$arr_sql[]="department='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['department'])))."'";
		$arr_sql[]="work='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['work'])))."'";	
		$arr_sql[]="more_detail='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['more_detail'])))."'";	
		$arr_sql[]="tell='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['tell'])))."'";	
		$arr_sql[]="email='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['email'])))."'";	

		$class_data->update_data($arr_sql);
	}<file_sep>/modules/news/process.php
<?php
@ob_start();
@session_start();

require_once('../../init.php');
include('../../src/class.pagination.php');
include('../../src/class.inputfilter.php');
$InputFilter = new InputFilter();

##CLASS_DB_CONNECT##
include('class_modules.php');
$class_data = new ClassData();
##CLASS_DB_CONNECT##

if(isset($_GET['acc_action']) and $_GET['acc_action'] == "delete_news"){	
	$data_id=$_GET['data_id'];
	echo $class_data->delete_news($data_id);

}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "delete_img_file"){	
	$data_id=$_GET['data_id'];
	echo $class_data->delete_img_file($data_id,$_GET['set_type']);

}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_news_detail"){		
	$news_id=$_GET['news_id'];
	echo $class_data->get_news_detail($news_id);
}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_news_list"){	
	echo $class_data->get_news_list();
}
<file_sep>/modules/mobile_api/class_modules.php
<?php 
class ClassData extends Databases {
	
	public function get_header_box($user_id){
        $products_arr=array();
        $products_arr["records"]=array();
		$this->sql ="SELECT DISTINCT year
					FROM tbl_pp6 
					WHERE std_ID='$user_id'
					ORDER BY year
					";
		$this->select();
        $this->setRows();	
        
		foreach($this->rows as $key => $value) {
   			$year=$value['year'];	
            $product_item=array(
                "key" => $key,
				"year" => $year,			
            );
			array_push($products_arr["records"], $product_item);	
		}
		echo json_encode($products_arr);
	}
    public function get_table_box($user_id,$year){
        $products_arr=array();
        $products_arr["records"]=array();
		$this->sql ="SELECT DISTINCT(term) as term,year,class_level,room
					FROM tbl_pp6 
					WHERE std_ID='$user_id'
					AND year='$year'
					ORDER BY term
					";
		$this->select();
        $this->setRows();	
        
		foreach($this->rows as $key => $value) {
            $term=$value['term'];
			$room=$value['room'];
			$class_level=$value['class_level'];
			$ClasslevelText=$this->getClasslevelText($class_level);
			if($class_level=='p1' || $class_level=='p2' || $class_level=='p3' || $class_level=='p4' || $class_level=='p5' || $class_level=='p6'){
				$class_level_status=1;
				$resaultGpa=$this->get_resaultGpaP($user_id,$term,$year);
			}else{
				$class_level_status=2;
				$resaultGpa=$this->get_resaultGpaM($user_id,$term,$year);
				$resaultGpax=$this->get_resaultGpax($user_id,$term,$year);
			}
			$resaultSum=$this->get_resaultSum($user_id,$term,$year);
			
			$find_position=$this->find_position($year,$class_level,$room);
			arsort($find_position);
			$arrayValuePosition=$this->arrayValuePositionNew($find_position,$user_id);
            $product_item=array(
                "key" => $key,
                "term" => $term,
                "class_level" => $ClasslevelText,
                "room" => $room,
				"year" => $year,
				"resaultSum" => $resaultSum,
				"resaultGpa" => $resaultGpa,
				"resaultGpax" => $resaultGpax,
				"class_level_status" => $class_level_status,
				"std_position" => $arrayValuePosition,
            );
			array_push($products_arr["records"], $product_item);
			
		}
		echo json_encode($products_arr);
	}
	public function arrayValuePositionNew($find_position,$std_ID){	
		$result = array();
		$pos = $real_pos = 0;
		$prev_score = -1;
		foreach ($find_position as $exam_n => $score) {
			$real_pos += 1;// Natural position.
			$pos = ($prev_score != $score) ? $real_pos : $pos;// If I have same score, I have same position in ranking, otherwise, natural position.
			$result[$exam_n] = array(
							 "score" => $score, 
							 "position" => $pos, 
							 "exam_no" => $exam_n
							 );
			$prev_score = $score;// update last score.
		}

		return $result[$std_ID]["position"];
}
	public function find_position($year_data,$class_level_data,$room){
		$data_response = array();	
		$this->sql ="SELECT distinct(tbl_pp6.std_ID) as std_pp6_id,tbl_pp6.DataID as pp6_id
					FROM tbl_pp6,tbl_sub_pp6
					WHERE tbl_pp6.DataID=tbl_sub_pp6.pp6_ID
					AND tbl_pp6.year='$year_data'
					AND tbl_pp6.room='$room'
					AND tbl_pp6.class_level='$class_level_data'
					AND tbl_sub_pp6.status=1
		";
		$this->select();
		$this->setRows();
		$find_gpa_sum=0;	
		$score_final_count=0;
		foreach($this->rows as $key => $value) {
			 $std_pp6_id=$value['std_pp6_id'];
			 $pp6_id=$value['pp6_id'];
			 if($class_level_data=='p1' || $class_level_data=='p2' || $class_level_data=='p3' || $class_level_data=='p4' || $class_level_data=='p5' || $class_level_data=='p6'){
				$data_big_std= $this->get_data_big_std_p($std_pp6_id,$pp6_id);
			}else{
				$data_big_std= $this->get_data_big_std_m($std_pp6_id,$pp6_id);
			}
			
			 $test[$std_pp6_id] = $data_big_std;
			 /*
	
			 $pick_poi= $this->get_pick_poi($registed_courseID,$stdID,$term_data,$year);
			 $grade_text=$this->get_grade_text($score_exam,$pick_poi);
			 $unit=$this->get_unit($registed_courseID);
			 $find_gpa=$grade_text*$unit;
			
			 $find_gpa_sum=$find_gpa_sum+$find_gpa;*/

			 //$tt.=$stdID.'='.$insert.',';
		}
		//$total= $final_poi+$mid_poi;

		return $test;
	}
	public function get_data_big_std_p($std_pp6_id,$pp6_id){
		$this->sql ="SELECT sum(score_total) as sumed
					FROM tbl_pp6,tbl_sub_pp6
					WHERE tbl_pp6.DataID=tbl_sub_pp6.pp6_ID
					AND tbl_sub_pp6.pp6_ID=$pp6_id
					AND score_total!=-1
		";
		$this->select();
		$this->setRows();
		return $this->rows[0]['sumed'];
	}
	public function get_data_big_std_m($std_pp6_id,$pp6_id){
		$this->sql ="SELECT unit,score_total
					FROM tbl_pp6,tbl_sub_pp6
					WHERE tbl_pp6.DataID=tbl_sub_pp6.pp6_ID
					AND tbl_sub_pp6.pp6_ID=$pp6_id
					AND score_total!=-1
		";
		$this->select();
		$this->setRows();
		$find_row_sum=0;
		foreach($this->rows as $key => $value) {
			 $unit=$value['unit'];
			 $score_total=$value['score_total'];
			 $grade= $this->get_grade($score_total);
			 $find_row_sum=$find_row_sum+($unit*$grade);
		}
		$this->sql ="SELECT SUM(unit) as unit_sum
					FROM tbl_pp6,tbl_sub_pp6
					WHERE tbl_pp6.DataID=tbl_sub_pp6.pp6_ID
					AND tbl_sub_pp6.pp6_ID=$pp6_id
					AND tbl_sub_pp6.status=1
		";
		$this->select();
		$this->setRows();
		$unit_sum=$this->rows[0]['unit_sum'];
		return $find_row_sum/$unit_sum;
	}
	public function get_grade($total){
		if ($total<50) {
			$grade='0.0';
		}elseif($total<55){
			$grade='1.0';
		}elseif($total<60){
			$grade='1.5';
		}elseif($total<65){
			$grade='2.0';
		}elseif($total<70){
			$grade='2.5';
		}elseif($total<75){
			$grade='3.0';
		}elseif($total<80){
			$grade='3.5';
		}elseif($total>=80){
			$grade='4.0';
		}
		return $grade;
	}
	
	public function get_resaultGpax($user_id,$term,$year){
		$this->sql ="SELECT score_total,unit
					FROM tbl_sub_pp6 
					WHERE status=1
					AND pp6_ID in(
						SELECT DataID
						FROM tbl_pp6
						WHERE std_ID=$user_id
						AND year<=$year
						AND term<=$term
					)
					";
		$this->select();
		$this->setRows();
		$score_row_sum=0;
		$unit_count=0;
		foreach($this->rows as $key => $value) {
			$score_total=$value['score_total'];
			$unit=$value['unit'];
			if($score_total!=-1){
				$grade=$this->get_grade_text($score_total);
				$score_row=$grade*$unit;
				$score_row_sum=$score_row_sum+$score_row;
			}
			
			$unit_count=$unit_count+$unit;
		}
		return number_format($score_row_sum/$unit_count,2);

}
	public function get_resaultGpaM($user_id,$term,$year){
			$this->sql ="SELECT score_total,unit
						FROM tbl_sub_pp6 
						WHERE status=1
						AND pp6_ID in(
							SELECT DataID
							FROM tbl_pp6
							WHERE std_ID=$user_id
							AND year='$year'
							AND term='$term'
						)
						";
			$this->select();
			$this->setRows();
			$score_row_sum=0;
			$unit_count=0;
			foreach($this->rows as $key => $value) {
				$score_total=$value['score_total'];
				$unit=$value['unit'];
				if($score_total!=-1){
					$grade=$this->get_grade_text($score_total);
					$score_row=$grade*$unit;
				}
				$score_row_sum=$score_row_sum+$score_row;
				$unit_count=$unit_count+$unit;
			}
			return number_format($score_row_sum/$unit_count,2);

	}
	public function get_resaultGpaP($user_id,$term,$year){
		$this->sql ="SELECT SUM(score_total) as score_total
					FROM tbl_sub_pp6 
					WHERE score_total!=-1
					AND status=1
					AND pp6_ID in(
						SELECT DataID
						FROM tbl_pp6
						WHERE std_ID=$user_id
						AND year='$year'
                        AND term='$term'
					)
					";
		$this->select();
		$this->setRows();
		$score_total=$this->rows[0]['score_total'];

		$this->sql ="SELECT COUNT(*) as num_row
					FROM tbl_sub_pp6 
					WHERE status=1
					AND pp6_ID in(
						SELECT DataID
						FROM tbl_pp6
						WHERE std_ID=$user_id
						AND year='$year'
                        AND term='$term'
					)
					";
		$this->select();
		$this->setRows();
		$num_row=$this->rows[0]['num_row'];
		$resaultGpaFind=$score_total/$num_row;
		return $resaultGpaFind;
	}
	public function get_resaultSum($user_id,$term,$year){
		$this->sql ="SELECT SUM(score_total) as score_total
					FROM tbl_sub_pp6 
					WHERE score_total!=-1
					AND pp6_ID in(
						SELECT DataID
						FROM tbl_pp6
						WHERE std_ID=$user_id
						AND year='$year'
                        AND term='$term'
					)
					";
		$this->select();
		$this->setRows();
		$score_total=$this->rows[0]['score_total'];
		if($score_total=='' || $score_total==NULL){
			$score_total=0;
		}
		return $score_total;
	}
    public function get_grade_text($score_exam,$score_pick){
		$total=$score_exam+$score_pick;
		if ($total<50) {
			$grade='0.0';
		}elseif($total<55){
			$grade='1.0';
		}elseif($total<60){
			$grade='1.5';
		}elseif($total<65){
			$grade='2.0';
		}elseif($total<70){
			$grade='2.5';
		}elseif($total<75){
			$grade='3.0';
		}elseif($total<80){
			$grade='3.5';
		}elseif($total>=80){
			$grade='4.0';
		}
		return $grade;
	}
    public function get_subject_list($user_id,$term,$year){
        $products_arr=array();
        $products_arr["records"]=array();
        $this->sql =" SELECT class_level
                     FROM tbl_pp6
                     WHERE std_ID=$user_id
                     AND year='$year'
                     AND term='$term'
                ";
        $this->select();
        $this->setRows();	
        $class_level=$this->rows[0]['class_level'];

        $this->sql ="SELECT *
					FROM tbl_sub_pp6
					WHERE pp6_ID in(
						SELECT DataID
						FROM tbl_pp6
						WHERE std_ID=$user_id
						AND year='$year'
                        AND term='$term'
					)
					ORDER BY status ASC
					";
		$this->select();
		$this->setRows();	
		$sum_course_score=0;
		$sum_cproportion_score=0;
		$find_gpa_sum=0;
		$find_unit_sum=0;

		$grade_sum=0;
		$count_loop=0;
		foreach($this->rows as $key => $value) {
			$courseID=$value['courseID'];
			$name=$value['name'];
            $status=$value['status'];      
            if($status==1){
                if($class_level=='p1' || $class_level=='p2' || $class_level=='p3' || $class_level=='p4' || $class_level=='p5' || $class_level=='p6'){
                    $name=$this-> get_department($value['department']);
                }else{
					$name=$courseID;
				}
                $unit=$value['unit'];
                $score_total=$value['score_total'];
                if($score_total==-1){
                    $score_total=$value['score_mid']+$value['score_final'];
                    $grade='ร';
                }else{
                    $grade=$this->get_grade_text($score_total);
                }
            }else{
                $score_total='-';
                $unit='-';
                $score_attend=$value['score_attend'];
                if($score_attend==-1){
                    $grade='ไม่ผ่าน';
                }else{
                    $grade='ผ่าน';
                }
            }
            $product_item=array(
                "key" => $key,   
                "name" => $name,
                "score_total" => $score_total,
                "unit" => $unit,
                "grade" => $grade,
            );
            array_push($products_arr["records"], $product_item);	
        }
        echo json_encode($products_arr);
    }
    public function get_department($data){
		
		switch ($data) {
		    case 1:
		       	$department='ภาษาไทย';
		        break;
		    case 2:
		        $department='คณิตศาสตร์';
		        break;
		    case 3:
		        $department='วิทยาศาสตร์';
		        break;
		    case 31:
		        $department='วิทยาศาสตร์และเทคโนโลยี';
		        break;    
		    case 4:
		        $department='สังคมศึกษา ศาสนาและวัฒนธรรม';
		        break;
		    case 41:
		        $department='สังคมศึกษา';
		        break;
		    case 42:
		        $department='ภูมิศาสตร์';
		        break;
		    case 43:
		        $department='ประวัติศาสตร์';
		        break;
		    case 5:
		        $department='สุขศึกษาและพลศึกษา';
		        break;
		    case 6:
		        $department='ศิลปะ';
		        break;
		    case 7:
		        $department='การงานอาชีพและเทคโนโลยี';
		        break; 
		    case 71:
		        $department='การงานอาชีพ';
		        break; 
		    case 8:
		        $department='ภาษาต่างประเทศ';
		        break;     
		    default:
		     	$department='';
		}
		return $department;
	}
   	public function getClasslevelText($class_level_data){
   	
   		if ($class_level_data=="p1") {
			$class_level="ป.1";
		}elseif($class_level_data=="p2"){
			$class_level="ป.2";	
		}elseif($class_level_data=="p3"){
			$class_level="ป.3";	
		}elseif($class_level_data=="p4"){
			$class_level="ป.4";	
		}elseif($class_level_data=="p5"){
			$class_level="ป.5";	
		}elseif($class_level_data=="p6"){
			$class_level="ป.6";	
		}elseif($class_level_data=="m1"){
			$class_level="ม.1";	
		}elseif($class_level_data=="m2"){
			$class_level="ม.2";	
		}elseif($class_level_data=="m3"){
			$class_level="ม.3";	
		}elseif($class_level_data=="m4"){
			$class_level="ม.4";	
		}elseif($class_level_data=="m5"){
			$class_level="ม.5";	
		}elseif($class_level_data=="m6"){
			$class_level="ม.6";	
		}
		return $class_level;
   	}

}<file_sep>/modules/add_delete_course/process.php
<?php
@ob_start();
@session_start();

require_once('../../init.php');
include('../../src/class.pagination.php');
include('../../src/class.inputfilter.php');
$InputFilter = new InputFilter();

##CLASS_DB_CONNECT##
include('class_modules.php');
$class_data = new ClassData();
##CLASS_DB_CONNECT##

if(isset($_GET['acc_action']) and $_GET['acc_action'] == "getdata_edit"){	
	$data_id = $_GET['data_id'];
	echo $class_data->getdata_edit($data_id);

}

if(isset($_POST['acc_action']) and $_POST['acc_action'] == "data_remove"){
	$data_val = $_POST['data_val'];
	
	echo $class_data->get_data_delete($data_val);
}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_data"){	
	$arr_search_val['courseID_search'] = $_GET['courseID_search'];
	$arr_search_val['department_search'] = $_GET['department_search'];
	$arr_search_val['class_level_search'] = $_GET['class_level_search'];
	$arr_search_val['status'] = $_GET['status'];
	echo $class_data->get_data($arr_search_val);
}
if(isset($_POST['acc_action']) and $_POST['acc_action'] == "save_data_edit"){
		$user_add=$_SESSION['ss_user_id'];
		$data_id_course=$_POST['data_id_course'];
		$arr_sql[]="courseID='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['courseID_edit'])))."'";
		$arr_sql[]="user_add='".chkhtmlspecialchars($InputFilter->clean_script(trim($user_add)))."'";
		$arr_sql[]="name='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['name'])))."'";
		$arr_sql[]="class_level='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['class_level'])))."'";
		$arr_sql[]="unit='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['unit'])))."'";
		$arr_sql[]="department='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['department'])))."'";
		$arr_sql[]="hr_learn='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['hr_learn'])))."'";
		$arr_sql[]="status='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['course_status'])))."'";
		$status_form=$_POST['course_status'];
		if ($status_form==11 || $status_form==12) {
			$arr_sql[]="status=1";
			$arr_sql[]="status_form='".$status_form."'";
		}else{
			$arr_sql[]="status='2'";
			$arr_sql[]="status_form='".$_POST['dev_mode_value_add_edit']."'";
		}
		echo $class_data->update_data($arr_sql,$data_id_course);
}
if(isset($_POST['acc_action']) and $_POST['acc_action'] == "save_data"){
		$user_add=$_SESSION['ss_user_id'];
		$arr_sql["courseID"]="'".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['courseID'])))."'";		
		$arr_sql["name"]="'".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['name'])))."'";	
		$arr_sql["class_level"]="'".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['class_level'])))."'";
		$arr_sql["unit"]="'".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['unit'])))."'";
		$arr_sql["department"]="'".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['department'])))."'";
		$arr_sql["hr_learn"]="'".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['hr_learn'])))."'";
		$arr_sql["user_add"]="'".chkhtmlspecialchars($InputFilter->clean_script(trim($user_add)))."'";
		$status_form=$_POST['course_status'];
		if ($status_form==11 || $status_form==12) {
			$arr_sql["status"]=1;
			$arr_sql["status_form"]=$status_form;
		}else{
			$arr_sql["status"]=2;
			$arr_sql["status_form"]=$_POST['dev_mode_value_add'];
		}
		
		$arr_sql["cdate"]="now()"; 		

		echo $class_data->insert_data($arr_sql);
}<file_sep>/modules/conclusion/form/learning_result_final_m.php
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="../../../assets/css/bootstrap.css" rel="stylesheet" type="text/css">
<link href="../../../assets/css/margin-padding.css" rel="stylesheet" type="text/css">
<link href="../../../assets/css/responsive.css" rel="stylesheet" type="text/css">
<link href="../../../assets/css/print_conclusion.css?<?php echo date('l jS \of F Y h:i:s A'); ?>" rel="stylesheet" type="text/css">

<script type="text/javascript" src="../../../assets/js/jquery.js"></script>
<style type="text/css">
<!--
 table {
    border-collapse: collapse;
}
td, th {
    border: 1px solid black;
    padding: 2px;
}
-->
</style>
<?php

 @session_start();
include ('../logo.php');
include ('learning_result_footer.php');

require_once('../../../init.php');
include('../class_modules/learing_resualt_final_m.php');
$class_data = new ClassData();

$class_level=$_GET['class_level'];
$room=$_GET['room'];
$year=$_GET['year'];
$term=$_GET['term'];
$final_data_m=$class_data->get_final_data_m($class_level,$room,$year,$term,$image_logo,$footer_text_detail,$footer_text_cen);
?>
<div style="background-color: rgb(82, 86, 89);min-height: 100%">
  <div style="font-size:16px;background-color: white;min-height: 100%;padding-right: 30px; padding-left: 30px;margin-right: auto;margin-left: auto;width: 100%">    
    <?php echo $final_data_m['std_list']; ?>
  </div>
</div>
<script>
$(document).ready(function() {
    get_print();
    setTimeout(window.close, 0);
  });
  function get_print() {
    window.print();
  }
</script><file_sep>/modules/regis_course_teaching/back/New folder/class_modules.php
<?php 

class ClassData extends Databases {
	public function get_term_year_now(){
		$data_response = array();	
		$this->sql ="SELECT  *
					FROM tbl_set_term_year 				
							";
		$this->select();
		$this->setRows();
		$data_response['term']=$this->rows[0]['term'];
		$data_response['year']=$this->rows[0]['year'];
		echo json_encode($data_response); 
	}
	public function get_name_title($name_title_data){
		if ($name_title_data=="dekchai") {
			$name_title="เด็กชาย";
		}elseif($name_title_data=="dekying"){
			$name_title="เด็กหญิง";
		}elseif($name_title_data=="nai"){
			$name_title="นาย";
		}else{
			$name_title="นางสาว";
		}
		return $name_title;
	}
	public function get_teaching_std_id($std_ID,$data_id){
		$this->sql ="SELECT  *
					FROM tbl_course_teaching_std 
					WHERE registed_courseID=$data_id
					AND stdID='$std_ID'						
							";
		$this->select();
		$this->setRows();
		return $this->rows[0]['DataID'];
	}
	public function get_teaching_student_only($data_id,$data_room){
		$data_response = array();	
		$this->sql ="SELECT  count(*) as count_loop_std
					FROM tbl_student 
					WHERE room='$data_room'
					AND std_ID in(
						SELECT stdID
						FROM tbl_course_teaching_std
						WHERE registed_courseID = $data_id	
						)		
							";
		$this->select();
		$this->setRows();
		$count_loop_std=$this->rows[0]['count_loop_std'];
		if ($count_loop_std!=0) {					
			$this->sql ="SELECT  *
						FROM tbl_student 
						WHERE room='$data_room'
						AND std_ID in(
							SELECT stdID
							FROM tbl_course_teaching_std
							WHERE registed_courseID = $data_id	
							)		
						ORDER BY 
						CASE
							WHEN name_title LIKE '%dekchai%' THEN 0
					        WHEN name_title LIKE '%nai%' THEN 1
					        WHEN name_title LIKE '%dekying%' THEN 2
					        WHEN name_title LIKE '%nangsaw%'THEN 3
					        WHEN std_ID THEN 4      
					    END
								";
			$this->select();
			$this->setRows();
			foreach($this->rows as $key => $value) {
				 $std_ID=$value['std_ID'];
				 $teaching_std_id=$this->get_teaching_std_id($std_ID,$data_id);
				 $name_title_data=$value['name_title'];
				 $name_title=$this->get_name_title($name_title_data);
				 $fname=$value['fname'];
				 $lname=$value['lname'];

				 $class_level_data=$value['class_level'];
				 $class_level=$this->get_class_level($class_level_data);
				 $room =$value['room'];
				 $data_response['std_list_only'].='
				 			<tr>                                 
	                                  <td style="text-align:center;">'.$std_ID.'</td>
	                                  <td style="text-align:left;padding-left:16%;">'.$name_title.$fname.' '.$lname.'</td>
	                                  <td style="text-align:center;">'. $class_level.'</td>
	                                  <td style="text-align:center;">'.$room.'</td>
	                                  <td style="text-align:center;">
	                                    <div data-id="'.$teaching_std_id.'" class="bt_delete"  aria-hidden="true" data-toggle="modal" data-target="#modalConfirmReStd">
	                                      <span class="glyphicon glyphicon-trash edit-icon-table" ></span>
	                                    </div>
	                                  </td>
	                                  
	                                  
	                                </tr>
				 ';
			}
		}else{
			 $data_response['std_list_only']='';
		}
		return json_encode($data_response);
	}
	public function get_course_teaching_student($data_id){
		$data_response = array();	
		$sql="SELECT *
			FROM tbl_add_delete_course 		
			WHERE DataID in(
				SELECT courseID
				FROM tbl_registed_course 
				WHERE DataID=$data_id
			)
							";
			$this->sql =$sql;
			$this->select(); 
			$this->setRows();
			$data_response['course_data_ID']=$this->rows[0]['DataID'];
			$data_response['courseID']=$this->rows[0]['courseID'];
			$data_response['name']=$this->rows[0]['name'];
			return json_encode($data_response);

	}

	public function get_score_before_after($course_id,$cumulative_before_mid,$cumulative_after_mid){
		$data_response = array();
		$this->sql ="SELECT  COUNT(*) as num_of_course
					FROM tbl_objective_conclude 
					WHERE courseID=$course_id
							";
		$this->select();
		$this->setRows();
		$num_of_course=$this->rows[0]['num_of_course'];
		if($num_of_course!="" || $num_of_course==0){
			$this->sql ="SELECT  COUNT(DataID) as score_count_before 
						FROM tbl_objective_conclude 
						WHERE courseID=$course_id
						AND proportion_status=1
								";
			$this->select();
			$this->setRows();
			$score_count_before=$this->rows[0]['score_count_before'];

			$data_response['score_count_before']=$this->rows[0]['score_count_before'];
			if ($score_count_before!=0) {
				$this->sql ="SELECT  SUM(score) as score_sum_before 
							FROM tbl_objective_conclude 
							WHERE courseID=$course_id
							AND proportion_status=1
									";
				$this->select();
				$this->setRows();
				$data_response['score_sum_before']=$cumulative_before_mid-$this->rows[0]['score_sum_before'];
			}else{
				$data_response['score_sum_before']="0";
			}
			
			$this->sql ="SELECT  COUNT(DataID) as score_count_after
						FROM tbl_objective_conclude 
						WHERE courseID=$course_id
						AND proportion_status=2
								";
			$this->select();
			$this->setRows();
			$score_count_after=$this->rows[0]['score_count_after'];
			$data_response['score_count_after']=$this->rows[0]['score_count_after'];
			if ($score_count_after!=0) {
				$this->sql ="SELECT  SUM(score) as score_sum_after 
							FROM tbl_objective_conclude 
							WHERE courseID=$course_id
							AND proportion_status=2
									";
				$this->select();
				$this->setRows();
				$data_response['score_sum_after']=$cumulative_after_mid-$this->rows[0]['score_sum_after'];			
			}else{
				$data_response['score_sum_after']="0";
			}
		}else{
			$data_response['score_sum_before']=0;
			$data_response['score_sum_after']=0;
		}
		return $data_response;

	}
	
	public function update_exam_mid_object($data_id_first,$objective_conclude_id){
		$this->sql ="SELECT count(*) as num_row
					FROM tbl_exam_mid_object 
					WHERE courseID=$data_id_first
					AND objective_conclude=$objective_conclude_id
							";
		$this->select();
		$this->setRows();
		$num_row= $this->rows[0]['num_row'];
		if($num_row==0){
			$this->sql ="INSERT INTO tbl_exam_mid_object(courseID,objective_conclude) VALUES($data_id_first,$objective_conclude_id);
							";
			$this->query();
		}else{
			$this->sql ="DELETE  FROM tbl_exam_mid_object 
						WHERE courseID=$data_id_first
						AND objective_conclude=$objective_conclude_id 
							";
			$this->query();
		}
	}
	public function update_exam_final_object($data_id_first,$objective_conclude_id){
		$this->sql ="SELECT count(*) as num_row
					FROM tbl_exam_final_object 
					WHERE courseID=$data_id_first
					AND objective_conclude=$objective_conclude_id
							";
		$this->select();
		$this->setRows();
		$num_row= $this->rows[0]['num_row'];
		if($num_row==0){
			$this->sql ="INSERT INTO tbl_exam_final_object(courseID,objective_conclude) VALUES($data_id_first,$objective_conclude_id);
							";
			$this->query();
		}else{
			$this->sql ="DELETE  FROM tbl_exam_final_object 
						WHERE courseID=$data_id_first
						AND objective_conclude=$objective_conclude_id 
							";
			$this->query();
		}
	}
	public function get_exam_mid_object($data_id_first,$objective_conclude_id){
		$this->sql ="SELECT  count(*) as num_exam_mid_object
					FROM tbl_exam_mid_object 
					WHERE courseID=$data_id_first
					AND objective_conclude=$objective_conclude_id
							";
		$this->select();
		$this->setRows();
		return $this->rows[0]['num_exam_mid_object'];
	}
	public function get_exam_final_object($data_id_first,$objective_conclude_id){
		$this->sql ="SELECT  count(*) as num_exam_final_object
					FROM tbl_exam_final_object 
					WHERE courseID=$data_id_first
					AND objective_conclude=$objective_conclude_id
							";
		$this->select();
		$this->setRows();
		return $this->rows[0]['num_exam_final_object'];
	}
	public function get_exam_object($data_id_first){
		$this->sql ="SELECT  status
					FROM tbl_add_delete_course 
					WHERE DataID=$data_id_first
							";
		$this->select();
		$this->setRows();
		$data_response['status']=$this->rows[0]['status'];

		$this->sql ="SELECT  DataID,no_order
					FROM tbl_objective_conclude 
					WHERE courseID=$data_id_first
					ORDER BY no_order ASC
							";
		$this->select();
		$this->setRows();

		foreach($this->rows as $key => $value) {
			$no_order= $value['no_order'];
			$objective_conclude_id= $value['DataID'];
			$exam_mid_object=$this->get_exam_mid_object($data_id_first,$objective_conclude_id);
			if($exam_mid_object==1){
				$status_mid="checked";
			}else{
				$status_mid="";
			}
			$data_response['object_list_mid'].='
								<div class="col-sm-3">
			                      <div class="checkbox">
			                        <label><input type="checkbox" onclick="update_exam_mid_object('.$data_id_first.','.$objective_conclude_id.')"  '.$status_mid.'>ตัวชี้วัดที่ '.$no_order.'</label>
			                      </div>
			                    </div>
			';

			$exam_final_object=$this->get_exam_final_object($data_id_first,$objective_conclude_id);
			if($exam_final_object==1){
				$status_final="checked";
			}else{
				$status_final="";
			}
			$data_response['object_list_final'].='
								<div class="col-sm-3">
			                      <div class="checkbox">
			                        <label><input type="checkbox" onclick="update_exam_final_object('.$data_id_first.','.$objective_conclude_id.')" '.$status_final.'>ตัวชี้วัดที่ '.$no_order.'</label>
			                      </div>
			                    </div>
			';
		}

		echo json_encode($data_response);
	}
	public function get_propotion_objective($data_id_first){
		$data_response = array();	
		$this->sql ="SELECT  class_level
					FROM tbl_add_delete_course 
					WHERE DataID=$data_id_first
							";
		$this->select();
		$this->setRows();
		$class_level_course=$this->rows[0]['class_level'];
		if ($class_level_course=='p1' || $class_level_course=='p2' || $class_level_course=='p3' || $class_level_course=='p4' || $class_level_course=='p5' || $class_level_course=='p6') {
				$text_desc_1='ก่อนวัดผลกลางปี';
				$text_desc_2='หลังวัดผลกลางปี';
			}else{
				$text_desc_1='ก่อนกลางภาค';
				$text_desc_2='หลังกลางภาค';
			}

		$data_response = array();	
		$this->sql ="SELECT  count(*) as num_row_propotion
					FROM tbl_proportion 
					WHERE courseID=$data_id_first
							";
		$this->select();
		$this->setRows();
		$num_row_propotion=$this->rows[0]['num_row_propotion'];
		if ($num_row_propotion!=0) {
			$this->sql ="SELECT  *
					FROM tbl_proportion 
					WHERE courseID=$data_id_first
							";
			$this->select();
			$this->setRows();
			$cumulative_before_mid=$this->rows[0]['cumulative_before_mid'];
			$cumulative_after_mid=$this->rows[0]['cumulative_after_mid'];
			$data_response['cumulative_before_mid']=$cumulative_before_mid;
			$data_response['cumulative_after_mid']=$cumulative_after_mid;
			$data_response['mid_exam']=$this->rows[0]['mid_exam'];
			$data_response['final_exam']=$this->rows[0]['final_exam'];
		}else{
			$data_response['cumulative_before_mid']="";
			$data_response['cumulative_after_mid']="";
			$data_response['mid_exam']="";
			$data_response['final_exam']="";
		}
		
		$this->sql ="SELECT  count(*) as num_row_ob
					FROM tbl_objective_conclude 
					WHERE courseID=$data_id_first
							";
		$this->select();
		$this->setRows();
		$num_row_ob=$this->rows[0]['num_row_ob'];
		if ($num_row_ob!=0) {
			$score_before_after=$this->get_score_before_after($data_id_first,$cumulative_before_mid,$cumulative_after_mid);			
			
			$data_response['score_sum_before']=$score_before_after['score_sum_before'];
			$data_response['score_sum_after']=$score_before_after['score_sum_after'];

			$this->sql ="SELECT  count(*) num_loop
					FROM tbl_objective_conclude 
					WHERE courseID=$data_id_first
							";
			$this->select();
			$this->setRows();
			$num_loop=$this->rows[0]['num_loop'];
			$this->sql ="SELECT  *
					FROM tbl_objective_conclude 
					WHERE courseID=$data_id_first
					ORDER BY no_order
							";
			$this->select();
			$this->setRows();

			$set_loop_id=1;
			foreach($this->rows as $key => $value) {
				$DataID= $value['DataID'];
				$no_order= $value['no_order'];
				$detail= $value['detail'];		
				$score= $value['score'];	
				$proportion_status= $value['proportion_status'];	
				if ($proportion_status==1) {
						$object_list='
							<option  selected value="1">'.$text_desc_1.'</option>              
	                        <option value="2">'.$text_desc_2.'</option>
						';
				}elseif($proportion_status==2){
					$object_list='
							<option value="1">'.$text_desc_1.'</option>              
	                        <option selected value="2">'.$text_desc_2.'</option>
						';
				}
				$data_response['objective_list'].='
                            <tr>
	                          <td width="4%">ข้อที่</td>
	                          <td width="7%">
	                             <div class="input-group">
	                              <input name="no_order[]"  type="text" class="form-control form-set-search exam_chk_dis"  aria-describedby="basic-addon1" value="'.$no_order.'">
	                            </div> 
	                          </td>
	                          <td width="12%" style="padding-left: 30px;">ตัวชี้วัด</td>
	                          <td width="40%">
	                            <div class="input-group" style="width: 100%;margin-left: -20px;">
	                              <input  name="detail[]" type="text" class="form-control form-set-search exam_chk_dis"  aria-describedby="basic-addon1" value="'.$detail.'">
	                            </div> 
	                          </td>
	                          <td width="25%">
	                            <select  name="object_list_data[]" class="form-control search-course-depart object_list_data" style="width: 100%;">
	                             '.$object_list.'
	                            </select>
	                          </td>
	                          <td width="5%" style="padding-left: 30px;">คะแนน</td>
	                          <td width="15%" style="padding-left: 5px;">
	                             <div class="input-group">
	                              <input name="score_data[]"  type="text" class="form-control form-set-search score_data"  aria-describedby="basic-addon1" value="'.$score.'" >
	                            </div> 
	                          </td>
	                          <td style="padding-left: 15px;">
	                            <div data-toggle="modal" data-target="#modalConRemoveobjective" data-id="'.$DataID.'" class="btn-search btn_delete_objective_first" style="margin-top: -6px;">
			                      <span class="text-icon" style="margin-left: 3px;">-</span>
			                    </div>  		                 
	                          </td>
	                        </tr>
				';
					
				if ($num_loop==$set_loop_id) {
					$data_response['objective_data_all_id'].=$DataID;
				}else{
					$data_response['objective_data_all_id'].=$DataID.'-';
				}
				
				$set_loop_id++;

			}
		}else{
			$data_response['objective_list']='';
		}

		return json_encode($data_response);


	}
	public function insert_data_teaching($insert,$term_search,$year_search){

		$this->sql ="SELECT  *
					FROM tbl_registed_course 
					WHERE courseID=$insert
					AND year='$year_search'
					AND term='$term_search'
							";
		$this->select();
		$this->setRows();
		$long_course=$this->rows[0]['DataID'];
		$cdate=date("Y-m-d");
		$this->sql ="SELECT  count(*) as row_data_1
					FROM tbl_registed_course_teaching 
					WHERE registed_courseID=$long_course
							";
		$this->select();
		$this->setRows();
		$row_data_1=$this->rows[0]['row_data_1'];
		if ($row_data_1==0) {
			$this->sql = "INSERT INTO tbl_registed_course_teaching(registed_courseID,cdate) VALUES($long_course,'$cdate')";
			$this->query();
			$new_id = $this->insertID();
		}
		
	}
	public function insert_data_proportion($insert,$course_id){

		$this->sql ="SELECT  count(*) as row_data_2
					FROM tbl_proportion 
					WHERE courseID=$course_id
							";
		$this->select();
		$this->setRows();
		$row_data_2=$this->rows[0]['row_data_2'];
		if ($row_data_2!=0) {
			$this->sql ="DELETE FROM tbl_proportion WHERE courseID = $course_id";
	   		$this->query();
		}
		$this->sql = "INSERT INTO tbl_proportion(".implode(",",array_keys($insert)).") VALUES (".implode(",",array_values($insert)).")";
		$this->query();
		$new_id = $this->insertID();
	}

	public function data_remove_std($data_val){
		$data_response = array();	
		$arr_id = explode(",", $data_val);
		$num=0;
		for ($i=0; $i < count($arr_id) ; $i++) { 
            $this->sql ="DELETE FROM tbl_course_teaching_std WHERE DataID = '$arr_id[$i]'";
	        $this->query();
	      $num=$num+$i;
		}
		return $num;
	}
	public function data_remove_objective($data_val){
            $this->sql ="DELETE FROM 
            			tbl_objective_conclude 
            			WHERE DataID=$data_val" ;		
	        $this->query();
		return $num;
	}
	public function get_data_delete($data_val){
		list($data_id,$room) = split('[-]', $data_val);
		  /* $this->sql ="DELETE FROM 
            			tbl_registed_course_teaching 
            			WHERE registed_courseID=$data_id" ;		
	       $this->query();*/
	       if ($room=='') {
	       		$this->sql ="DELETE FROM 
            			tbl_registed_course_teaching 
            			WHERE registed_courseID=$data_id" ;		
	      		$this->query();
	       }else{
	       	  $this->sql ="DELETE FROM 
            			tbl_course_teaching_std 
            			WHERE registed_courseID=$data_id
            			AND stdID IN(
            				SELECT std_ID
            				FROM tbl_student
            				WHERE room='$room'
            			)
            			" ;		
	        	$this->query();
	       }
	     
       /*   $this->sql ="DELETE FROM 
            			tbl_course_teaching_std 
            			WHERE stdID in(
            				SELECT std_ID
            				FROM tbl_student
            				WHERE room='$room'
            			) 
            		    AND registed_courseID in(
            		    	SELECT DataID
            		    	FROM tbl_registed_course
            		    	WHERE DataID=$data_id

            		    )
            		";
            $this->query();*/
	       

		return $room;
	}
	 function get_unit_data($unit_data){
		if ($unit_data==0.0 | $unit_data==9.9) {
			$unit="-";
		}else{
			$unit=$unit_data;
		}
		return $unit;
	}
	public function get_term($unit_data,$status_data,$term){
		if ($unit_data==0) {
			if ($status_data==1) {
				$term="1,2";
			}else{
				$term=$term;
			}
			
		}else{
			$term=$term;
		}
		return $term;
	}
	
	public function get_year_data($registed_courseID){
		$this->sql ="SELECT  *
					FROM tbl_registed_course 
					WHERE DataID=$registed_courseID
							";
			$this->select();
			$this->setRows();
			return $this->rows[0]['year'];
	}
	public function get_term_data($registed_courseID){
		$this->sql ="SELECT  *
					FROM tbl_registed_course 
					WHERE DataID=$registed_courseID
							";
			$this->select();
			$this->setRows();
			return $this->rows[0]['term'];
	}
	public function chk_find_std($registed_courseID,$term){
			$this->sql ="SELECT  *
						FROM tbl_add_delete_course 
						WHERE DataID in(
							SELECT courseID
							FROM tbl_registed_course
							WHERE DataID=$registed_courseID
						)
							";
			$this->select();
			$this->setRows();
			$DataID=$this->rows[0]['DataID'];
			$long_course=$this->rows[0]['courseID'];
			$name_course=$this->rows[0]['name'];
			$unit_course=$this->rows[0]['unit'];
			$hr_learn_course=$this->rows[0]['hr_learn'];
			$class_level_course=$this->rows[0]['class_level'];
			$status=$this->rows[0]['status'];



			$status=$this->rows[0]['status'];
			$class_level=$this->get_class_level($class_level_course);
			$unit_data=$this->get_unit_data($unit_course);
			$status_data=$this->rows[0]['status'];
			$term=$this->get_term_data($registed_courseID);
			$year_data=$this->get_year_data($registed_courseID);
			$term_new=$this->get_term($unit_course,$status_data,$term);
			if ($class_level_course=='p1' || $class_level_course=='p2' || $class_level_course=='p3' || $class_level_course=='p4' || $class_level_course=='p5' || $class_level_course=='p6') {
				$class_level_status='p';
			}else{
				$class_level_status='m';
			}
			$this->sql ="SELECT COUNT(distinct room) as num_room
						FROM tbl_student 
						WHERE std_ID in(
							SELECT stdID
							FROM tbl_course_teaching_std
							WHERE registed_courseID=$registed_courseID
						)
						
							";
			$this->select();
			$this->setRows();
			$num_room=$this->rows[0]['num_room'];
			if ($num_room!=0) {
				$this->sql ="SELECT distinct room
						FROM tbl_student 
						WHERE std_ID in(
							SELECT stdID
							FROM tbl_course_teaching_std
							WHERE registed_courseID=$registed_courseID
						)
						
							";
				$this->select();
				$this->setRows();
				foreach($this->rows as $key => $value) {
					$room=$value['room'];
					$data.='
						 			<tr style="text-align:center;">
	                                  
	                                  <td style="text-align:left;padding-left:3%;">'.$long_course.'</td>
	                                  <td style="text-align:left;padding-left:8%;"><a href="index.php?op=regis_course_teaching-edit_student&id='.$registed_courseID.'&room='.$room.'&courseID='.$DataID.'&term='.$term_new.'&year='.$year_data.'&status='.$status.'&class_level_status='.$class_level_status.'">'.$name_course.'</a></td>
	                                  <td>'.$unit_data.'</td>
	                                  <td>'.$hr_learn_course.'</td>
	                                  <td>'.$class_level .'</td>
	                                  <td>'.$room.'</td>
	                                  <td>'.$term_new.'</td>
	                                  <td>'.$year_data.'</td>
	                                  <td>
	                                     <div class="bt_delete" data-id="'.$registed_courseID.'-'.$room.'" aria-hidden="true" data-toggle="modal" data-target="#modalConfirm">
	                                      <span class="glyphicon glyphicon-trash edit-icon-table"></span>
	                                    </div>
	                                  </td>
	                                </tr>
					';
				}
			}else{
				$data.='
						 			<tr style="text-align:center;">
	                                  
	                                  <td style="text-align:left;padding-left:3%;">'.$long_course.'</td>
	                                  <td style="text-align:left;padding-left:8%;"><a href="index.php?op=regis_course_teaching-edit_student&id='.$registed_courseID.'&room=0&courseID='.$DataID.'&term='.$term_new.'&year='.$year_data.'">'.$name_course.'</a></td>
	                                  <td>'.$unit_data.'</td>
	                                  <td>'.$hr_learn_course.'</td>
	                                  <td>'.$class_level .'</td>
	                                  <td>ยังไม่เลือกนักเรียน</td>
	                                  <td>'.$term_new.'</td>
	                                  <td>'.$year_data.'</td>
	                                  <td>
	                                     <div class="bt_delete" data-id="'.$registed_courseID.'" aria-hidden="true" data-toggle="modal" data-target="#modalConfirm">
	                                      <span class="glyphicon glyphicon-trash edit-icon-table" style="top:-1px;"></span>
	                                    </div>
	                                  </td>
	                                </tr>
					';
				}
			
			
			return $data;
	}
	public function get_registed_course_teaching(){
		$user_id=$_SESSION['ss_user_id'];
		$data_response = array();	 

			$this->sql ="SELECT *
			FROM tbl_set_term_year
				";
			$this->select();
			$this->setRows();
			$year=$this->rows[0]['year'];	
			$term=$this->rows[0]['term'];

			$this->sql ="SELECT *
			FROM tbl_registed_course_teaching
			WHERE registed_courseID in(
				SELECT DataID
				FROM tbl_registed_course
				WHERE year='$year'
				AND DataID in(
					SELECT regis_course_id
					FROM tbl_course_teacher
					WHERE teacher_id=$user_id
				)
			)
				";
			$this->select();
			$this->setRows();
			$num=1;
			foreach($this->rows as $key => $value) {
				$registed_courseID=$value['registed_courseID'];

				$chk_find.=$this->chk_find_std($registed_courseID,$term);
				$data.='number '.$registed_courseID.'is ' .$chk_find;
				$num++;
			}
			return json_encode($chk_find);
	}
	public function data_add_std($data_val,$course_id,$term_search,$year_search){

		$sql="SELECT *
			FROM tbl_registed_course 
			WHERE courseID=$course_id
			AND year='$year_search'
			AND term='$term_search'
				";
			$this->sql =$sql;
			$this->select();
			$this->setRows();
		$courseID=$this->rows[0]['DataID'];	

		/*$sql="SELECT *
			FROM tbl_add_delete_course 
			WHERE DataID=$course_id
				";
			$this->sql =$sql;
			$this->select();
			$this->setRows();
		$class_level=$this->rows[0]['class_level'];	*/

		$cdate=date("Y-m-d");
		$arr_id = explode(",", $data_val);

		$num=0;
		for ($i=0; $i < count($arr_id) ; $i++) { 
            $this->sql ="INSERT INTO tbl_course_teaching_std(registed_courseID,stdID,cdate) VALUES($courseID,'{$arr_id[$i]}','$cdate')";
	        $this->query();
	        $new_id = $this->insertID();
	      /*  if ($class_level=='p1' || $class_level=='p2' || $class_level=='p3' || $class_level=='p4' || $class_level=='p5' || $class_level=='p6') {
		        	 for ($j=1; $j <=40 ; $j++) { 
		        	$this->sql ="INSERT INTO tbl_attend_class(course_teaching_stdID,week,score_status) 
		        				VALUES($new_id,$j,0)";
		        	$this->query();
		        	}	   
		        }else{
		        	 for ($j=1; $j <=20 ; $j++) { 
		        	$this->sql ="INSERT INTO tbl_attend_class(course_teaching_stdID,week,score_status) 
		        				VALUES($new_id,$j,0)";
		        	$this->query();
		        	}	   
			}*/
	        
	        
        $num=$num+$i;
		}
		return $num;
	}
	public function get_std_list($id_std_search,$search_class_modal,$search_room_modal,$course_id,$term_search,$year_search){
		$sql="SELECT *
			FROM tbl_add_delete_course 
			WHERE DataID=$course_id
				";
			$this->sql =$sql;
			$this->select();
			$this->setRows();
		$status_form=$this->rows[0]['status_form'];	
		$sql="SELECT *
			FROM tbl_registed_course 
			WHERE courseID=$course_id
			AND term='$term_search'
			AND year='$year_search'
				";
			$this->sql =$sql;
			$this->select();
			$this->setRows();
		$registed_courseID=$this->rows[0]['DataID'];	
		$data_response = array();	
		
		$condition_sql.="std_ID is not null  ";
		if ($id_std_search=="" && $search_class_modal=="" && $search_room_modal=="") {
			$condition_sql.=" AND class_level='p1' AND room='1' ";
		}			
		if (isset($id_std_search) && $id_std_search != "") {
			$condition_sql .= " AND ( std_ID LIKE '%{$id_std_search}%')   ";
		}
		if (isset($search_class_modal) && $search_class_modal != "") {
			$condition_sql .= " AND ( class_level = '$search_class_modal')   ";
		}
		if (isset($search_room_modal) && $search_room_modal != "") {
			$condition_sql .= " AND ( room = '$search_room_modal')   ";
		}

			$this->sql ="SELECT count(*) num_row
					FROM tbl_student 
					WHERE $condition_sql

					";
			$this->select();
			$this->setRows();
		$num_row=$this->rows[0]['num_row'];	

		if ($num_row!=0) {
			$sql="SELECT *
			FROM tbl_student 
			WHERE $condition_sql
			ORDER BY class_level ASC,
			CASE
				WHEN name_title LIKE '%dekchai%' THEN 0
		        WHEN name_title LIKE '%nai%' THEN 1
		        WHEN name_title LIKE '%dekying%' THEN 2
		        WHEN name_title LIKE '%nangsaw%'THEN 3
		        WHEN std_ID THEN 4      
		    END

				";
			$this->sql =$sql;
			$this->select();
			$this->setRows();

			foreach($this->rows as $key => $value) {
				$std_ID=$value['std_ID'];

				//$data_response['asd']=$std_ID;
				
				$name_title=$value['name_title'];
				$std_ID_status=$this->chk_std_id($std_ID,$registed_courseID,$status_form,$term_search,$year_search,$name_title);
				$name_title_con=$this->get_name_title($name_title);
				$fname=$value['fname'];
				$lname=$value['lname'];
				$class_level_data=$value['class_level'];
				$class_level=$this->get_class_level($class_level_data);
				$room=$value['room'];
				
				if ($std_ID_status==0) {
					$data_response['std_list'].='
								  <tr>    
	                                  <td style="text-align: center;">      
	                                    <input class="checkbox_data" type="checkbox" value="'.$std_ID.'" name="checkbox_delete[]" id="checkbox'.$std_ID.'">             
	                                  </td>                             
	                                  <td style="text-align: center;">'.$std_ID.'</td>
	                                  <td style="text-align:left;pl-20">'.$name_title_con.'</td>
	                                  <td style="text-align:left;pl-20">'.$fname.'</td>
	                                  <td style="text-align:left;pl-20">'.$lname.'</td>
	                                  <td style="text-align: center;">'.$class_level.'</td>
	                                  <td style="text-align: center;">'.$room.'</td>    
	                                </tr>
					';	
				}else{
					$data_response['std_list'].='';
				}	

			}
		}else{	
			$data_response['std_list'].='';
		}
		
			$data_response['std_ID_status']=$registed_courseID;
			return json_encode($data_response);
	}

	public function chk_std_id($std_ID_status,$registed_courseID,$status_form,$term_search,$year_search,$name_title){
		if ($status_form==21) {
			$sql="SELECT *
			FROM tbl_registed_course
			WHERE term ='$term_search'
			AND year='$year_search'
			AND courseID in(
				SELECT DataID
				FROM tbl_add_delete_course 
				WHERE status_form=21
				
			)
				";
			$this->sql =$sql;
			$this->select();
			$this->setRows();
			$count_data_set=0;
			foreach($this->rows as $key => $value) {
				$count_std_choomnoom=$this->get_count_std_choomnoom($value['DataID'],$std_ID_status);
				$count_data_set=$count_data_set+$count_std_choomnoom;
			}
			$data=$count_data_set;
		}else if($status_form==22){
			if ($name_title=='dekying') {
				$data=1;
			}else{
				$data=0;
			}

		}else if($status_form==23){
			if ($name_title=='dekying') {
				$data=0;
			}else{
				$data=1;
			}

		}else{
			$sql="SELECT count(*) as num_row_status
			FROM tbl_course_teaching_std 
			WHERE stdID='$std_ID_status'
			AND registed_courseID=$registed_courseID	
				";
			$this->sql =$sql;
			$this->select();
			$this->setRows();
			$data=	$this->rows[0]['num_row_status'];
		}
		return $data;
	}
	public function get_count_std_choomnoom($regis_id,$std_ID_status){
			$sql="SELECT count(*) as num_row
			FROM tbl_course_teaching_std 
			WHERE stdID='$std_ID_status'
			AND registed_courseID=$regis_id
			";
			$this->sql =$sql;
			$this->select();
			$this->setRows();
			return	$this->rows[0]['num_row'];
	}
	public function get_name_to_add_std($data_id_first,$registed_course_id,$term_search,$year_search){
		$data_response = array();
		$sql="SELECT *
			FROM tbl_add_delete_course 
			WHERE DataID=$data_id_first			
				";
			$this->sql =$sql;
			$this->select();
			$this->setRows();
			$data_response['name']=$this->rows[0]['name'];
			$data_response['status']=$this->rows[0]['status'];
			$class_level=$this->rows[0]['class_level'];	
			if ($class_level=='p1' || $class_level=='p2' || $class_level=='p3' || $class_level=='p4' || $class_level=='p5' || $class_level=='p6') {
				$data_response['class_level_status']='p';
			}else{
				$data_response['class_level_status']='m';
			}
			if ($registed_course_id=="") {
				$registed_course_id=$this->get_registed_course_id($data_id_first,$term_search,$year_search);
			}
			$this->sql ="SELECT count(*) as num_row
						FROM tbl_registed_course_teaching 
						WHERE registed_courseID=$registed_course_id						
							";
			$this->select();
			$this->setRows();
			$data_response['num_row']=$this->rows[0]['num_row'];
			return json_encode($data_response);
	}
	public function search_course_class($department_search,$class_level_search,$term_search,$year_search){
		$data_response = array();
		$condition_sql="DataID > 0";
		$condition_sql_date="DataID > 0";
		if (isset($department_search) && $department_search != "") {
			if ($department_search=="dev_mode") {
				$condition_sql .= " AND ( status=2 ) ";
			}else{
				$condition_sql .= " AND ( department = '$department_search')  ";
			}
			
		}
		if (isset($class_level_search) && $class_level_search != "") {
			$condition_sql .= " AND ( class_level = '$class_level_search')  ";
		}


		if (isset($term_search) && $term_search != "") {
			$condition_sql_date .= " AND ( term = '$term_search')  ";
		}
		if (isset($year_search) && $year_search != "") {
			$condition_sql_date .= " AND ( year = '$year_search')  ";
		}
		/*$year_now=date("Y");
		$year_now_set=$year_now+543;*/
		$this->sql ="SELECT count(*) as num_row_data
					FROM tbl_add_delete_course 
					WHERE $condition_sql
					AND DataID in(
						SELECT courseID
						FROM tbl_registed_course 
						WHERE $condition_sql_date
						
					)
						";
		$this->select();
		$this->setRows();
		$num_row_data=$this->rows[0]['num_row_data'];
		if ($num_row_data!=0) {
			$sql="SELECT *
						FROM tbl_add_delete_course 
						WHERE $condition_sql			
						AND DataID in(
							SELECT courseID
							FROM tbl_registed_course 
							WHERE $condition_sql_date
						)
						ORDER BY courseID ASC
							";
			$this->sql =$sql;
			$this->select();
			$this->setRows();
			foreach($this->rows as $key => $value) {
				$DataID=$value['DataID'];
				$courseID=$value['courseID'];
			
				if ($key==0) {
					$data_response['data_id_first']=$DataID;
					$data_response['registed_course_id']=$this->get_registed_course_id($DataID,$term_search,$year_search);
				}
				$data_response['dropdown_list'].='
								<option value="'.$DataID.'">'.$courseID.'</option>
				';	
			}

		}else{
			$data_response['dropdown_list']='<option>ไม่พบรหัสวิชา</option>';
			$data_response['course_name']='ไม่พบรายวิชา';
			$data_response['data_id_first']="";
		}

		echo json_encode($data_response);
		
	}
	
	public function hide_class_std($data_id_first){
		$data_response = array();
		$sql="SELECT *
			FROM tbl_add_delete_course 
			WHERE DataID=$data_id_first		
		
							";
			$this->sql =$sql;
			$this->select();
			$this->setRows();
		$class_level=$this->rows[0]['class_level'];
		if ($class_level=="p1") {
			$data_response='<option value="p1"> ป.1</option>';
		}elseif($class_level=="p2"){
			$data_response='<option value="p2"> ป.2</option>';
		}elseif($class_level=="p3"){
			$data_response='<option value="p3"> ป.3</option>';
		}elseif($class_level=="p4"){
			$data_response='<option value="p4"> ป.4</option>';
		}elseif($class_level=="p5"){
			$data_response='<option value="p5"> ป.5</option>';
		}elseif($class_level=="p6"){
			$data_response='<option value="p6"> ป.6</option>';
		}elseif($class_level=="m1"){
			$data_response='<option value="m1"> ม.1</option>';
		}elseif($class_level=="m2"){
			$data_response='<option value="m2"> ม.2</option>';
		}elseif($class_level=="m3"){
			$data_response='<option value="m3"> ม.3</option>';
		}elseif($class_level=="m4"){
			$data_response='<option value="m4"> ม.4</option>';
		}elseif($class_level=="m5"){
			$data_response='<option value="m5"> ม.5</option>';
		}elseif($class_level=="m6"){
			$data_response='<option value="m6"> ม.6</option>';
		}
		return json_encode($data_response);
	}
	public function get_registed_course_id($courseID,$term_search,$year_now_set){
			$this->sql ="SELECT *
						FROM tbl_registed_course 
						WHERE courseID=$courseID
						AND year='$year_now_set'
						AND term='$term_search'
							";
			$this->select();
			$this->setRows();
			$DataID=$this->rows[0]['DataID'];
			return $DataID;

	}
	public function get_class_level($class_level_data){
		if ($class_level_data=="p1") {
			$class_level="ป.1";
		}elseif($class_level_data=="p2"){
			$class_level="ป.2";	
		}elseif($class_level_data=="p3"){
			$class_level="ป.3";	
		}elseif($class_level_data=="p4"){
			$class_level="ป.4";	
		}elseif($class_level_data=="p5"){
			$class_level="ป.5";	
		}elseif($class_level_data=="p6"){
			$class_level="ป.6";	
		}elseif($class_level_data=="m1"){
			$class_level="ม.1";	
		}elseif($class_level_data=="m2"){
			$class_level="ม.2";	
		}elseif($class_level_data=="m3"){
			$class_level="ม.3";	
		}elseif($class_level_data=="m4"){
			$class_level="ม.4";	
		}elseif($class_level_data=="m5"){
			$class_level="ม.5";	
		}elseif($class_level_data=="m6"){
			$class_level="ม.6";	
		}
		return $class_level;
	}
}
?><file_sep>/modules/attend_class/process.php
<?php
@ob_start();
@session_start();

require_once('../../init.php');
include('../../src/class.pagination.php');
include('../../src/class.inputfilter.php');
$InputFilter = new InputFilter();

##CLASS_DB_CONNECT##
include('class_modules.php');
$class_data = new ClassData();
##CLASS_DB_CONNECT##

if(isset($_GET['acc_action']) and $_GET['acc_action'] == "add_attend"){
	$value_loop=$_GET['value_loop'];
	$set_attend_day_id=$_GET['set_attend_day_id'];
	$course_teaching_stdID=$_GET['course_teaching_stdID'];
	$length_list_val=$_GET['length_list_val'];
	
	if ($value_loop==3) {
		$attend_value_1=$_GET['attend_value_1'];
		$attend_value_2=$_GET['attend_value_2'];
		$attend_value_3=$_GET['attend_value_3'];
		echo $class_data->add_attend($value_loop,$course_teaching_stdID,$set_attend_day_id,$length_list_val,$attend_value_1,$attend_value_2,$attend_value_3);	
	}elseif($value_loop==2){
		$attend_value_1=$_GET['attend_value_1'];
		$attend_value_2=$_GET['attend_value_2'];
		echo $class_data->add_attend($value_loop,$course_teaching_stdID,$set_attend_day_id,$length_list_val,$attend_value_1,$attend_value_2);	
	}elseif($value_loop==1){
		$attend_value_1=$_GET['attend_value_1'];
		echo $class_data->add_attend($value_loop,$course_teaching_stdID,$set_attend_day_id,$length_list_val,$attend_value_1);	
	}
	
}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "insert_value_in_attend"){
	$value=$_GET['value'];
	$week=$_GET['week'];
	$set_attend_day_id=$_GET['set_attend_day_id'];
	$course_teaching_stdID=$_GET['course_teaching_stdID'];
	
	$registed_course_id=$_GET['registed_course_id'];
	$attend_class_week_listID=$_GET['attend_class_week_listID'];
	
	echo $class_data->insert_value_in_attend($registed_course_id,$value,$week,$set_attend_day_id,$course_teaching_stdID,$attend_class_week_listID);	
}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "set_hr"){
	$registed_course_id=$_GET['registed_course_id'];
	$value_day=$_GET['value_day'];
	$hr_set=$_GET['hr_set'];
	echo $class_data->set_hr($registed_course_id,$value_day,$hr_set);	
}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "set_day"){
	$registed_course_id=$_GET['registed_course_id'];
	$value_day=$_GET['value_day'];
	$hr_set=$_GET['hr_set'];
	$room_search=$_GET['room_search'];
	$coures_id_list_val=$_GET['coures_id_list_val'];
	
	echo $class_data->set_day($registed_course_id,$value_day,$hr_set,$room_search,$coures_id_list_val);	
}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_day_set"){
	$registed_course_id=$_GET['registed_course_id'];
	$room_search=$_GET['room_search'];
	echo $class_data->get_day_set($registed_course_id,$room_search);
		
}

if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_week_between"){
	$coures_id_list_val=$_GET['coures_id_list_val'];
	echo $class_data->get_week_between($coures_id_list_val);	
}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_count_adttend_class_val"){
	$coures_id_list_val=$_GET['coures_id_list_val'];
	echo $class_data->get_count_adttend_class_val($coures_id_list_val);	
}
if(isset($_POST['acc_action']) and $_POST['acc_action'] == "save_attend_score_std"){
	$std_id_all=$_POST['std_id_all'];	
	$value_attend_week=$_POST['value_attend_week'];
	$all_attendID=$_POST['all_attendID'];

	$coures_id_list_val=$_POST['coures_id_list_val'];
	//$set_count_adttend_class_val=$_POST['set_count_adttend_class_val'];
	
	$arr_std_id_all = explode("-", $std_id_all);
	$arr_value_attend_week = explode(",", $value_attend_week);
	$arr_all_attendID = explode("-", $all_attendID);
	$num_1=0;

	for ($i=0; $i <count($arr_std_id_all) ; $i++) {
		for ($k=0; $k < 10; $k++) { 
			$class_data->sql ="
			UPDATE tbl_attend_class SET score_status='$arr_value_attend_week[$num_1]' WHERE DataID=$arr_all_attendID[$num_1]
			";	
   	 		echo $class_data->query();		
	   	 	$num_1++;
		}
	}
	//echo $class_data->set_count_adttend_class_val($coures_id_list_val,$set_count_adttend_class_val);
}

if(isset($_GET['acc_action']) and $_GET['acc_action'] == "save_attend"){	
	$status=$_GET['status'];
	$attend_id=$_GET['attend_id'];
	$course_teaching_stdID=$_GET['course_teaching_stdID'];
	$set_attend_day_id=$_GET['set_attend_day_id'];
	$week=$_GET['week'];
	
	$class_data->sql ="SELECT COUNT(*) as attend_count
				FROM tbl_attend_class_std 	
				WHERE DataID=$attend_id
				";
	$class_data->select();
	$class_data->setRows();
	$attend_count=$class_data->rows[0]['attend_count'];	
	if ($attend_id==0) {
		$class_data->sql ="INSERT INTO tbl_attend_class_std(course_teaching_std_id,set_attend_day_id,week,status) VALUES($course_teaching_stdID,$set_attend_day_id,$week,'$status')	";							
		$class_data->query();
	}else{
		if ($status=='1') {
			$class_data->sql ="DELETE FROM tbl_attend_class_std WHERE DataID=$attend_id" ;
			$class_data->query();
		}else{
			$class_data->sql ="UPDATE tbl_attend_class_std SET status='$status' WHERE DataID=$attend_id";				
			$class_data->query();
		}
	}
	/*if ($attend_count>0) {
		if ($status=='1') {
			$class_data->sql ="DELETE FROM tbl_attend_class_std WHERE DataID=$attend_id" ;
			$class_data->query();
		}else{
			$class_data->sql ="UPDATE tbl_attend_class_std SET status='$status' WHERE DataID=$attend_id";				
			$class_data->query();
		}
	}else{
		$class_data->sql ="INSERT INTO tbl_attend_class_std(course_teaching_std_id,set_attend_day_id,week,status) VALUES($course_teaching_stdID,$set_attend_day_id,$week,'$status')	";							
		$class_data->query();
	}*/
	echo json_encode(1);
}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_week_list_data"){	
	$room_search=$_GET['room_search'];
	$coures_id_list_val=$_GET['coures_id_list_val'];
	$length_list_val=$_GET['length_list_val'];	
	$registed_course_teaching_id=$_GET['registed_course_teaching_id'];	
	$user_status=$_SESSION['ss_status'];
	if ($user_status==1) {
		echo $class_data->get_week_list_data($coures_id_list_val,$length_list_val,$room_search,$registed_course_teaching_id);
	}elseif($user_status==2){
		$term_data=$_GET['term_data'];
		$year_data=$_GET['year_data'];
		echo $class_data->get_week_list_data_admin($coures_id_list_val,$length_list_val,$room_search,$registed_course_teaching_id,$term_data,$year_data);
	}
	
}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_day_list"){	
	$length_list_val=$_GET['length_list_val'];
	$registed_course_id=$_GET['registed_course_id'];
	$room_search=$_GET['room_search'];
	
	echo $class_data->get_day_list($length_list_val,$registed_course_id,$room_search);
}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "search_course_detail"){	
	$coures_id_list=$_GET['coures_id_list'];
	$room_search=$_GET['room_search'];
	$term_data=$_GET['term_data'];
	$year_data=$_GET['year_data'];
	echo $class_data->search_course_detail($coures_id_list,$room_search,$term_data,$year_data);
}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_class_level"){	
	$coures_id_list_val=$_GET['coures_id_list_val'];
	$user_status=$_SESSION['ss_status'];
	if ($user_status==1) {
		echo $class_data->get_class_level($coures_id_list_val);
	}elseif($user_status==2){
		$term_data=$_GET['term_data'];
		$year_data=$_GET['year_data'];
		echo $class_data->get_class_level_admin($coures_id_list_val,$term_data,$year_data);
	}
	
}

if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_coures_id_list"){	
	$user_status=$_SESSION['ss_status'];
	if ($user_status==1) {
		echo $class_data->get_coures_id_list();
	}elseif($user_status==2){
		$term_data=$_GET['term_data'];
		$year_data=$_GET['year_data'];
		echo $class_data->get_coures_id_list_admin($term_data,$year_data);
	}
	
}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_year"){	
	echo $class_data->get_year();
}<file_sep>/config.php
<?php
	@header( 'Pragma: no-cache' );
	@header( 'Content-Type:text/html; charset=utf-8');
	date_default_timezone_set('Asia/Bangkok');
	error_reporting(0);

	/*Database Connect *************************************************************/
		//ONLINE
		// define("DB_SERVER","localhost");
		// define("DB_USER","hishield_db");	
		// define("DB_PASS","<PASSWORD>");
		// define("DB_DATABASE","hishield_db");


		// OFFLINE : LOCALHOST
		define("DB_SERVER","localhost");
		define("DB_USER","root");	
		define("DB_PASS","");
		define("DB_DATABASE","sratongact_eva");


?>

<file_sep>/modules/print/process.php
<?php
@ob_start();
@session_start();

require_once('../../init.php');
include('../../src/class.pagination.php');
include('../../src/class.inputfilter.php');
$InputFilter = new InputFilter();

##CLASS_DB_CONNECT##
include('class_modules.php');
$class_data = new ClassData();
##CLASS_DB_CONNECT##

if(isset($_GET['acc_action']) and $_GET['acc_action'] == "search_course_detail"){	
	$coures_id_list=$_GET['coures_id_list'];
	$room_search=$_GET['room_search'];
	echo $class_data->search_course_detail($coures_id_list,$room_search);
}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_class_level"){	
	$coures_id_list_val=$_GET['coures_id_list_val'];
	echo $class_data->get_class_level($coures_id_list_val);
}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_coures_id_list"){	
	echo $class_data->get_coures_id_list();
}<file_sep>/src/class_db_test.php
<?php 
/*************************************** PROCESS DB ****************************************/
// -- SELECT * FROM pro_category WHERE lft <= 1 AND rgt >= 1 AND level > 0
// -- SELECT * FROM pro_category WHERE lft <= 23 AND rgt >= 23 AND level = 1
// -- SELECT * FROM pro_category WHERE lft >= 22 AND rgt <= 33 
// -- SELECT * FROM pro_category WHERE lft > 2 AND rgt < 15 and level=2
// -- SELECT *  FROM pro_category WHERE lft <= 2 AND rgt >= 2 AND level > 0 
// -- SELECT count(cat_id) as data_id_total FROM pro_category WHERE parent_id = 0  ORDER BY sequence DESC

class Members extends Databases {
	public function __construct($params=NULL){
		$this->module = $params['module']  ;
		 parent::__construct((empty($params['table']))?$module:$params['table'] );
	}

	public function ex_setrows_tb(){
		$this->sql = "select * from $this->table  " ;
		$this->select();  //update(); delete();
		$this->setRows();
		echo '<pre>';
		print_r($this->rows);
		echo '</pre>';

	}

	public function ex_getrows_tb(){
		$this->sql = "select * from our_people_photos " ;
		$this->select();
		return $this->getRows();
	}

	public function ex_getone_tb(){
		$this->sql = "select opp_id from our_people_photos where our_id='2' limit 0,1 " ;
		$this->select();
		$this->setRows();
		return $this->rows[0]['opp_id'];
	}

	// public function ex_getrows_tb(){
	// 	$this->sql = "inset into our_people_photos ('.......') " ;
	// 	$this->insert();
	// 	return $this->insertID();
	// } 


	
}


?><file_sep>/modules/regis_student/index.js
var opPage = 'regis_student';
$(document).ready(function() {
	years_set();
	get_day(1);
	get_term_year_now();
}); 
$(function () {
  $('[data-toggle="tooltip"]').tooltip()
})
$(document).delegate('#exit_std', 'click', function(event) {
	window.location.reload();
});
$(document).delegate('#uploadBtn_select', 'click', function(event) {
	$('#uploadBtn').trigger('click');
});
$( "#uploadBtn" ).change(function() {
	$("#modalWaitUp").modal("show");
	var year_main =$("#year_main").val();
	var file_data = $('#uploadBtn').prop('files')[0];   
    var form_data = new FormData();     

    form_data.append('file', file_data);
    form_data.append('year_main', year_main);
    //alert(form_data);                             
    $.ajax({
                url: 'modules/regis_student/upload_one.php', // point to server-side PHP script 
                dataType: 'text',  // what to expect back from the PHP script, if anything
                cache: false,
                contentType: false,
                processData: false,
                data: form_data,                         
                type: 'post',
                success: function(data){
                	$(".modal").modal("hide");
                	$("#table_list").html(data);
                	$("#modalstdshow").modal("show");
                	
                	
                    //alert 	(php_script_response); // display response from the PHP script, if any
                }
     });
});
function form_reset(form_se) {
	$("#"+form_se)[0].reset();
}
function send_data() {
		var formData = $( "#frm_data" ).serializeArray();
		var year_main =$("#year_main").val();

		formData.push({ "name": "acc_action", "value": "save_data" }); 
		formData.push({ "name": "year_main", "value": year_main }); 
		
		$.post('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {
			// console.log(data);
			// return false;
			$(".modal").modal("hide");
			$("#modalRegistered").modal("show");
			$("#std_ID").attr( "placeholder", "" );
			$("#card_ID").attr( "placeholder", ""  );
			form_reset("frm_data");
		});
}
function isNumber(data){
    data = data +"e1";                      // Disallow eng. notation "10e2"+"e1" is NaN
    var clean = parseFloat(data,10) / data ; // 1 if parsed cleanly
    return (clean && (data/data) === 1.0);  // Checks for NaN
}
$(document).delegate('#btn__save', 'click', function(event) {
	$("#std_ID").addClass("form-set");
	$("#card_ID").addClass("form-set");
	var std_ID =$("#std_ID").val();
	var card_ID =$("#card_ID").val();
	if(std_ID!='' && card_ID!='') {
		var formData = new Array();
		formData.push({ "name": "acc_action", "value": "chk_id" }); 
		formData.push({ "name": "std_ID", "value": std_ID }); 
		formData.push({ "name": "card_ID", "value": card_ID }); 
		$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {	
			if (data.num_std_ID=="1") {
				$(".modal").modal("hide");
				$("#std_ID").removeClass("form-set");
				$("#std_ID").addClass("form-set-null-data");
				$("#std_ID").attr( "placeholder", "รหัส "+std_ID+" มีอยู่ในระบบแล้ว" );
				$("#std_ID").val("");
			}
			if(data.num_card_ID=="1"){
				$(".modal").modal("hide");
				$("#card_ID").removeClass("form-set");
				$("#card_ID").addClass("form-set-null-data");
				$("#card_ID").attr( "placeholder", "รหัส "+card_ID+" มีอยู่ในระบบแล้ว"  );
				$("#card_ID").val("");
			}					
			if (data.num_std_ID=="0" && data.num_card_ID=="0") {
				var num_card_ID=card_ID.length;
				if (num_card_ID>13) {
					$(".modal").modal("hide");
					$("#card_ID").removeClass("form-set");
					$("#card_ID").addClass("form-set-null-data");
					$("#card_ID").attr( "placeholder", "รหัสบัตรประชาชนเกิน 13 หลัก"  );
					$("#card_ID").val("");
				}else if(num_card_ID<13){
					$(".modal").modal("hide");
					$("#card_ID").removeClass("form-set");
					$("#card_ID").addClass("form-set-null-data");
					$("#card_ID").attr( "placeholder", "รหัสบัตรประชาชนไม่ถึง 13 หลัก"  );
					$("#card_ID").val("");
				}else{
					var card_id_sck=isNumber(card_ID);
					if (card_id_sck==true) {
						send_data();				
					}else{
						$(".modal").modal("hide");
						$("#card_ID").removeClass("form-set");
						$("#card_ID").addClass("form-set-null-data");
						$("#card_ID").attr( "placeholder", "ใส่ข้อมูลเป็นตัวเลขเท่านั้น"  );
						$("#card_ID").val("");
					}
					
				}
				
			}

		});
		
	}else{
		$(".modal").modal("hide");
		if(std_ID==""){
			$("#std_ID").removeClass("form-set");
			$("#std_ID").addClass("form-set-null-data");
			$("#std_ID").attr( "placeholder", "กรุณาใส่ข้อมูล" );
		}
		if(card_ID==""){
			$("#card_ID").removeClass("form-set");
			$("#card_ID").addClass("form-set-null-data");
			$("#card_ID").attr( "placeholder", "กรุณาใส่ข้อมูล" );
		}


	}
	

});
function get_term_year_now() {
	var formData = new Array();
	formData.push({ "name": "acc_action", "value": "get_term_year_now" }); 
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {
		var year=data.year;
		var year_now=data.year_now;	
		var year_last=year_now-5;;
		var year_set=document.getElementById("year_main");	
		var year_now_max=year_now+1;
		year_set.innerHTML += '<option selected="selected" value="'+year_now_max+'"> ปีการศึกษา'+year_now_max+'</option>';
		for (var i = year_now; i >= year_last; i--) {
			if (i==year) {
				year_set.innerHTML += '<option selected="selected" value="'+i+'"> ปีการศึกษา'+i+'</option>';
			}else{
				year_set.innerHTML += '<option value="'+i+'">ปีการศึกษา '+i+'</option>';
			}	
		}
	});
}
function years_set() {
	var formData = new Array();
	formData.push({ "name": "acc_action", "value": "get_years" }); 
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {
		$("#years_set").html(data.set_years);
	});
}
function get_day(mouth) {
	//var formData = $( "#frm_data" ).serializeArray();
	var formData = new Array();
	formData.push({ "name": "acc_action", "value": "get_day" }); 
	formData.push({ "name": "mouth", "value": mouth }); 
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {
		console.log(data.day_set)
		$("#day_set").html(data.day_set);
	});

}<file_sep>/modules/regis_student/class_room.php
<?php
@ob_start();
@session_start();

require_once('../../init.php');
include('../../src/class.pagination.php');
include('../../src/class.inputfilter.php');
$InputFilter = new InputFilter();

##CLASS_DB_CONNECT##
include('class_modules.php');
$class_data = new ClassData();

$class_data->sql ="SELECT  *
				   FROM tbl_student
				
						";
$class_data->select();
$class_data->setRows();	
foreach($class_data->rows as $key => $value) {
	$std_ID=$value['std_ID'];
	$class_level=$value['class_level'];
	$room=$value['room'];
	$data_response.="
		insert into tbl_std_class_room(std_ID,class_level,room,year) values('$std_ID','$class_level','$room','2558');<br>
	";
}
echo $data_response;<file_sep>/modules/print/pdf_form.php
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="../../assets/css/bootstrap.css" rel="stylesheet" type="text/css">
<link href="../../assets/css/margin-padding.css" rel="stylesheet" type="text/css">
<link href="../../assets/css/responsive.css" rel="stylesheet" type="text/css">
<link href="../../assets/css/print.css?<?php echo date('l jS \of F Y h:i:s A'); ?>" rel="stylesheet" type="text/css">

<script type="text/javascript" src="../../assets/js/jquery.js"></script>

<style type="text/css">
<!--
 table {
    border-collapse: collapse;
}

td, th {
    border: 1px solid black;
    padding: 5px;
}
-->
</style>
<?php

 @session_start();
    include('logo.php');
    require_once('../../init.php');
    include('class_modules.php');
    $class_data = new ClassData();

$data_id=$_POST['data_id'];
$room_search=$_POST['room_search'];
$status=$_POST['status'];
$status_form=$_POST['status_form'];

$page=$_POST['page'];
$class_data->sql ="SELECT *
        FROM tbl_add_delete_course   
        WHERE DataID=$data_id
        ";
  $class_data->select();
  $class_data->setRows();
  $courseID=$class_data->rows[0]['courseID'];
  $name=$class_data->rows[0]['name'];
  $class_level=$class_data->rows[0]['class_level'];

$class_data->sql ="SELECT *
        FROM tbl_set_term_year   
        ";
  $class_data->select();
  $class_data->setRows();
  $term=$class_data->rows[0]['term'];
  $year=$class_data->rows[0]['year'];

  //$class_level_new=$class_data->get_class_level_new($class_level);
  if ($class_level=='p1' || $class_level=='p2' || $class_level=='p3' || $class_level=='p4' || $class_level=='p5' || $class_level=='p6') { 
    $class_level_remove=str_replace('p','',$class_level);
  }else{
    $class_level_remove=str_replace('m','',$class_level);
  }
  $get_grade_summary=$class_data->get_grade_summary($data_id,$room_search,$status);
  if($status==1/* || $page=='all_page'*/){
   
   $attend=$class_data->get_attend($data_id,$status,$room_search);
   $objective_list=$class_data->get_objective_list($data_id,$room_search);
   $std_desirable=$class_data->get_std_desirable($data_id,$room_search);
  }
  if ($status==2) {
    $attend=$class_data->get_attend($data_id,$status,$room_search);
    $std_desirable=$class_data->get_std_desirable($data_id,$room_search);
    $dev_summary=$class_data->get_dev_summary($data_id,$room_search); 
    $num_all_std_dev=$dev_summary['num_all_std'];
    $data_atte_pass=$dev_summary['data_atte_pass'];
    $data_atte_nopass=$dev_summary['data_atte_nopass'];

    $summary_atte_pass_per=round(($data_atte_pass*100)/$num_all_std_dev,2);
    $summary_atte_nopass_per=round(($data_atte_nopass*100)/$num_all_std_dev,2);
  }

  $num_all_std=$get_grade_summary['num_all_std'];

  $data_i=$get_grade_summary['data_i'];
  $data_atte=$get_grade_summary['data_atte'];

  $data_00=$get_grade_summary['data_00'];
  $data_10=$get_grade_summary['data_10'];
  $data_15=$get_grade_summary['data_15'];
  $data_20=$get_grade_summary['data_20'];
  $data_25=$get_grade_summary['data_25'];
  $data_30=$get_grade_summary['data_30'];
  $data_35=$get_grade_summary['data_35'];
  $data_40=$get_grade_summary['data_40'];

  $data_i=$get_grade_summary['data_i'];
  $data_atte=$get_grade_summary['data_atte'];

  $get_per_00=round(($data_00*100)/$num_all_std,2);
  $get_per_10=round(($data_10*100)/$num_all_std,2);
  $get_per_15=round(($data_15*100)/$num_all_std,2);
  $get_per_20=round(($data_20*100)/$num_all_std,2);
  $get_per_25=round(($data_25*100)/$num_all_std,2);
  $get_per_30=round(($data_30*100)/$num_all_std,2);
  $get_per_35=round(($data_35*100)/$num_all_std,2);
  $get_per_40=round(($data_40*100)/$num_all_std,2);

  $get_per_i=round(($data_i*100)/$num_all_std,2);
  $get_per_atte=round(($data_atte*100)/$num_all_std,2);

  $data_desirable_nopass=$get_grade_summary['data_desirable_nopass'];
  $data_desirable_pass=$get_grade_summary['data_desirable_pass'];
  $data_desirable_good=$get_grade_summary['data_desirable_good'];
  $data_desirable_verygood=$get_grade_summary['data_desirable_verygood'];

  $get_per_desirable_nopass=round(($data_desirable_nopass*100)/$num_all_std,2);
  $get_per_desirable_pass=round(($data_desirable_pass*100)/$num_all_std,2);
  $get_per_desirable_good=round(($data_desirable_good*100)/$num_all_std,2);
  $get_per_desirable_verygood=round(($data_desirable_verygood*100)/$num_all_std,2);

  $data_read_think_write_nopass=$get_grade_summary['data_read_think_write_nopass'];
  $data_read_think_write_pass=$get_grade_summary['data_read_think_write_pass'];
  $data_read_think_write_good=$get_grade_summary['data_read_think_write_good'];
  $data_read_think_write_verygood=$get_grade_summary['data_read_think_write_verygood'];

  $get_per_read_think_write_nopass=round(($data_read_think_write_nopass*100)/$num_all_std,2);
  $get_per_read_think_write_pass=round(($data_read_think_write_pass*100)/$num_all_std,2);
  $get_per_read_think_write_good=round(($data_read_think_write_good*100)/$num_all_std,2);
  $get_per_read_think_write_verygood=round(($data_read_think_write_verygood*100)/$num_all_std,2);
  if ($class_level=='p1' || $class_level=='p2' || $class_level=='p3') {
      $text_rtw_desc='
                      
                      <tr>
                          <td width="110px" style="vertical-align: top;border: none;padding-left:20px;">ตัวชี้วัดที่ 1</td>    
                          <td style="border: none;">สามารถอ่านและหาประสบการณ์จากสื่อที่หลากหลาย</td>      
                       </tr>
                       <tr>
                          <td width="110px" style="vertical-align: top;border: none;padding-left:20px;">ตัวชี้วัดที่ 2</td>    
                          <td style="border: none;">สามารถจับประเด็นสำคัญ ข้อเท็จจริง ความคิดเห็นเรื่องที่อ่าน</td>     
                       </tr>
                       <tr>
                          <td width="110px" style="vertical-align: top;border: none;padding-left:20px;">ตัวชี้วัดที่ 3</td>    
                          <td style="border: none;">สามารถเปรียบเทียบแง่มุมต่างๆ เช่น ข้อดี ข้อเสีย ประโยชน์ <br>โทษ ความเหมาะสม ไม่เหมาะสม</td>      
                       </tr>
                       <tr>
                          <td width="110px" style="vertical-align: top;border: none;padding-left:20px;">ตัวชี้วัดที่ 4</td>    
                          <td style="border: none;">สามารถแสดงความคิดเห็นต่อเรื่องที่อ่าน โดยมีเหตุผลประกอบ</td>      
                       </tr>
                       <tr>
                          <td width="110px" style="vertical-align: top;border: none;padding-left:20px;">ตัวชี้วัดที่ 5</td>    
                          <td style="border: none;">สามารถถ่ายทอดความคิดเห็นความรู้สึกจากเรื่องที่อ่านโดยการเขียน</td>      
                       </tr>
      ';
    }elseif($class_level=='p4' || $class_level=='p5' || $class_level=='p6') {
      $text_rtw_desc='
                      
                      <tr>
                          <td width="110px" style="vertical-align: top;border: none;padding-left:20px;">ตัวชี้วัดที่ 1</td>    
                          <td style="border: none;">สามารถอ่านเพื่อหาข้อมูลสารสนเทศเสริมประสบการณ์จากสื่อประเภท<br>ต่างๆ</td>     
                       </tr>
                       <tr>
                          <td width="110px" style="vertical-align: top;border: none;padding-left:20px;">ตัวชี้วัดที่ 2</td>    
                          <td style="border: none;">สามารถจับประเด็นสำคัญ เปรียบเทียบ เชื่อมโยงความเป็นเหตุเป็น<br>ผลจากเรื่องที่อ่าน</td>      
                       </tr>
                       <tr>
                          <td width="110px" style="vertical-align: top;border: none;padding-left:20px;">ตัวชี้วัดที่ 3</td>    
                          <td style="border: none;">สามารถเชื่อมโยงความสัมพันธ์ของเรื่องราว เหตุการณ์ของเรื่อง<br>ที่อ่าน</td>      
                       </tr>
                       <tr>
                          <td width="110px" style="vertical-align: top;border: none;padding-left:20px;">ตัวชี้วัดที่ 4</td>    
                          <td style="border: none;">สามารถแสดงความคิดเห็นต่อเรื่องที่อ่านโดยมีเหตุผลสนับสนุน</td>     
                       </tr>
                       <tr>
                          <td width="110px" style="vertical-align: top;border: none;padding-left:20px;">ตัวชี้วัดที่ 5</td>    
                          <td style="border: none;">สามารถถ่ายทอดความเข้าใจ ความคิดเห็น คุณค่าจากเรื่องที่อ่าน<br>โดยการเขียน</td>      
                       </tr>
      ';
    }elseif($class_level=='m1' || $class_level=='m2' || $class_level=='m3') {
      $text_rtw_desc='
                      
                      <tr>
                          <td width="110px" style="vertical-align: top;border: none;padding-left:20px;">ตัวชี้วัดที่ 1</td>    
                          <td style="border: none;">สามารถคัดสรรสื่อที่ต้องการอ่านเพื่อหาข้อมูลสารสนเทศได้ตาม<br>วัตถุประสงค์ สามารถสร้างความเข้าใจและประยุกต์ใช้ความรู้จากการอ่าน</td>      
                       </tr>
                       <tr>
                          <td width="110px" style="vertical-align: top;border: none;padding-left:20px;">ตัวชี้วัดที่ 2</td>    
                          <td style="border: none;">สามารถจับประเด็นสำคัญและประเด็นสนับสนุน โต้แย้ง</td>      
                       </tr>
                       <tr>
                          <td width="110px" style="vertical-align: top;border: none;padding-left:20px;">ตัวชี้วัดที่ 3</td>    
                          <td style="border: none;">สามารถวิเคราะห์ วิจารณ์ ความสมเหตุสมผล ความน่าเชื่อถือ ลำดับความ<br>และความเป็นไปได้ของเรื่องที่อ่าน</td>     
                       </tr>
                       <tr>
                          <td width="110px" style="vertical-align: top;border: none;padding-left:20px;">ตัวชี้วัดที่ 4</td>    
                          <td style="border: none;">สามารถสรุปคุณค่า แนวคิด แง่คิดที่ได้จากการอ่าน</td>     
                       </tr>
                       <tr>
                          <td width="110px" style="vertical-align: top;border: none;padding-left:20px;">ตัวชี้วัดที่ 5</td>    
                          <td style="border: none;">สามารถสรุป อภิปราย ขยายความ แสดงความคิดเห็น โต้แย้ง สนับสนุน<br> โน้มน้าว โดยการเขียนสื่อสารในรูปแบบต่าง ๆ เช่น ผังความคิด เป็นต้น</td>     
                       </tr>
      ';
    }elseif($class_level=='m4' || $class_level=='m5' || $class_level=='m6') {
      $text_rtw_desc='
                       
                        <tr>
                          <td width="110px" style="vertical-align: top;border: none;padding-left:20px;">ตัวชี้วัดที่ 1</td>    
                          <td style="border: none;">สามารถอ่านเพื่อการศึกษาค้นคว้า เพิ่มพูนความรู้ประสบการณ์และ<br>การประยุกต์ใช้ในชีวิตประจำวัน</td>     
                       </tr>
                       <tr>
                          <td width="110px" style="vertical-align: top;border: none;padding-left:20px;">ตัวชี้วัดที่ 2</td>    
                          <td style="border: none;">สามารถจับประเด็นสำคัญลำดับเหตุการณ์จากการอ่านสื่อที่มีความ<br>ซับซ้อน</td>      
                       </tr>
                       <tr>
                          <td width="110px" style="vertical-align: top;border: none;padding-left:20px;">ตัวชี้วัดที่ 3</td>    
                          <td style="border: none;">สามารถวิเคราะห์สิ่งที่ผู้เขียนต้องการสื่อสารกับผู้อ่านและสามารถ<br>วิพากษ์ ให้ข้อเสนอแนะในแง่มุมต่าง ๆ</td>      
                       </tr>
                       <tr>
                          <td width="110px" style="vertical-align: top;border: none;padding-left:20px;">ตัวชี้วัดที่ 4</td>    
                          <td style="border: none;">สามารถประเมินความน่าเชื่อถือ คุณค่า แนวคิดที่ได้จากสิ่งที่อ่าน<br>อย่างหลากหลาย</td>      
                       </tr>
                       <tr>
                          <td width="110px" style="vertical-align: top;border: none;padding-left:20px;">ตัวชี้วัดที่ 5</td>    
                          <td style="border: none;">สามารถเขียนแสดงความคิดเห็นโต้แย้ง สรุป โดยมีข้อมูลอธิบาย<br>สนับสนุนอย่างเพียงพอและสมเหตุสมผล</td>      
                       </tr>
      ';
    }
 
?>

<div class="container">
  <center>
    <button id="printPageButton" onClick="window.print();">พิมพ์</button>
  </center>

<div style="page-break-after:always;width: 297mm">
    <page >

    <img class="logo-print-size" src="<?php echo $image_logo ?>">
     <br>
    <div class="col-sm-12 text-center " style="font-size: 36px;margin-top: 8px;">
      <p class="text-bold " style="margin-top: -8px;">แบบบันทึกผลการพัฒนาคุณภาพผู้เรียน (ปพ.5)</p>
      <p class="text-bold " style="line-height: 0.3">โรงเรียนเทศบาลวัดสระทอง สังกัดเทศบาลเมืองร้อยเอ็ด อำเภอเมือง จังหวัดร้อยเอ็ด</p>
      <p >รหัสวิชา <span class="text-bold"><?php echo  $courseID; ?></span> รายวิชา <span class="text-bold"><?php echo  $name; ?></span></p>
      <?php if ($class_level=='p1' || $class_level=='p2' || $class_level=='p3' || $class_level=='p4' || $class_level=='p5' || $class_level=='p6') {  ?>
        <?php
          if ($status==2) {
         ?>
         <?php  
          if ($status_form==25 || $status_form==26 || $status_form==27) {
         ?>
          <p style="line-height: 0.5">ระดับชั้นประถมศึกษาปีที่ <span class="text-bold"><?php echo $class_level_remove.'/'.$room_search; ?></span> ปีการศึกษา <span class="text-bold"><?php echo $year; ?></span> </p>
         <?php }else{ ?>
          <p style="line-height: 0.5">ระดับชั้นประถมศึกษาปีที่ <span class="text-bold"><?php echo $class_level_remove; ?></span> ปีการศึกษา <span class="text-bold"><?php echo $year; ?></span> </p>
        <?php } ?>
        <?php  }else{ ?>
          <p style="line-height: 0.5">ระดับชั้นประถมศึกษาปีที่ <span class="text-bold"><?php echo $class_level_remove.'/'.$room_search; ?></span> ปีการศึกษา <span class="text-bold"><?php echo $year; ?></span> </p>
        <?php } ?>
      <?php }else{ ?>
        <?php
          if ($status==2) {
         ?>
           <?php  
            if ($status_form==25 || $status_form==26 || $status_form==27) {
           ?>
           <p style="line-height: 0.4">ระดับชั้นมัธยมศึกษาปีที่ <span class="text-bold"><?php echo $class_level_remove.'/'.$room_search; ?></span> ภาคเรียนที่  <span class="text-bold"><?php echo $term; ?></span> ปีการศึกษา <span class="text-bold"><?php echo $year; ?></span> </p>
           <?php }else{ ?>
            <p style="line-height: 0.4">ระดับชั้นมัธยมศึกษาปีที่ <span class="text-bold"><?php echo $class_level_remove; ?></span> ภาคเรียนที่  <span class="text-bold"><?php echo $term; ?></span> ปีการศึกษา <span class="text-bold"><?php echo $year; ?></span> </p>
            <?php } ?>
        <?php  }else{ ?>
            <p style="line-height: 0.4">ระดับชั้นมัธยมศึกษาปีที่ <span class="text-bold"><?php echo $class_level_remove.'/'.$room_search; ?></span> ภาคเรียนที่  <span class="text-bold"><?php echo $term; ?></span> ปีการศึกษา <span class="text-bold"><?php echo $year; ?></span> </p>
        <?php } ?>
      <?php } ?>
      <?php 
        if ($status==1) {
      ?>
      <p style="line-height: 1.4;font-size: 28px;margin-top: 30px;">
        <span>ครูประจำชั้น ........................................................................</span>
        <span style="margin-left: 20px;">ครูประจำชั้น ........................................................................</span>
      </p>
     
      <?php  }  ?>
    </div>
     <br>

<?php if($status==1){ ?>

  <table cellspacing="0" style="width: 92%; text-align: center; font-size: 26px;margin-left: 30px;border: 1px solid black;margin-top:-10px;">
              <thead style="border: none;">
                <tr class="text-middle">
                  <td rowspan="2"  style="  vertical-align: middle;width: 16%;">จำนวนนักเรียนทั้งหมด</td>
                  <td colspan="10" style="width: 60%;padding: 5px;">สรุปผลการพัฒนาคุณภาพผู้เรียน</td>    
                  <td rowspan="3"  style="  vertical-align: middle;width: 14%;">หมายเหตุ</td> 
                </tr>
                <tr>
                  <td colspan="10" style="padding: 5px;border-left: none;">จำนวนนักเรียนที่ได้ระดับผลการเรียน</td>
                </tr>
                <tr>
                  <td style="width: 7%;"><?php echo $num_all_std.'&nbsp;&nbsp; คน'; ?></td>
                  <td style="width: 7%;">4.0</td>
                  <td style="width: 7%;">3.5</td>
                  <td style="width: 7%;">3.0</td>
                  <td style="width: 7%;">2.5</td>
                  <td style="width: 7%;">2.0</td>
                  <td style="width: 7%;">1.5</td>
                  <td style="width: 7%;">1.0</td>
                  <td style="width: 7%;">0</td>
                  <td style="width: 7%;">ร</td>
                  <td style="width: 7%;">มส</td>
                </tr>
              </thead>
              <tbody>
                 <tr>
                  <td>จำนวนที่ได้</td>
                  <td><?php echo $data_40; ?></td>
                  <td><?php echo $data_35; ?></td>
                  <td><?php echo $data_30; ?></td>
                  <td><?php echo $data_25; ?></td>
                  <td><?php echo $data_20; ?></td>
                  <td><?php echo $data_15; ?></td>
                  <td><?php echo $data_10; ?></td>
                  <td><?php echo $data_00; ?></td>
                  <td><?php echo $data_i; ?></td>
                  <td><?php echo $data_atte; ?></td>
                  <td></td>
                </tr>
                 <tr>
                  <td>คิดเป็นร้อยละ</td>
                  <td><?php echo $get_per_40; ?></td>
                  <td><?php echo $get_per_35; ?></td>
                  <td><?php echo $get_per_30; ?></td>
                  <td><?php echo $get_per_25; ?></td>
                  <td><?php echo $get_per_20; ?></td>
                  <td><?php echo $get_per_15; ?></td>
                  <td><?php echo $get_per_10; ?></td>
                  <td><?php echo $get_per_00; ?></td>
                  <td><?php echo $get_per_i; ?></td>
                  <td><?php echo $get_per_atte; ?></td>
                  <td></td>
                </tr>
              </tbody>
    </table> 

    <table cellspacing="0" style="width: 92%; text-align: center; font-size: 26px;margin-left: 30px;">
              <thead style="border-top: none;">
                <tr class="text-middle">
                  <td rowspan="2"  style="vertical-align: middle;width: 12.74%;border-top: none;">ผลการประเมิน</td>
                  <td colspan="4" style="width: 35%;padding: 5px;border-top: none;">ผลการประเมินคุณลักษณะอันพึงประสงค์</td>   
                  <td colspan="4" style="width: 35%;padding: 5px;border-top: none;">ผลการประเมินการอ่าน คิดวิเคราะห์ และเขียน</td>    
                  <td style="  vertical-align: middle;width: 11.08%;border-top: none;"></td> 
                </tr>
                
                <tr>
                  <td style="width: 7%;border-left: none;">ดีเยี่ยม</td>
                  <td style="width: 7%;">ดี</td>
                  <td style="width: 7%;">ผ่าน</td>
                  <td style="width: 7%;">ไม่ผ่าน</td>
                  <td style="width: 7%;">ดีเยี่ยม</td>
                  <td style="width: 7%;">ดี</td>
                  <td style="width: 7%;">ผ่าน</td>
                  <td style="width: 7%;">ไม่ผ่าน</td>
                  <td style="width: 7%;"></td>
                </tr>
              </thead>
              <tbody>
                 <tr>
                  <td>จำนวนที่ได้</td>
                  <td><?php echo $data_desirable_verygood; ?></td>
                  <td><?php echo $data_desirable_good; ?></td>
                  <td><?php echo $data_desirable_pass; ?></td>
                  <td><?php echo $data_desirable_nopass; ?></td>
                  <td><?php echo $data_read_think_write_verygood; ?></td>
                  <td><?php echo $data_read_think_write_good; ?></td>
                  <td><?php echo $data_read_think_write_pass; ?></td>
                  <td><?php echo $data_read_think_write_nopass; ?></td>
                  
                  <td></td>
                </tr>
                 <tr>
                  <td>คิดเป็นร้อยละ</td>
                  <td><?php echo $get_per_desirable_verygood; ?></td>
                  <td><?php echo $get_per_desirable_good; ?></td>
                  <td><?php echo $get_per_desirable_pass; ?></td>
                  <td><?php echo $get_per_desirable_nopass; ?></td>
                  <td><?php echo $get_per_read_think_write_verygood; ?></td>
                  <td><?php echo $get_per_read_think_write_good; ?></td>
                  <td><?php echo $get_per_read_think_write_pass; ?></td>
                  <td><?php echo $get_per_read_think_write_nopass; ?></td>
                  
                  <td></td>
                </tr>
              </tbody>
    </table> 
    <?php }else{ ?>

       <table cellspacing="0" style="width: 92%; text-align: center; font-size: 26px;margin-left: 30px;border: 1px solid black;margin-top: 10px;">
        <thead style="border: none;">
          <tr>
            <td rowspan="2" style="width: 16%;">จำนวนนักเรียนทั้งหมด</td>
            <td colspan="2" style="width: 70%;">สรุปผลการพัฒนาคุณภาพผู้เรียน</td>
            <td rowspan="3" style="width: 14%;">หมายเหตุ</td>
          </tr>
          <tr>
            <td colspan="2" style="border-left: none;">จำนวนนักเรียนที่ได้ระดับผลการเรียน</td>
          </tr>
          <tr>
            <td><?php echo $num_all_std_dev.'&nbsp;&nbsp;คน'; ?></td>
            <td style="width: 13.8px;">ผ่าน</td>
            <td>ไม่ผ่าน</td>
          </tr>
        </thead>
        <tbody>
          <tr>
            <td>จำนวนที่ได้</td> 
            <td><?php echo $data_atte_pass; ?></td>
            <td><?php echo $data_atte_nopass; ?></td>
            <td></td>
          </tr>
          <tr>
            <td>คิดเป็นร้อยละ</td>
            <td><?php echo $summary_atte_pass_per; ?></td>
            <td><?php echo $summary_atte_nopass_per; ?></td>
            <td></td>
          </tr>
        </tbody>
       </table>
       <table cellspacing="0" style="width: 92%; text-align: center; font-size: 26px;margin-left: 30px;">
              <thead style="border-top: none;">
                <tr class="text-middle">
                  <td rowspan="2"  style="  vertical-align: middle;width: 12.74%;border-top: none;">ผลการประเมิน</td>
                  <td colspan="4" style="width: 35%;padding: 5px;border-top: none;">ผลการประเมินคุณลักษณะอันพึงประสงค์</td>   
                  <td colspan="4" style="width: 35%;padding: 5px;border-top: none;">ผลการประเมินการอ่าน คิดวิเคราะห์ และเขียน</td>    
                  <td style="  vertical-align: middle;width: 11.08%;border-top: none;"></td> 
                </tr>
                
                <tr>
                  <td style="width: 7%;border-left: none;">ดีเยี่ยม</td>
                  <td style="width: 7%;">ดี</td>
                  <td style="width: 7%;">ผ่าน</td>
                  <td style="width: 7%;">ไม่ผ่าน</td>
                  <td style="width: 7%;">ดีเยี่ยม</td>
                  <td style="width: 7%;">ดี</td>
                  <td style="width: 7%;">ผ่าน</td>
                  <td style="width: 7%;">ไม่ผ่าน</td>
                  <td style="width: 7%;"></td>
                </tr>
              </thead>
              <tbody>
                 <tr>
                  <td>จำนวนที่ได้</td>
                  <td><?php echo $data_desirable_verygood; ?></td>
                  <td><?php echo $data_desirable_good; ?></td>
                  <td><?php echo $data_desirable_pass; ?></td>
                  <td><?php echo $data_desirable_nopass; ?></td>
                  <td><?php echo $data_read_think_write_verygood; ?></td>
                  <td><?php echo $data_read_think_write_good; ?></td>
                  <td><?php echo $data_read_think_write_pass; ?></td>
                  <td><?php echo $data_read_think_write_nopass; ?></td>
                  
                  <td></td>
                </tr>
                 <tr>
                  <td>คิดเป็นร้อยละ</td>
                  <td><?php echo $get_per_desirable_verygood; ?></td>
                  <td><?php echo $get_per_desirable_good; ?></td>
                  <td><?php echo $get_per_desirable_pass; ?></td>
                  <td><?php echo $get_per_desirable_nopass; ?></td>
                  <td><?php echo $get_per_read_think_write_verygood; ?></td>
                  <td><?php echo $get_per_read_think_write_good; ?></td>
                  <td><?php echo $get_per_read_think_write_pass; ?></td>
                  <td><?php echo $get_per_read_think_write_nopass; ?></td>
                  
                  <td></td>
                </tr>
              </tbody>
    </table>
    <?php } ?>

    <div style="position: relative;margin-top: 40px;font-size: 24px;">    

      <div style="position: absolute;left: 130px;top: 40px;">
        <p >................................................................. ครูผู้สอน </p>
        <div style="position: relative;">
          <p style="position: absolute;left: 0;">(</p> <p style="position: absolute;right: 50px;"> )</p>
       </div><br>
        <p style="margin-left: 15px;">................/................/...................</p>    
      </div>

       <div style="position: absolute;right: 140px;top: 40px;">
        <p>................................................................. หัวหน้างานวัดผล </p>      
        <div style="position: relative;">
          <p style="position: absolute;left: 0;">(</p> <p style="position: absolute;right: 102px;"> )</p>
       </div><br>
        <p style="margin-left: 15px;">................/................/...................</p>
      </div>

    </div>

    <div style="position: relative;margin-top: 200px;font-size: 24px;">
      <div style="position: absolute;top: 40px;left: 130px;">
        <p>................................................................. หัวหน้ากลุ่มสาระการเรียนรู้</p>
        <div style="position: relative;">
          <p style="position: absolute;left: 0;">(</p> <p style="position: absolute;right: 170px;"> )</p>
        </div><br>
        <p style="margin-left: 15px;">................/................/...................</p>
      </div>
    </div> 
    
    <div style="position: relative;margin-top: 330px;font-size: 24px;">
      <div style="position: absolute;top: 40px;right: 280px;">
        <p >(</span> <span style="margin-left:10px ">)</span> อนุมัติ</p>
        <p style="margin-top: -44px;margin-left: 95px;"><span>(</span> <span style="margin-left:10px ">)</span> ไม่อนุมัติ</p>
      </div>
    </div> 

    <div style="position: relative;margin-top: 400px;margin-bottom: 700px;font-size: 24px;">    

      <div style="position: absolute;left: 130px;top: 40px;">
        <p>................................................................. รองผู้อำนวยการฝ่ายวิชาการ </p>
        <div style="position: relative;">
          <p style="position: absolute;left: 0;">(</p> <p style="position: absolute;right: 175px;"> )</p>
       </div><br>
        <p style="margin-left: 15px;">................/................/...................</p>    
      </div>

       <div style="position: absolute;right: 90px;top: 40px;">
        <p>................................................................. ผู้อำนวยการสถานศึกษา </p>      
        <div style="position: relative;">
          <p style="position: absolute;left: 0;">(</p> <p style="position: absolute;right: 145px;"> )</p>
       </div><br>
        <p style="margin-left: 15px;">................/................/...................</p>
      </div>

    </div>

</page>
    </div>
  <?php
    if($page=='all_page'){
      if($attend['set_page']=='port'){ 
        echo $attend['data_html'];
      }else{
        echo $attend['data_html'];
      }
    }
  ?>

<!--<?php if($page=='all_page'){ ?>
<?php if($attend['set_page']=='port'){ echo $attend['data_html']; ?>

 <?php }else{ echo $attend['data_html']; ?> 
-orientation="<?php if($attend['set_page']=='land'){echo "landscape";}else{echo "portrait";}?>"
  <?php } ?> -->

 
  <page orientation="portrait">
     <?php 
        if($status==1){ 
          echo $objective_list['data_html']; 
        }
      ?>           
          
  </page>

  <?php if ($status==2) {    ?>
    <?php echo $dev_summary['data_html_dev']; ?>
  <?php } ?>

<?php echo $std_desirable; ?>

<div style="page-break-after:always;position: relative;top: 100px; ">
 <page orientation="portrait"> 
   <?php if($status==1){ ?>
  <table cellspacing="0" style="width: 92%; text-align: center; font-size: 24px;margin-left: 30px;border: 1px solid black;margin-top: 10px;">
              <thead style="border: none;">
                <tr class="text-middle">
                  <td rowspan="2"  style="  vertical-align: middle;width: 16%;">จำนวนนักเรียนทั้งหมด</td>
                  <td colspan="10" style="width: 60%;padding: 5px;">สรุปผลการพัฒนาคุณภาพผู้เรียน</td>    
                  <td rowspan="3"  style="  vertical-align: middle;width: 14%;">หมายเหตุ</td> 
                </tr>
                <tr>
                  <td colspan="10" style="padding: 5px;border-left: none;">จำนวนนักเรียนที่ได้ระดับผลการเรียน</td>
                </tr>
                <tr>
                  <td style="width: 7%;"><?php echo $num_all_std.'&nbsp;&nbsp;คน'; ?></td>
                  <td style="width: 7%;">4.0</td>
                  <td style="width: 7%;">3.5</td>
                  <td style="width: 7%;">3.0</td>
                  <td style="width: 7%;">2.5</td>
                  <td style="width: 7%;">2.0</td>
                  <td style="width: 7%;">1.5</td>
                  <td style="width: 7%;">1.0</td>
                  <td style="width: 7%;">0</td>
                  <td style="width: 7%;">ร</td>
                  <td style="width: 7%;">มส</td>
                </tr>
              </thead>
              <tbody>
                 <tr>
                  <td>จำนวนที่ได้</td>
                  <td><?php echo $data_40; ?></td>
                  <td><?php echo $data_35; ?></td>
                  <td><?php echo $data_30; ?></td>
                  <td><?php echo $data_25; ?></td>
                  <td><?php echo $data_20; ?></td>
                  <td><?php echo $data_15; ?></td>
                  <td><?php echo $data_10; ?></td>
                  <td><?php echo $data_00; ?></td>
                  <td><?php echo $data_i; ?></td>
                  <td><?php echo $data_atte; ?></td>
                  <td></td>
                </tr>
                 <tr>
                  <td>คิดเป็นร้อยละ</td>
                  <td><?php echo $get_per_40; ?></td>
                  <td><?php echo $get_per_35; ?></td>
                  <td><?php echo $get_per_30; ?></td>
                  <td><?php echo $get_per_25; ?></td>
                  <td><?php echo $get_per_20; ?></td>
                  <td><?php echo $get_per_15; ?></td>
                  <td><?php echo $get_per_10; ?></td>
                  <td><?php echo $get_per_00; ?></td>
                  <td><?php echo $get_per_i; ?></td>
                  <td><?php echo $get_per_atte; ?></td>
                  <td></td>
                </tr>
              </tbody>
    </table> 
    
    <table cellspacing="0" style="width: 92%; text-align: center; font-size: 24px;margin-left: 30px;">
              <thead style="border-top: none;">
                <tr class="text-middle">
                  <td rowspan="2"  style="  vertical-align: middle;width: 12.74%;border-top: none;">ผลการประเมิน</td>
                  <td colspan="4" style="width: 35%;padding: 5px;border-top: none;">ผลการประเมินคุณลักษณะอันพึงประสงค์</td>   
                  <td colspan="4" style="width: 35%;padding: 5px;border-top: none;">ผลการประเมินการอ่าน คิดวิเคราะห์ และเขียน</td>    
                  <td style="  vertical-align: middle;width: 11.08%;border-top: none;"></td> 
                </tr>
                
                <tr>
                  <td style="width: 7%;border-left: none;">ดีเยี่ยม</td>
                  <td style="width: 7%;">ดี</td>
                  <td style="width: 7%;">ผ่าน</td>
                  <td style="width: 7%;">ไม่ผ่าน</td>
                  <td style="width: 7%;">ดีเยี่ยม</td>
                  <td style="width: 7%;">ดี</td>
                  <td style="width: 7%;">ผ่าน</td>
                  <td style="width: 7%;">ไม่ผ่าน</td>
                  <td style="width: 7%;"></td>
                </tr>
              </thead>
              <tbody>
                 <tr>
                  <td>จำนวนที่ได้</td>
                  <td><?php echo $data_desirable_verygood; ?></td>
                  <td><?php echo $data_desirable_good; ?></td>
                  <td><?php echo $data_desirable_pass; ?></td>
                  <td><?php echo $data_desirable_nopass; ?></td>
                  <td><?php echo $data_read_think_write_verygood; ?></td>
                  <td><?php echo $data_read_think_write_good; ?></td>
                  <td><?php echo $data_read_think_write_pass; ?></td>
                  <td><?php echo $data_read_think_write_nopass; ?></td>
                  
                  <td></td>
                </tr>
                 <tr>
                  <td>คิดเป็นร้อยละ</td>
                  <td><?php echo $get_per_desirable_verygood; ?></td>
                  <td><?php echo $get_per_desirable_good; ?></td>
                  <td><?php echo $get_per_desirable_pass; ?></td>
                  <td><?php echo $get_per_desirable_nopass; ?></td>
                  <td><?php echo $get_per_read_think_write_verygood; ?></td>
                  <td><?php echo $get_per_read_think_write_good; ?></td>
                  <td><?php echo $get_per_read_think_write_pass; ?></td>
                  <td><?php echo $get_per_read_think_write_nopass; ?></td>
                  
                  <td></td>
                </tr>
              </tbody>
    </table> 
    <div style="margin-left: 30px;margin-top: 30px;line-height: 0.9;">
              <p style="font-size: 24px;">เกณฑ์ระดับคุณภาพ</p>
              <p style="margin-left: 12px;margin-top: 10px;font-size: 22px;">ระดับผลการเรียน</p>
              <p style="margin-left: 12px;margin-top: -5px;font-size: 22px;">ระดับ 4</p>
              <p style="margin-left: 12px;margin-top: -5px;font-size: 22px;">ระดับ 3.5</p>
              <p style="margin-left: 12px;margin-top: -5px;font-size: 22px;">ระดับ 3</p>
              <p style="margin-left: 12px;margin-top: -5px;font-size: 22px;">ระดับ 2.5</p>
              <p style="margin-left: 12px;margin-top: -5px;font-size: 22px;">ระดับ 2</p>
              <p style="margin-left: 12px;margin-top: -5px;font-size: 22px;">ระดับ 1.5</p>
              <p style="margin-left: 12px;margin-top: -5px;font-size: 22px;">ระดับ 1</p>
              <p style="margin-left: 12px;margin-top: -5px;font-size: 22px;">ระดับ 0</p>
        
            </div>
    <div style="margin-left: 160px;margin-top: -221px;line-height: 0.9;">
      
              <p style="margin-left: 12px;margin-top: 10px;font-size: 22px;">ความหมาย</p>
              <p style="margin-left: 12px;margin-top: -5px;font-size: 22px;">ดีเยี่ยม</p>
              <p style="margin-left: 12px;margin-top: -5px;font-size: 22px;">ดีมาก</p>
              <p style="margin-left: 12px;margin-top: -5px;font-size: 22px;">ดี</p>
              <p style="margin-left: 12px;margin-top: -5px;font-size: 22px;">ค่อนข้างดี</p>
              <p style="margin-left: 12px;margin-top: -5px;font-size: 22px;">ปานกลาง</p>
              <p style="margin-left: 12px;margin-top: -5px;font-size: 22px;">พอใช้</p>
              <p style="margin-left: 12px;margin-top: -5px;font-size: 22px;">ผ่านเกณฑ์ขั้นต่ำ</p>
              <p style="margin-left: 12px;margin-top: -5px;font-size: 22px;">ต่ำกว่าเกณฑ์</p>
        
            </div>
     <div style="margin-left:290px;margin-top: -221px;line-height: 0.9;">             
              <p style="margin-left: 12px;margin-top: 10px;font-size: 22px;">ช่วงคะแนน</p>
              <p style="margin-left: 12px;margin-top: -5px;font-size: 22px;">80-100</p>
              <p style="margin-left: 12px;margin-top: -5px;font-size: 22px;">75-79</p>
              <p style="margin-left: 12px;margin-top: -5px;font-size: 22px;">70-74</p>
              <p style="margin-left: 12px;margin-top: -5px;font-size: 22px;">65-69</p>
              <p style="margin-left: 12px;margin-top: -5px;font-size: 22px;">60-64</p>
              <p style="margin-left: 12px;margin-top: -5px;font-size: 22px;">55-59</p>
              <p style="margin-left: 12px;margin-top: -5px;font-size: 22px;">50-54</p>
              <p style="margin-left: 12px;margin-top: -5px;font-size: 22px;">0-49</p>
              
        
      </div>
      <div>
           <table style="width: 80%;margin-left: 50px;margin-top: 40px;font-size: 14px;" >  
            <tbody style="border:none;">
              <tr>
              <td style="width: 40%;border: none;">
                <p style="margin-left: -20px;font-size: 24px;">ตัวชี้วัดคุณลักษณะอันพึงประสงค์</p>
                <p style="line-height: 0.9;font-size: 22px;">1.รักชาติ ศาสน์ กษัตริย์</p>
                <p style="line-height: 0.9;font-size: 22px;">2.ซื่อสัตย์สุจริต</p>
                <p style="line-height: 0.9;font-size: 22px;">3.มีวินัย</p>
                <p style="line-height: 0.9;font-size: 22px;">4.ใฝ่เรียนรู้</p>
                <p style="line-height: 0.9;font-size: 22px;">5.อยู่อย่างพอเพียง</p>
                <p style="line-height: 0.9;font-size: 22px;">6.มุ่งมั่นในการทำงาน</p>
                <p style="line-height: 0.9;font-size: 22px;">7.รักความเป็นไทย</p>
                <p style="line-height: 0.9;font-size: 22px;">8.มีจิตสาธารณะ</p>
              </td>            
            </tr>
            </tbody>  
        </table>
        <table style="width: 80%;margin-left:700px;margin-top: -193px;font-size: 14px;">
          <tbody style="border:none;">
            <tr>
              <td style="width: 40%;border: none;">               
                  <p style="margin-left: -20px;margin-top: -92px;font-size: 24px;">เกณฑ์ระดับคุณภาพคุณลักษณะอันพึงประสงค์</p>
                  <p style="line-height: 0.9;font-size: 22px;">3  ดีเยี่ยม  คะแนน 2.5-3.0</p>
                  <p style="line-height: 0.9;font-size: 22px;">2  ดี  คะแนน 1.5-2.4</p>
                  <p style="line-height: 0.9;font-size: 22px;">1  ผ่าน  คะแนน 0.5-1.4</p>
                  <p style="line-height: 0.9;font-size: 22px;">0  ไม่ผ่าน คะแนน 0-0.4</p>                           
                </td>
            </tr>
          </tbody>
        </table>
        <table style="width: 80%;margin-left:700px;margin-top: 240px;font-size: 14px;">
          <tbody style="border:none;">
            <tr>
              <td style="width: 40%;border: none;">               
                  <p style="margin-left: -20px;margin-top: -91px;font-size: 24px;">เกณฑ์ระดับคุณภาพการอ่าน คิดวิเคราะห์และเขียน</p>
                  <p style="line-height: 0.9;font-size: 22px;">3  ดีเยี่ยม  คะแนน 2.5-3.0</p>
                  <p style="line-height: 0.9;font-size: 22px;">2  ดี  คะแนน 1.5-2.4</p>
                  <p style="line-height: 0.9;font-size: 22px;">1  ผ่าน  คะแนน 0.5-1.4</p>
                  <p style="line-height: 0.9;font-size: 22px;">0  ไม่ผ่าน คะแนน 0-0.4</p>                           
                </td>
            </tr>
          </tbody>
        </table>
        <p style="margin-top: -163px;margin-left: 40px;font-size: 24px;margin-bottom: -12px;">ตัวชี้วัดการอ่าน คิดวิเคราะห์และเขียน </p> 
        <table style="margin-left: 35px;margin-top: 15px;font-size: 14px;">      
          <tbody style="border:none;font-size: 22px;">
            <?php echo $text_rtw_desc; ?>
          </tbody>
        </table>
      </div>
    <?php }else{ ?>

      <table cellspacing="0" style="width: 92%; text-align: center; font-size: 24px;margin-left: 30px;border: 1px solid black;margin-top: 10px;">
        <thead style="border: none;">
          <tr>
            <td rowspan="2" style="width: 16%;">จำนวนนักเรียนทั้งหมด</td>
            <td colspan="2" style="width: 70%;">สรุปผลการพัฒนาคุณภาพผู้เรียน</td>
            <td rowspan="3" style="width: 14%;">หมายเหตุ</td>
          </tr>
          <tr>
            <td colspan="2" style="border-left: none;">จำนวนนักเรียนที่ได้ระดับผลการเรียน</td>
          </tr>
          <tr>
            <td><?php echo $num_all_std_dev.'&nbsp;&nbsp;คน'; ?></td>
            <td style="width: 13.8px;">ผ่าน</td>
            <td>ไม่ผ่าน</td>
          </tr>
        </thead>
        <tbody>
          <tr>
            <td>จำนวนที่ได้</td> 
            <td><?php echo $data_atte_pass; ?></td>
            <td><?php echo $data_atte_nopass; ?></td>
            <td></td>
          </tr>
          <tr>
            <td>คิดเป็นร้อยละ</td>
            <td><?php echo $summary_atte_pass_per; ?></td>
            <td><?php echo $summary_atte_nopass_per; ?></td>
            <td></td>
          </tr>
        </tbody>
       </table>
       <table cellspacing="0" style="width: 92%; text-align: center; font-size: 24px;margin-left: 30px;">
              <thead style="border: none;">
                <tr class="text-middle">
                  <td rowspan="2"  style="  vertical-align: middle;width: 12.74%;border-top: none;">ผลการประเมิน</td>
                  <td colspan="4" style="width: 35%;padding: 5px;border-top: none;">ผลการประเมินคุณลักษณะอันพึงประสงค์</td>   
                  <td colspan="4" style="width: 35%;padding: 5px;border-top: none;">ผลการประเมินการอ่าน คิดวิเคราะห์ และเขียน</td>    
                  <td style="  vertical-align: middle;width: 11.08%;border-top: none;"></td> 
                </tr>
                
                <tr>
                  <td style="width: 7%;border-left: none;">ดีเยี่ยม</td>
                  <td style="width: 7%;">ดี</td>
                  <td style="width: 7%;">ผ่าน</td>
                  <td style="width: 7%;">ไม่ผ่าน</td>
                  <td style="width: 7%;">ดีเยี่ยม</td>
                  <td style="width: 7%;">ดี</td>
                  <td style="width: 7%;">ผ่าน</td>
                  <td style="width: 7%;">ไม่ผ่าน</td>
                  <td style="width: 7%;"></td>
                </tr>
              </thead>
              <tbody>
                 <tr>
                  <td>จำนวนที่ได้</td>
                  <td><?php echo $data_desirable_verygood; ?></td>
                  <td><?php echo $data_desirable_good; ?></td>
                  <td><?php echo $data_desirable_pass; ?></td>
                  <td><?php echo $data_desirable_nopass; ?></td>
                  <td><?php echo $data_read_think_write_verygood; ?></td>
                  <td><?php echo $data_read_think_write_good; ?></td>
                  <td><?php echo $data_read_think_write_pass; ?></td>
                  <td><?php echo $data_read_think_write_nopass; ?></td>                 
                  <td></td>
                </tr>
                 <tr>
                  <td>คิดเป็นร้อยละ</td>
                  <td><?php echo $get_per_desirable_verygood; ?></td>
                  <td><?php echo $get_per_desirable_good; ?></td>
                  <td><?php echo $get_per_desirable_pass; ?></td>
                  <td><?php echo $get_per_desirable_nopass; ?></td>
                  <td><?php echo $get_per_read_think_write_verygood; ?></td>
                  <td><?php echo $get_per_read_think_write_good; ?></td>
                  <td><?php echo $get_per_read_think_write_pass; ?></td>
                  <td><?php echo $get_per_read_think_write_nopass; ?></td>
                  
                  <td></td>
                </tr>
              </tbody>
    </table> 
 
      <div>
           <table style="width: 80%;margin-left: 50px;margin-top: 40px;font-size: 14px;" >  
            <tbody style="border:none;">
              <tr>
              <td style="width: 40%;border: none;">
                <p style="margin-left: -20px;font-size: 24px;">ตัวชี้วัดคุณลักษณะอันพึงประสงค์</p>
                <p style="line-height: 0.9;font-size: 22px;">1.รักชาติ ศาสน์ กษัตริย์</p>
                <p style="line-height: 0.9;font-size: 22px;">2.ซื่อสัตย์สุจริต</p>
                <p style="line-height: 0.9;font-size: 22px;">3.มีวินัย</p>
                <p style="line-height: 0.9;font-size: 22px;">4.ใฝ่เรียนรู้</p>
                <p style="line-height: 0.9;font-size: 22px;">5.อยู่อย่างพอเพียง</p>
                <p style="line-height: 0.9;font-size: 22px;">6.มุ่งมั่นในการทำงาน</p>
                <p style="line-height: 0.9;font-size: 22px;">7.รักความเป็นไทย</p>
                <p style="line-height: 0.9;font-size: 22px;">8.มีจิตสาธารณะ</p>
              </td>            
            </tr>
            </tbody>  
        </table>
        <table style="width: 80%;margin-left:700px;margin-top: -193px;font-size: 14px;">
          <tbody style="border:none;">
            <tr>
              <td style="width: 40%;border: none;">               
                  <p style="margin-left: -20px;margin-top: -92px;font-size: 24px;">เกณฑ์ระดับคุณภาพคุณลักษณะอันพึงประสงค์</p>
                  <p style="line-height: 0.9;font-size: 22px;">3  ดีเยี่ยม  คะแนน 2.5-3.0</p>
                  <p style="line-height: 0.9;font-size: 22px;">2  ดี  คะแนน 1.5-2.4</p>
                  <p style="line-height: 0.9;font-size: 22px;">1  ผ่าน  คะแนน 0.5-1.4</p>
                  <p style="line-height: 0.9;font-size: 22px;">0  ไม่ผ่าน คะแนน 0-0.4</p>                           
                </td>
            </tr>
          </tbody>
        </table>
        <table style="width: 80%;margin-left:700px;margin-top: 240px;font-size: 14px;">
          <tbody style="border:none;">
            <tr>
              <td style="width: 40%;border: none;">               
                  <p style="margin-left: -20px;margin-top: -91px;font-size: 24px;">เกณฑ์ระดับคุณภาพการอ่าน คิดวิเคราะห์และเขียน</p>
                  <p style="line-height: 0.9;font-size: 22px;">3  ดีเยี่ยม  คะแนน 2.5-3.0</p>
                  <p style="line-height: 0.9;font-size: 22px;">2  ดี  คะแนน 1.5-2.4</p>
                  <p style="line-height: 0.9;font-size: 22px;">1  ผ่าน  คะแนน 0.5-1.4</p>
                  <p style="line-height: 0.9;font-size: 22px;">0  ไม่ผ่าน คะแนน 0-0.4</p>                           
                </td>
            </tr>
          </tbody>
        </table>
        <p style="margin-top: -163px;margin-left: 40px;font-size: 24px;margin-bottom: -12px;">ตัวชี้วัดการอ่าน คิดวิเคราะห์และเขียน </p> 
        <table style="margin-left: 35px;margin-top: 15px;font-size: 14px;">      
          <tbody style="border:none;font-size: 22px;">
            <?php echo $text_rtw_desc; ?>
          </tbody>
        </table>
      </div>
    <?php } ?>
     
  </page>
</div>


<?php  } ?>
</div>

<script>
 $(document).ready(function() {
    get_print();
    setTimeout(window.close, 0);
  });
  function get_print() {
    window.print();
  }
</script><file_sep>/includes/name-tab.js
$(document).ready(function() {
	get_name_tab();
	get_img_tab();
});
function get_img_tab() {
	var formData = new Array();
	formData.push({ "name": "acc_action", "value": "get_img_tab" }); 
	$.getJSON('includes/process.php', formData, function(data, textStatus, xhr) {
		
		$("#get_img_tab").html(data.get_img_tab);
	});
}
function get_name_tab() {
	var formData = new Array();
	formData.push({ "name": "acc_action", "value": "get_name_tab" }); 
	$.getJSON('includes/process.php', formData, function(data, textStatus, xhr) {

		$("#full_name_th").html(data.full_name_th);
	});
}<file_sep>/modules/regis_course_teaching/back/edit_student.js
var opPage = 'regis_course_teaching';
$(document).ready(function() {
	get_course_teaching_student();
	get_teaching_student_only();
	hide_class_std() ;
	

}); 
function hide_class_std() {
	var formData = new Array();
	var course_id=_get.courseID;
	formData.push({ "name": "acc_action", "value": "hide_class_std" }); 
	formData.push({ "name": "data_id_first", "value": course_id }); 
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {
		$("#search_class_modal").html(data);
			get_std_list_new();
	})
}
 $(document).delegate('#checkbox_all', 'click', function(event) {
	if(this.checked) { // check select status
        $('.checkbox_data').each(function() { //loop through each checkbox
            this.checked = true;  //select all checkboxes with class "checkbox1"               
        });
    }else{
        $('.checkbox_data').each(function() { //loop through each checkbox
            this.checked = false; //deselect all checkboxes with class "checkbox1"                       
        });         
    }
});
$(document).delegate('#btn__conf_add_std', 'click', function(event) {
	var tempValue=$("input[name='checkbox_delete[]']:checked").map(function(n){ if(this.checked){return  this.value;}; }).get().join(',');
	
	var course_id=$("#course_id_").val();
	var term_search=_get.term;
	var year_search=_get.year;
	var formData = new Array();
	formData.push({ "name": "acc_action", "value": "data_add_std" }); 
	formData.push({ "name": "data_val", "value": tempValue});
	formData.push({ "name": "course_id", "value": course_id}); 
	formData.push({ "name": "term_search", "value": term_search }); 	
	formData.push({ "name": "year_search", "value": year_search });  
	$.post('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {
		
		get_teaching_student_only();
		get_std_list_new();
		$('.modal').modal('hide');
	})

});
 $(document).delegate('.bt_delete', 'click', function(event) {
 	var data_id = $(this).attr('data-id');
 	 $(document).delegate('#btn_to_deleteReStd', 'click', function(event) {
 		$.post('modules/' + opPage + '/process.php', {
			'acc_action' : 'data_remove_std',
			'data_val' : data_id
		}, function(response) {

			data_id='';
			$(".modal").modal("hide");
			get_std_list_new();
			get_teaching_student_only() ;

		});
 	});
 });
function get_std_list_new() {
	var course_id=_get.courseID;
	var term_search=_get.term;
	var year_search=_get.year;
	var search_class_modal=$("#search_class_modal").val();
	var formData = $( "#frm_data_search_modal" ).serializeArray();
	formData.push({ "name": "acc_action", "value": "get_std_list_new" }); 
	formData.push({ "name": "course_id", "value": course_id }); 
	formData.push({ "name": "term_search", "value": term_search }); 	
	formData.push({ "name": "year_search", "value": year_search }); 		
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {

		$("#std_list").html(data.std_list);

		
	})
}
function get_teaching_student_only() {
	var data_room;
	var formData = new Array();
	if (_get.room==0) {
		var search_room_modal=$("#search_room_modal").val()
		data_room=search_room_modal;
	}else{
		data_room=_get.room;
	}
	formData.push({ "name": "acc_action", "value": "get_teaching_student_only" }); 
	formData.push({ "name": "data_id", "value": _get.id});
	formData.push({ "name": "data_room", "value":data_room });
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {
		$("#std_list_only").html(data.std_list_only);
	})
}
function add_data_proportion() {
	var course_id=_get.courseID;
	var formData = $( "#frm_data_teaching" ).serializeArray();
	formData.push({ "name": "acc_action", "value": "add_data_proportion" }); 
	formData.push({ "name": "course_id", "value": course_id }); 
	$.post('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {
		$(".modal").modal("hide");
	})
}
function update_objective_conclude() {
	var course_id=_get.courseID;

	var objective_data_all_id=$('#objective_data_all_id').val();
	var formData = $( "#frm_data_objective" ).serializeArray();
	formData.push({ "name": "acc_action", "value": "update_objective_conclude" }); 
	formData.push({ "name": "course_id", "value": course_id }); 
	formData.push({ "name": "objective_data_all_id", "value": objective_data_all_id }); 
	$.post('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {

		$(".modal").modal("hide");
	})
}
function add_objective_conclude() {
	var course_id=_get.courseID;
	var formData = $( "#frm_data_objective_plus" ).serializeArray();
	formData.push({ "name": "acc_action", "value": "add_objective_conclude" }); 
	formData.push({ "name": "course_id", "value": course_id }); 
	$.post('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {

	})
}
function get_registed_course_teaching() {
	var formData = new Array();
	formData.push({ "name": "acc_action", "value": "get_registed_course_teaching" }); 	
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {

		$('#data_table_regis_course_teaching').html(data);
		
	})
}
$(document).delegate('#btn_add_teaching', 'click', function(event) {
	add_data_proportion();
	update_objective_conclude();
	add_objective_conclude();
	get_registed_course_teaching() ;
	/*
	var course_id=_get.courseID;
	var formData = new Array();
	formData.push({ "name": "acc_action", "value": "add_teaching" }); 
	formData.push({ "name": "course_id", "value": course_id }); 
	$.post('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {
		$(".modal").modal("hide");
		get_registed_course_teaching() ;
	})*/
})
 $(document).delegate('#btn_plus_objective', 'click', function(event) {
	plus_objective();
})
 function plus_objective() {
	var formData = $( "#frm_data_objective_plus" ).serializeArray();
	formData.push({ "name": "acc_action", "value": "plus_objective" }); 
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {
		$('#data_objective_place_plus').html(data);
	})
 }

function get_course_teaching_student() {
	var formData = new Array();
	formData.push({ "name": "acc_action", "value": "get_course_teaching_student" }); 
	formData.push({ "name": "data_id", "value": _get.id});
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {
		$("#course_id_from_search").html(data.courseID);
		$("#course_name_from_search").html(data.name+'(ลงทะเบียนแล้ว)');	
		$("#course_id_").val(data.course_data_ID);	
		get_propotion_objective(data.course_data_ID);
	})
}
function get_propotion_objective(data_id_first) {
	var formData = new Array();
	formData.push({ "name": "acc_action", "value": "get_propotion_objective" }); 
	formData.push({ "name": "data_id_first", "value": data_id_first }); 	
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {

		$("#comulative").val(data.comulative);
		$("#mid_exam").val(data.mid_exam);
		$("#final_exam").val(data.final_exam);
		$("#data_objective_place").html(data.objective_list);
		$("#objective_data_all_id").val(data.objective_data_all_id);
		
		
		
	})
}
$(document).delegate('#btn_modal_std_search', 'click', function(event) {
	get_std_list_new();
})<file_sep>/modules/regis_course/index.js
var opPage = 'regis_course';
$(document).ready(function() {
	get_data();
	get_data_year_search();
	get_data_registered();
	get_data_registered_edit();
	$(".chk_delete_btn_h").css("display","none");
	get_term_year_now();
}); 

 $(document).delegate('#btn_set_term_year', 'click', function(event) {
 	var formData = new Array();
 	var term_set=$("#term_set").val();
 	var year_set=$("#year_set").val();
	formData.push({ "name": "acc_action", "value": "set_term_year" }); 
	formData.push({ "name": "term_set", "value": term_set }); 
	formData.push({ "name": "year_set", "value": year_set }); 
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {
		window.location.reload();
	 });
 });
 function get_term_year_now() {
	var formData = new Array();
	formData.push({ "name": "acc_action", "value": "get_term_year_now" }); 
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {
		var term=data.term;		
		if(data.status_rang==3 || data.status_rang==4){
			$("#term_search_id_"+term).attr('selected','selected');
			$("#term_search_id_1_2").css('display','none');
		}else{
			$("#term_search_id_1").css('display','none');
			$("#term_search_id_2").css('display','none');
			$("#term_search_id_1_2").attr('selected','selected');
		}
		var year=data.year;
		var year_now=data.year_now;	
		var year_last=year_now-5;;
		var year_set=document.getElementById("year_set");
		year_set.innerHTML += '<option selected="selected" value="'+(year_now+2)+'"> ปีการศึกษา'+(year_now+2)+'</option>';
		year_set.innerHTML += '<option selected="selected" value="'+(year_now+1)+'"> ปีการศึกษา'+(year_now+1)+'</option>';	

		for (var i = year_now; i >= year_last; i--) {
			if (i==year) {
				year_set.innerHTML += '<option selected="selected" value="'+i+'"> ปีการศึกษา'+i+'</option>';
			}else{
				year_set.innerHTML += '<option value="'+i+'">ปีการศึกษา '+i+'</option>';
			}	
		}
	})
}

function chk_to_hide_edit(value) {
	var course_status_val=$("#course_status").val();
	chk_to_hide_department_edit(course_status_val);
}
function chk_to_hide_department_edit(value) {
	var class_level_val=$("#class_level").val();

	if (value==1) {
		$("#department").removeAttr("disabled");
		if (class_level_val=="m1" || class_level_val=="m2" || class_level_val=="m3" || class_level_val=="m4" || class_level_val=="m5" || class_level_val=="m6") {
			$("#unit_chk").removeAttr("disabled");
		}else{
			$("#unit_chk").attr("disabled","disabled");
		}
			
	}else{
		$("#unit_chk").attr("disabled","disabled");
		$("#department").attr("disabled","disabled");
	}
		}
 $(document).delegate('.btn_remove_registed', 'click', function(event) {
 	var data_id_re = $(this).attr('data-id');
 	var data_term = $(this).attr('data-term');
 	var data_year = $(this).attr('data-year');

	 $(document).delegate('#btn__save_canlcel_course', 'click', function(event) {
	 	var formData = new Array();
		formData.push({ "name": "acc_action", "value": "remove_registed" }); 
		formData.push({ "name": "data_id", "value": data_id_re }); 
		formData.push({ "name": "data_term", "value": data_term }); 
		formData.push({ "name": "data_year", "value": data_year }); 
		$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {

			get_data_registered($(".chk_delete_btn_h").css("display"));
			get_data_registered_edit();
			get_data_year_search();
			$('.modal').modal('hide');	
			$(".chk_delete_btn").css("display","block");
		});
		
 	});
 });
$(document).delegate('.btn_edit', 'click', function(event) {
	hide_edit_col();
})
$(document).delegate('#btn_edit', 'click', function(event) {
	show_edit_col();
})
function hide_edit_col() {
	$
	$(".chk_delete_btn_h").css("display","none");
	$(".btn_edit").attr('id',"btn_edit");
}
function show_edit_col() {

	$(".chk_delete_btn_h").css("display","block");
	$(".chk_delete_btn_h").css("borderBottom","1px solid #fff");

	$("#btn_edit").addClass("btn_edit");
	$(".btn_edit").attr('id',"");
}
function get_data_year_search() {
	var formData = new Array();
	formData.push({ "name": "acc_action", "value": "get_data_year_search" }); 
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {
		$(".data_year_search").html(data.year_list);
		
	})
}
$(document).delegate('#btn_data_year_search_2', 'click', function(event) {
	get_data_registered(0);
})
$(document).delegate('#btn_data_year_search_3', 'click', function(event) {
	get_data_registered_edit(1);
})
function get_data_registered(chk_edit_after) {
	var formData = $( "#frm_data_search_reiged_2" ).serializeArray();
	formData.push({ "name": "acc_action", "value": "get_data_registered" });
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {
		$(".table_list_registed").html(data.course);
	})
}
function get_data_registered_edit(chk_edit_after) {
	var formData = $( "#frm_data_search_reiged_3" ).serializeArray();
	formData.push({ "name": "acc_action", "value": "get_data_registered_edit" });
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {
		$(".table_list_registed_edit").html(data.course);
	})
}

function save_regis_course(tempValue){
	var formData = new Array();
	formData.push({ "name": "acc_action", "value": "save_regis_course" }); 
	formData.push({ "name": "data_val", "value": tempValue}); 
	$.post('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {
		tempValue='';
		get_data();
		$('.modal').modal('hide');		
		$("#modalRegisted").modal("show");
		get_data_registered($(".chk_delete_btn_h").css("display"));
		get_data_registered_edit();
		get_data_year_search();
		
	})
}	

$(document).delegate('#chk_value_select', 'click', function(event) {
	var tempValue=$("input[name='checkbox_regis_course[]']:checked").map(function(n){ if(this.checked){return  this.value;}; }).get().join(',');
	if (tempValue!="") {
		$("#modalRegister").modal("show");
	}else{
		$("#modalNoSelect").modal("show");
	}
});
$(document).delegate('#btn__save_regis_course', 'click', function(event) {
	var tempValue=$("input[name='checkbox_regis_course[]']:checked").map(function(n){ if(this.checked){return  this.value;}; }).get().join(',');
		var term =$("#term").val();
		var year =$("#year").val();
		var formData = new Array();
		formData.push({ "name": "acc_action", "value": "chk_regiseted_course" }); 
		formData.push({ "name": "data_val", "value": tempValue }); 
		formData.push({ "name": "term", "value": term }); 
		formData.push({ "name": "year", "value": year }); 
		$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {
			if (data!="") {
				$(".modal").modal("hide");
				$("#text_chk_alert").html(data);
				$("#modalChkRegis").modal("show");
			}else{
				save_regis_course(tempValue);
			}
		});
	
});
$(document).delegate('#btn__save', 'click', function(event) {
	var courseID =$("#courseID").val();
	if(courseID!='') {	
		var formData = $( "#frm_data_edit" ).serializeArray();
		formData.push({ "name": "acc_action", "value": "save_data" }); 
		$.post('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {
			$(".modal").modal("hide");
			$("#modalEdited").modal("show");
			get_data();
			get_data_registered($(".chk_delete_btn_h").css("display"));
			window.location.reload();
		});
	}else{
		$("#courseID").removeClass("form-set");
		//$(".modal").modal("hide");
		$("#courseID").addClass("form-set-null-data_edit");
		$("#courseID").attr( "placeholder", "กรุณาใส่ข้อมูล" );
	}
	

});
function get_data(status) {
	var formData = $( "#frm_search" ).serializeArray();
	formData.push({ "name": "acc_action", "value": "get_data" }); 
	formData.push({ "name": "status", "value": status }); 
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {
		$("#table_list").html(data.table_list);
	});
}
$(document).delegate('#btn_courseID_search', 'click', function(event) {
	get_data(1);
});
$(document).delegate('#btn_department_class_search', 'click', function(event) {
	get_data();
});
$(document).delegate('#btn_cancel_checked', 'click', function(event) {
	$('.checkbox_data').each(function() { //loop through each checkbox
            this.checked = false;  //select all checkboxes with class "checkbox1"               
        });
});


function remove_class() {
	
	for (var i = 1 ; i <= 8; i++) {
		$("#dep_"+i).removeAttr("selected"); 
	}

	for (var i = 1 ; i <= 6; i++) {
		$("#p"+i).removeAttr("selected"); 
	}
	for (var i = 1 ; i <= 6; i++) {
		$("#m"+i).removeAttr("selected"); 
	}

	$("#unit_05").removeAttr("selected"); 
	$("#unit_10").removeAttr("selected"); 
	$("#unit_15").removeAttr("selected"); 
	$("#unit_20").removeAttr("selected"); 
	$("#unit_25").removeAttr("selected"); 
	$("#unit_30").removeAttr("selected"); 

	$("#course_status_1").removeAttr("selected"); 
	$("#course_status_2").removeAttr("selected");

}
function chk_class_to_en_unit(class_level_data) {
	if (class_level_data=="p1" || class_level_data=="p2" || class_level_data=="p3" || class_level_data=="p4" || class_level_data=="p5" || class_level_data=="p6") {
			$("#unit_chk").attr("disabled","disabled");
		}else{
			$("#unit_chk").removeAttr("disabled"); 	
		}
}
function select_teacher_to_course(teacher_id) {
	var teacher_id_array = teacher_id.split('-');
	var teacher_id_length =teacher_id_array.length;
	for (var i = 0; i < teacher_id_length; i++) {
		$(".checkbox_data_teacher_"+teacher_id_array[i]).attr("checked","checked"); 
	}
	
}
function get_teacher_to_course_registed(registered_id) {

	var formData = new Array();
	formData.push({ "name": "acc_action", "value": "get_teacher_to_course_registed" }); 
	formData.push({ "name": "registered_id", "value": registered_id }); 
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {

		$("#teacher_course_place").html(data.teacher_listed);
		select_teacher_to_course(data.teacher_id);

	});
}
function insert_teacher_to_course(teacher_id,registered_id) {
	var formData = new Array();
	formData.push({ "name": "acc_action", "value": "insert_teacher_to_course" }); 
	formData.push({ "name": "teacher_id", "value": teacher_id }); 
	formData.push({ "name": "registered_id", "value": registered_id }); 
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {
		get_teacher_to_course_registed(registered_id);
		get_data_registered_edit();
	});
}

$(document).delegate('.room_btn_chk', 'click', function(event) {
 	var course_teacher_id = $(this).attr('course-teacher-id');
 	var room_val = $(this).val();

 	var formData = new Array();
	formData.push({ "name": "acc_action", "value": "set_room_teacher" }); 
	formData.push({ "name": "course_teacher_id", "value": course_teacher_id }); 
	formData.push({ "name": "room_val", "value": room_val }); 
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {
		get_data_registered_edit();
	});
 });

$(document).delegate('.btn_room_detail', 'click', function(event) {
 	var data_id_registered_room = $(this).attr('data-id-registered-room');

 	var formData = new Array();
	formData.push({ "name": "acc_action", "value": "get_room_detail" }); 
	formData.push({ "name": "data_id_registered_room", "value": data_id_registered_room }); 
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {
		$("#course_detail_header").html(data.course_detail_header);
		$("#teacher_list_box").html(data.teacher_list_box);
		

	});
 });

$(document).delegate('#btn_courseID_search', 'click', function(event) {

 	var teacher_search_data =$("#teacher_search_data").val();
 	var data_id_registered=$("#data_id_registered_val").val();
 	var formData = new Array();
	formData.push({ "name": "acc_action", "value": "get_teacher_list" }); 
	formData.push({ "name": "data_id_registered", "value": data_id_registered }); 
	formData.push({ "name": "teacher_search_data", "value": teacher_search_data }); 
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {
		
		get_teacher_to_course_registed(data_id_registered)
		$("#table_teacher_list").html(data);

	});
 });
 $(document).delegate('.btn_teacher_list', 'click', function(event) {
 	var data_id_registered = $(this).attr('data-id-registered');

 	var formData = new Array();
	formData.push({ "name": "acc_action", "value": "get_teacher_list" }); 
	formData.push({ "name": "data_id_registered", "value": data_id_registered }); 
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {

		$("#data_id_registered_val").val(data_id_registered);
		get_teacher_to_course_registed(data_id_registered)
		$("#table_teacher_list").html(data);

	});
 });
 $(document).delegate('.btn_getdata_edit', 'click', function(event) {
 	$("#courseID").addClass("form-set");
 	remove_class() ;
 	var data_id = $(this).attr('data-id');
 	var formData = new Array();
	formData.push({ "name": "acc_action", "value": "getdata_edit" }); 
	formData.push({ "name": "data_id", "value": data_id }); 
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {
		
		var class_level_data=data.class_level;
		var department_data=data.department;
		var unit_data=data.unit;
		var status_data=data.status;
		$("#"+class_level_data).attr("selected","selected"); 
		$("#"+department_data).attr("selected","selected"); 
		$("#unit_"+unit_data).attr("selected","selected"); 
		$("#course_status_"+status_data).attr("selected","selected"); 
		chk_class_to_en_unit(class_level_data);
		$("#data_id_course").val(data.data_id_course);
		$("#courseID").val(data.courseID);
		$("#name").val(data.name);
		$("#hr_learn").val(data.hr_learn);
		if (status_data==2) {
			$("#unit_chk").attr("disabled","disabled");
			$("#department").attr("disabled","disabled");

		}else{
			$("#unit_chk").removeAttr("disabled");
			$("#department").removeAttr("disabled");

		}

	});

 });
$('input').on('keydown', function(event) {
   var x = event.which;
   if (x === 13) {
   	get_data();
    event.preventDefault();

   }
});<file_sep>/modules/menu/class_modules.php
<?php 

class ClassData extends Databases {


	var $role;
	var $role_id;

	public function __construct()
	{
		$this->role = new ClassRole();
		$this->role_id = (int)$_SESSION['ss_user_id'];
		// You don't have permission to access
	}

/*************************************** PROCESS DB ****************************************/
	
	public function get_data_list($arr_search_val,$pages_current,$sort_column,$sort_by){

		## SQL CONDITION ##
		$sql_condition = " DataID > 0 ";
		$data_name = $arr_search_val['data_name'];
		$s_status = $arr_search_val['s_status'];

		if (isset($data_name) && $data_name != "") {
			$sql_condition .= " AND ( boxI_name LIKE '%{$data_name}%' OR boxI_nameEn LIKE '%{$data_name}%')  ";
		}

		if (isset($s_status) && $s_status != "") {
			$sql_condition .= " AND ( status = '{$s_status}' )  ";
		}
		
		## SQL CONDITION ##	

		## PAGINATION ##
		$this->sql = " SELECT count(DataID) as data_id_total FROM tbl_menu WHERE {$sql_condition} ";
		$this->select();
		$this->setRows();
		$dataidtotal = (int)$this->rows[0]['data_id_total'];
		$pagination = new pagination();
		$pages = (int)$pages_current;
		$rowsperpage = 20; 
		$arrpage = $pagination->calculate_pages($dataidtotal, $rowsperpage, $pages);
		$sequence = ($arrpage['current'] == 1) ? 1 : ($arrpage['current'] * $rowsperpage)-1 ; 
		## PAGINATION ##

		## DATA TBLE ##
		$data_response = array();
		$data_response['data_list'] = "";
		if($dataidtotal > 0){

		$arr_status = array('Save Draft','Published');
		$sql_order_by = " sequence ASC ";

		$sql = "SELECT * 
				FROM tbl_menu  
				WHERE {$sql_condition} 
				AND DataID!=1
				ORDER BY {$sql_order_by} {$arrpage['limit']} ";
		$this->sql = $sql;
		$this->select();
		$this->setRows();
		foreach($this->rows as $key => $value) {

			$DataID = $this->rows[$key]['DataID'];
			$Title_Show = $this->rows[$key]['boxI_nameEn'];

			$sequence = (int)$this->rows[$key]['sequence'];
			$status = (int)$this->rows[$key]['status'];
			$update_time = $this->rows[$key]['update_time'];
			$arr_status = array("<span class=\"label label-important\">Save Draft</span>","<span class=\"label label-info\">Published</span>","<span class=\"label label-default\">Close</span>");

			$edit_hyperlink = "index.php?op=menu-from&id={$DataID}" ;

			$data_response['data_list'] .= "<tr>
							                  <td style=\"text-align: center;\">
							                    <div class=\"checkbox check-success\">
							                      <input type=\"checkbox\" value=\"{$DataID}\" name=\"checkbox_delete[]\" id=\"checkbox{$DataID}\" class=\"checkbox_data\">
							                      <label for=\"checkbox{$DataID}\">&nbsp;</label>
							                    </div>
							                  </td>
							                  <td style=\"text-align: center;\"><a href=\"{$edit_hyperlink}\">{$Title_Show }</a> </td>
							                  <td style=\"text-align: center;\">".DateThai($update_time,"date_en")."</td>
							                 <!--<td style=\"text-align: center;\">{$arr_status[$status]}</td>
							                  <td style=\"text-align: center;\"><input class=\"span2\" id=\"sequence_{$DataID}\" name=\"sequence_{$DataID}\" data-id=\"{$sequence}\"  type=\"text\" style=\"width:50px; text-align:center;\" value=\"{$sequence}\">-->
                <a class=\"btn btn-inverse btn_sequence\" data-id=\"{$DataID}\" href=\"javascript:;\"><i class=\"fa fa-arrows-v\"></i></a></td>";

			$data_response['data_list'] .= "<td style=\"text-align: center;\"><a class=\"btn btn-inverse btn_edit \" data-id=\"{$DataID}\" href=\"javascript:;\"><i class=\"fa fa-edit\"></i></a>" ;
			/*$data_response['data_list'] .= "<a class=\"btn btn-danger bt_delete\" data-id=\"{$DataID}\" href=\"javascript:;\"><i class=\"fa fa-trash-o\"></i></a>";*/
			$data_response['data_list'] .= "</td></tr>";

			$sequence++;

		}}

		## DATA TBLE ##
        /*$data_response['data_pagination'] .= "<li><a href=\"javascript:;\" data-id=\"{$arrpage['previous']}\" class=\"chg_pagination\">&laquo;</a></li>";
		for($p=0; $p<count($arrpage['pages']); $p++){ 
			$activepages = ($arrpage['pages'][$p]==$arrpage['current']) ? "active" : ""; 
			$data_response['data_pagination'] .= "<li class=\"{$activepages}\"><a href=\"javascript:;\" data-id=\"{$arrpage['pages'][$p]}\" class=\"chg_pagination\">{$arrpage['pages'][$p]}</a></li>";
		}
        $data_response['data_pagination'] .= " <li><a href=\"javascript:;\" data-id=\"{$arrpage['next']}\" class=\"chg_pagination\">&raquo;</a></li>";*/

		return json_encode($data_response);
		// return $data_response;

	}

	public function get_data_from($DataID){
		$data_response = array();
		$this->sql = "SELECT * FROM tbl_menu WHERE DataID={$DataID} " ;
		$this->select();
		$this->setRows();
		$data_response['boxI_name'] = unchkhtmlspecialchars($this->rows[0]['boxI_name']);
		$data_response['boxI_nameEn'] = unchkhtmlspecialchars($this->rows[0]['boxI_nameEn']);
		$data_response['boxI_desc'] = unchkhtmlspecialchars($this->rows[0]['boxI_desc']);
		$data_response['boxI_descEn'] = unchkhtmlspecialchars($this->rows[0]['boxI_descEn']);

		$data_response['boxII_name'] = unchkhtmlspecialchars($this->rows[0]['boxII_name']);
		$data_response['boxII_nameEn'] = unchkhtmlspecialchars($this->rows[0]['boxII_nameEn']);
		$data_response['boxII_desc'] = unchkhtmlspecialchars($this->rows[0]['boxII_desc']);
		$data_response['boxII_descEn'] = unchkhtmlspecialchars($this->rows[0]['boxII_descEn']);

		$data_response['boxIII_name'] = unchkhtmlspecialchars($this->rows[0]['boxIII_name']);
		$data_response['boxIII_nameEn'] = unchkhtmlspecialchars($this->rows[0]['boxIII_nameEn']);
		$data_response['boxIII_desc'] = unchkhtmlspecialchars($this->rows[0]['boxIII_desc']);
		$data_response['boxIII_descEn'] = unchkhtmlspecialchars($this->rows[0]['boxIII_descEn']);

		$data_response['boxIV_name'] = unchkhtmlspecialchars($this->rows[0]['boxIV_name']);
		$data_response['boxIV_nameEn'] = unchkhtmlspecialchars($this->rows[0]['boxIV_nameEn']);
		$data_response['boxIV_desc'] = unchkhtmlspecialchars($this->rows[0]['boxIV_desc']);
		$data_response['boxIV_descEn'] = unchkhtmlspecialchars($this->rows[0]['boxIV_descEn']);

		$data_response['status'] = $this->rows[0]['status'];
		$data_response['tag_title'] = $this->rows[0]['tag_title'];
		$data_response['tag_keyword'] = $this->rows[0]['tag_keyword'];
		$data_response['tag_description'] = $this->rows[0]['tag_description'];

		return json_encode($data_response);
	}

	public function get_data($DataID){
		$this->sql = "SELECT * FROM tbl_menu WHERE DataID={$DataID} " ;
		$this->select();
		return $this->getRows();
	}

	public function get_data_uniquevalue($field_name,$sql_where){
		$this->sql = "SELECT {$field_name} FROM tbl_menu WHERE {$sql_where} " ;
		$this->select();
		$this->setRows();
		return trim($this->rows[0][$field_name]);
	}

	public function insert_data($insert,$user_id){
		$this->sql = "INSERT INTO tbl_menu(".implode(",",array_keys($insert)).") VALUES (".implode(",",array_values($insert)).")";
		$this->query();
		$new_id = $this->insertID();

		$this->sql = "INSERT INTO tbl_log(title_action,menu_name,data_id,update_by,update_time) VALUES ('เพิ่มข้อมูล Menu','Menu','{$new_id}','{$user_id}',now())";
		$this->query();

		$this->sql = " SELECT sequence FROM tbl_menu ORDER BY sequence DESC, update_time DESC , create_time DESC LIMIT 0,1 ";
		$this->select();
		$this->setRows();
		$sequence_new =  $this->rows[0]['sequence']+1;

		$this->sql = "UPDATE tbl_menu SET sequence=$sequence_new WHERE DataID='".$new_id."'";
		$this->query();

		// $this->sql = "UPDATE tbl_keyword SET article_id=$new_id WHERE article_id = 0 AND type_page = 2";
		// $this->query();

		$this->sql = "UPDATE tbl_menu_gallery SET menuID = $new_id , status = $new_id  WHERE menuID = 0 AND status = 0  ";
		$this->query();

		
	}

	public function update_data($update,$DataID,$user_id){


        $this->sql = "INSERT INTO tbl_log(title_action,menu_name,data_id,update_by,update_time) VALUES ('แก้ไขข้อมูล Menu','Menu','{$DataID}','{$user_id}',now())";
		$this->query();

		$this->sql = "UPDATE tbl_menu SET ".implode(",",$update)." WHERE DataID='".$DataID."'";
		$this->query();

		// // $this->sql = "UPDATE tbl_keyword SET article_id=$new_id WHERE article_id = {$DataID}";
		// // $this->query();

		// $this->sql = "UPDATE tbl_menu_gallery SET menuID=$DataID WHERE menuID == 0";
		// $this->query();

	}

	public function get_data_delete($data_val,$user_id){

		$arr_id = explode(",", $data_val);
		for ($i=0; $i < count($arr_id) ; $i++) { 

	        $targetfile = "../../../file_managers/menu/";

		    $this->sql = " SELECT FileName FROM tbl_menu_gallery WHERE menuID = {$arr_id[$i]}";
		    $this->select();
		    $this->setRows();
		    foreach($this->rows as $key => $value) {
		    	$FileName =  $this->rows[$key]['FileName'];
		    	
		        if(@file_exists($targetfile."thumbnails/{$FileName}")){
				  @unlink($targetfile."thumbnails/{$FileName}");	
	            }
	            if(@file_exists($targetfile."photo/{$FileName}")){
				  @unlink($targetfile."photo/{$FileName}");	
	            }
        	}

            $this->sql ="DELETE FROM tbl_menu_gallery WHERE menuID = {$arr_id[$i]}";
            $this->query();

	        $this->sql = "SELECT sequence FROM tbl_menu WHERE DataID = {$arr_id[$i]}";
		    $this->select();
		    $this->setRows();
		    $sequence_new =  $this->rows[0]['sequence']-1;
		    $sequence =  $this->rows[0]['sequence'];

		    $this->sql = "UPDATE tbl_menu SET sequence=sequence-1 WHERE sequence > {$sequence}";
		    $this->query(); 

            $this->sql ="DELETE FROM tbl_menu WHERE DataID = {$arr_id[$i]}";
	        $this->query();

	        // $this->sql ="DELETE FROM tbl_keyword WHERE article_id = {$arr_id[$i]} AND type_page = 2";
         //    $this->query();

            $this->sql = "INSERT INTO tbl_log(title_action,menu_name,data_id,update_by,update_time) VALUES ('ลบข้อมูล Menu','Menu','{$arr_id[$i]}','{$user_id}',now())";
		    $this->query();

		}

	}

	public function ex_sequence_data($data_id,$sequence_old,$sequence,$user_id){
		if($sequence_old > $sequence){

			$st_limit 	= ($sequence-1);
			$ct_limit 	= ($sequence_old-$sequence);
			
			$this->sql = " SELECT sequence FROM tbl_menu WHERE DataID > 0 ORDER BY sequence ASC, update_time DESC , create_time DESC LIMIT {$st_limit},1 ";
			$this->select();
			$this->setRows();
			$sequence_new =  $this->rows[0]['sequence'];


			$this->sql = "UPDATE tbl_menu SET sequence=sequence+1 
								 WHERE DataID > 0
								 AND DataID IN (SELECT * FROM (SELECT DataID FROM tbl_menu WHERE DataID > 0 ORDER BY sequence ASC, update_time DESC , create_time DESC limit {$st_limit}, {$ct_limit}) AS t) 
								 ORDER BY sequence ASC, update_time DESC , create_time DESC ";
			$this->query();

								
			$this->sql = "UPDATE tbl_menu SET sequence='{$sequence_new}' WHERE DataID={$data_id}";
			$this->query();

		}else if($sequence_old < $sequence){
			$st_limit 	= ($sequence-1);
			$this->sql = " 	SELECT sequence FROM tbl_menu 
							WHERE DataID > 0 
							ORDER BY sequence ASC, update_time DESC , create_time DESC  
							LIMIT {$st_limit},1 
						  ";
			$this->select();
			$this->setRows();
			$sequence_new =  $this->rows[0]['sequence'];

			$st_limit 	= ($sequence_old-1);
			$ct_limit 	= ($sequence-$sequence_old)+1;

			$this->sql = "UPDATE tbl_menu SET sequence=sequence+1 
						  WHERE sequence <= {$sequence_new} AND sequence > {$st_limit} AND DataID <> {$data_id}  
						  ORDER BY sequence ASC, update_time DESC , create_time DESC  ";
			$this->query();
						
			$this->sql = "UPDATE tbl_menu SET sequence='{$sequence_new}' WHERE DataID='{$data_id}'";
			$this->query();

			$this->sql = "INSERT INTO tbl_log(title_action,menu_name,data_id,update_by,update_time) VALUES ('จัดอันดับข้อมูล Menu','Menu','{$data_id}','{$user_id}',now())";
		    $this->query();

		}
		
	}

    public function ex_add_thumb($insert){

		$this->sql = "INSERT INTO tbl_menu_gallery(".implode(",",array_keys($insert)).") VALUES (".implode(",",array_values($insert)).")";
		$this->query();
		$photo_id = $this->insertID();

		$this->sql = "UPDATE tbl_menu_gallery SET sequence=$photo_id WHERE DataID='".$photo_id."'";
		$this->query();	

		return $photo_id;
	}

	public function get_thumb($data_id){
		
		$sql_condition = "WHERE menuID={$data_id} AND Type = 0 ";

		$sql_order_by = " sequence ASC ";

		$sql = "SELECT DataID,FileName
				FROM tbl_menu_gallery 
				 {$sql_condition} 
				";
		$this->sql = $sql;
		$this->select();
		$this->setRows();
		foreach($this->rows as $key => $value) {
			$DataID = $value['DataID'];
			$FileName = $value['FileName'];//unchkhtmlspecialchars
			$file_name = (@file_exists("../../../file_managers/menu/thumbnails/{$FileName}")) ? $FileName : "thumbnail.jpg";
			$data_response .= "
			        <center>
					<div class=\"col-lg-12 col-md-10\">
						<p class=\"small no-margin\"><img src=\"../file_managers/menu/thumbnails/{$FileName}?".time()."\" style=\"width:auto;\" class=\"img-rounded m-r-25  m-b-10\"></p>
						<div class=\"btn-group btn-group-xs text-center\">
						  <a href=\"javascript:;\"  data-id=\"{$DataID}\" class=\" btn btn-danger btn_remove_thumb\">Remove</a>
						</div>                    
						<hr/>
					</div>
					</center>";
			$sequence++;
		}

		return $data_response;
	}
	
	public function remove_thumb($data_id){
		$targetfile = "../../../file_managers/menu/";

		$this->sql = " SELECT FileName FROM tbl_menu_gallery WHERE DataID = {$data_id} LIMIT 0,1 ";
		$this->select();
		$this->setRows();
		$FileName =  $this->rows[0]['FileName'];
	    if(@file_exists($targetfile."thumbnails/{$FileName}")){
			@unlink($targetfile."thumbnails/{$FileName}");	

		}

        $this->sql ="DELETE FROM tbl_menu_gallery WHERE DataID={$data_id} ";
        $this->query();
		return "y";

	}


public function ex_add_award($insert){

		$this->sql = "INSERT INTO tbl_menu_gallery(".implode(",",array_keys($insert)).") VALUES (".implode(",",array_values($insert)).")";
		$this->query();
		$photo_id = $this->insertID();

		$this->sql = "UPDATE tbl_menu_gallery SET sequence=$photo_id WHERE DataID='".$photo_id."'";
		$this->query();	

		return $photo_id;
	}

public function get_photo_award($data_id){

		$sql_condition = " menuID={$data_id} AND Type = 1";

		$sql_order_by = " sequence ASC ";

		$sql = "SELECT DataID,FileName
				FROM tbl_menu_gallery 
				WHERE {$sql_condition} 
				ORDER BY {$sql_order_by} ";
		$this->sql = $sql;
		$this->select();
		$this->setRows();
		foreach($this->rows as $key => $value) {
			$DataID = $value['DataID'];
			$FileName = $value['FileName'];//unchkhtmlspecialchars
			$file_name = (@file_exists("../../../file_managers/menu/photo/{$FileName}")) ? $FileName : "thumbnail.jpg";
			$data_response .= "
					<div class=\"col-lg-3 col-md-3\">	
						<div class=\"row\">	
							<div class=\"col-lg-12 col-md-12\">
								<p class=\"small no-margin text-center\">
								<img src=\"../file_managers/menu/photo/{$FileName}?".time()."\" style=\"width:200px;\" class=\"img-rounded m-r-25  m-b-10\">
								</p>
								<p class=\"small no-margin text-center\">
									  <a href=\"javascript:;\"  data-id=\"{$DataID}\" class=\" btn-sm btn-danger btn_remove_award\">Remove</a>
								</p>
							</div>
						</div>
						<hr/>
					</div>";
			$sequence++;
		}

		return $data_response;
	}

	public function remove_file_award($data_id){
		$targetfile = "../../../file_managers/menu/";

		$this->sql = " SELECT FileName FROM tbl_menu_gallery WHERE DataID = {$data_id} LIMIT 0,1 ";
		$this->select();
		$this->setRows();
		$FileName =  $this->rows[0]['FileName'];
	    if(@file_exists($targetfile."photo/{$FileName}")){
			@unlink($targetfile."photo/{$FileName}");				

		}

        $this->sql ="DELETE FROM tbl_menu_gallery WHERE DataID={$data_id} ";
        $this->query();
		return "y";

	}	


/*************************************** PROCESS DB ****************************************/

}


?><file_sep>/modules/regis_course/index.php
<div class="container set-content-pad-20" >
  <div class="bg-whte" style="position: relative;padding-bottom: 60px">
    <div class="circle-bg-violet">
      <img class="head-img-circle" src="assets/images/1.png">
    </div>
    <div class="text-head-title">
      <p>ลงทะเบียนรายวิชา</p>
    </div>
    <div class="text-head-desc">
      <p>ใช้สำหรับลงทะเบียน เพิ่มรายวิชาตามโครงสร้างหลักสูตรของสถานศึกษาเข้าสู่ระบบ</p>
    </div>
    <div class="row pd-50 pt-80 stage-set" >                  
      <div class="col-sm-12 col-xs-12 mt-30">  
        <?php if ($_SESSION['ss_status']==4){  ?>   
          <p class="text-bold text-before-box" >ภาคเรียนและปีการศึกษาปัจจุบัน</p>
        <?php }else{ ?>
          <p class="text-bold text-before-box" >กำหนดภาคเรียนและปีการศึกษาปัจจุบัน</p>
        <?php } ?>
        <form id="frm_data">   
          <table>
            <tbody style="border: none;">
              <tr>
                <td>
                  <select id="term_set" name="term_set" class="form-control search-class-depart ml-10">    
                    <option id="term_search_id_1" value="1">ภาคเรียนที่ 1</option>
                    <option id="term_search_id_2" value="2">ภาคเรียนที่ 2</option> 
                    <option id="term_search_id_1_2" value="">ภาคเรียนที่ 1,2</option>                           
                  </select>
                </td>
                <td>
                  <select id="year_set" name="year_set" class="form-control search-course-depart ml-10">
                   
                  </select>
                </td>
                <?php if ($_SESSION['ss_status']==2){  ?>  
                <td>
                  <div class="ml-20" style="margin-top: -2px">
                    <div data-toggle="modal" data-target="#modalAddTermYear" class="btn-search">
                      <span class="glyphicon glyphicon-arrow-right" aria-hidden="true"></span>
                    </div>  
                  </div>
                </td>
              <?php } ?>
              </tr>
            </tbody>
          </table>
        </form>  

      </div>                     
    </div>
    <div class="row">
      <div class="hr-co-text-depart mt-nega-30"></div> 
    </div>
    <div class=" ml-50 mr-50" >
      <div class="row">
        <ul class="nav nav-tabs" role="tablist">
          <?php if ($_SESSION['ss_status']==2){  ?>   
          <li role="presentation" class="active"><a class="text-black" href="#all_sub_tab" aria-controls="all_sub_tab" role="tab" data-toggle="tab">เลือกวิชาลงทะเบียน</a></li>
          <li role="presentation" ><a class="text-black" href="#registed_tab" aria-controls="registed_tab" role="tab" data-toggle="tab">รายวิชาที่ลงทะเบียนแล้ว</a></li>
          <li role="presentation" ><a class="text-black" href="#teacher_tab" aria-controls="teacher_tab" role="tab" data-toggle="tab">กำหนดผู้สอนและห้องเรียน</a></li>
          <?php }else{ ?>
           <li role="presentation" class="active"  ><a class="text-black" href="#teacher_tab" aria-controls="teacher_tab" role="tab" data-toggle="tab">กำหนดผู้สอนและห้องเรียน</a></li>
          <?php } ?>

        </ul>
      </div>
      <div class="tab-content">
        <div role="tabpanel" class="tab-pane fade <?php if ($_SESSION['ss_status']==2){ echo "in active";} ?>" id="all_sub_tab">
          <div class="row mt-30" ">
            <div class="text-title-table">
              <h4 class="text-bold">เลือกวิชาลงทะเบียน</h4>
            </div>
          </div>
          <div class="row search-box-regis-course stage-set" >
            <div class="col-sm-5 col-xs-12">   
              <form id="frm_search">
                <p class="text-bold text-search set-text-search-1" >ค้นหาจากรายวิชา</p>

                <div class="input-group form-serch-width-regis">
                  <input id="courseID_search" name="courseID_search" type="text" class="form-control form-set-search" placeholder="*รหัสวิชา" aria-describedby="basic-addon1">
                </div>                          

                <div class="btn-search-poi-regis-1">
                  <div id="btn_courseID_search" class="btn-search "><span class="glyphicon glyphicon-search" aria-hidden="true"></span></div>     
                </div>   
              </div>
              <div class="col-sm-7 col-xs-12">                        
                <p class="text-bold text-search set-text-search-2" >ค้นหาจาก</p>
                <select id="department_search" name="department_search" class="form-control search-group">
                  <option value="">ทุกกลุ่มสาระ</option>
                  <option value="2">คณิตศาสตร์</option>
                  <option value="1">ภาษาไทย</option>
                  <option value="8">ภาษาต่างประเทศ</option>
                  <option value="3">วิทยาศาสตร์</option>
                  <option value="31">วิทยาศาสตร์และเทคโนโลยี</option>
                  
                  <option value="4">สังคมศึกษา ศาสนาและวัฒนธรรม</option>
                  
                  <option value="71">การงานอาชีพ</option>
                  <option value="7">การงานอาชีพและเทคโนโลยี</option>                             
                  <option value="5">สุขศึกษาและพลศึกษา</option>
                  <option value="6">ศิลปะ</option>
                 
                  <option value="dev_mode">กิจกรรมพัฒนาผู้เรียน</option>
                </select>
                <select id="class_level_search" name="class_level_search" class="form-control search-group">
                  <option value="">ทุกระดับชั้น</option>
                  <option value="p1"> ป.1</option>
                  <option value="p2"> ป.2</option>
                  <option value="p3"> ป.3</option>
                  <option value="p4"> ป.4</option>
                  <option value="p5"> ป.5</option>
                  <option value="p6"> ป.6</option>
                  <option value="m1"> ม.1</option>
                  <option value="m2"> ม.2</option>
                  <option value="m3"> ม.3</option>
                  <option value="m4"> ม.4</option>
                  <option value="m5"> ม.5</option>
                  <option value="m6"> ม.6</option>
                </select>
                <div class="btn-search-poi-regis">
                  <div id="btn_department_class_search" class="btn-search">
                    <span class="glyphicon glyphicon-search" aria-hidden="true"></span>
                  </div>  
                </div>
              </div> 
            </form>                 
          </div>
         
          <div class="row">
            <div class="col-md-12">
              <div class="table-responsive">
                <table class="table table-striped-violet" >
                  <thead class="header-table">
                    <tr>
                      <th></th>
                      <th style="text-align: left;">รหัสวิชา</th>
                      <th style="text-align: left;">รายวิชา</th>
                      <th style="text-align: left;">ประเภท</th>
                      <th>น.น./นก.</th>
                      <th>เวลาเรียน</th>
                      <th>ระดับชั้น</th>
               
                    </tr>
                  </thead>
                  <tbody id="table_list" class="body-table">

                  </tbody>
                </table> 
              </div>
            </div>                                     
          </div>   
            <div id="btn_cancel_checked" class="btn-grey">
              ยกเลิก
            </div>    
            <div data-toggle="modal" id="chk_value_select" class="btn-violet">
              ลงทะเบียน
            </div>      
        </div>
        <div role="tabpanel" class="tab-pane fade " id="registed_tab">
          <div class="row mt-30" ">
            <div class="text-title-table">
              <h4 class="text-bold">รายวิชาที่ลงทะเบียนแล้ว</h4>
            </div>
          </div>
         
          <div class="row mt-10">
            <div class="col-md-12">
              <div class="table-responsive">
                <table class="table table-striped-violet" >
                  <thead class="header-table">
                    <tr>

                      <th style="text-align: left;padding-left: 30px;">รหัสวิชา</th>
                      <th style="text-align: left;">รายวิชา</th>
                      <th style="text-align: left;">ประเภท</th>
                      <th>น.น./นก.</th>
                      <th>เวลาเรียน</th>
                      <th>ระดับชั้น</th>                           
                      <th>ยกเลิก</th>
                    </tr>
                  </thead>
                  <tbody class="body-table table_list_registed">

                  </tbody>
                </table> 
              </div>
            </div>                                     
          </div> 
        </div>
       <div role="tabpanel" class="tab-pane fade <?php if ($_SESSION['ss_status']==4){ echo "in active";} ?>" id="teacher_tab">
          <div class="row mt-30" ">
            <div class="text-title-table">
              <h4 class="text-bold">กำหนดผู้สอนและห้องเรียน</h4>
            </div>
          </div>

          <div class="row mt-10">
            <div class="col-md-12">
              <div class="table-responsive">
                <table class="table table-striped-violet" >
                  <thead class="header-table">
                    <tr>

                      <th style="text-align: left;padding-left: 30px;">รหัสวิชา</th>
                      <th style="text-align: left;">รายวิชา</th>
                      <th style="text-align: left;">ประเภท</th>
                      <th>น.น./นก.</th>
                      <th>เวลาเรียน</th>
                      <th>ระดับชั้น</th>                           
                      <th>ครูผู้สอน</th>
                      <th>ห้อง</th>
                    </tr>
                  </thead>
                  <tbody class="body-table table_list_registed_edit">

                  </tbody>
                </table> 
              </div>
            </div>                                     
          </div> 
        </div>
        </div>
      </div>

      
    </div>

  </div>   

</div><file_sep>/modules/up_class/process.php
<?php
@ob_start();
@session_start();

require_once('../../init.php');
include('../../src/class.pagination.php');
include('../../src/class.inputfilter.php');
$InputFilter = new InputFilter();

##CLASS_DB_CONNECT##
include('class_modules.php');
$class_data = new ClassData();
##CLASS_DB_CONNECT##

if(isset($_POST['acc_action']) and $_POST['acc_action'] == "reverse_upclass"){	
	
	$log_upclass_id= $_POST['log_upclass_id'];
	$data_year_old= $_POST['data_year_old'];
	$data_year_new= $_POST['data_year_new'];
	echo $class_data->reverse_upclass($data_year_old,$data_year_new,$log_upclass_id);
}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "data_upclassed"){	
	echo $class_data->data_upclassed();
}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "up_class_m"){	
	echo $class_data->up_class_m($_GET['value_set']);
}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "up_class_p"){	
	echo $class_data->up_class_p($_GET['value_set']);
}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "up_class"){	
	echo $class_data->up_class();
}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_year"){	
	echo $class_data->get_year();
}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "data_year_search_student"){	
	$data_class_search= $_GET['data_class_search'];
	echo $class_data->data_year_search_student($data_class_search);
}<file_sep>/modules/attend_class/backup/class_modules.php
<?php 

class ClassData extends Databases {
	
	public function get_week_between($coures_id_list_val){
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 		
					WHERE DataID=$coures_id_list_val	
							";
		$this->select();
		$this->setRows();
		$class_level=$this->rows[0]['class_level'];
		if ($class_level=='p1' || $class_level=='p2' || $class_level=='p3' || $class_level=='p4' || $class_level=='p5' || $class_level=='p6') {
			$data_response='
							<option value="1-10">สัปดาห์ที่ 1-10</option>
                             <option value="11-20">สัปดาห์ที่ 11-20</option>    
                             <option value="21-31">สัปดาห์ที่ 21-31</option>   
                             <option value="31-40">สัปดาห์ที่ 31-40</option>  
			';
		}else{
			$data_response='
							<option value="1-10">สัปดาห์ที่ 1-10</option>
                             <option value="11-20">สัปดาห์ที่ 11-20</option>    
			';
		}
		echo json_encode($data_response);
	}
	public function get_count_adttend_class_val($coures_id_list_val){
		$this->sql ="SELECT  *
					FROM tbl_set_term_year 			
							";
		$this->select();
		$this->setRows();
		$term_set=$this->rows[0]['term'];
		$year_set=$this->rows[0]['year'];
		$class_level=$this->rows[0]['class_level'];
		if ($class_level=='p1' || $class_level=='p2' || $class_level=='p3' || $class_level=='p4' || $class_level=='p5' || $class_level=='p6') {
			$term_set='1,2';
		}
		$registed_courseID=$this->get_registed_courseID($coures_id_list_val,$term_set,$year_set);
		$this->sql ="SELECT  *
					FROM tbl_set_count_adttend_class
					WHERE registed_courseID=$registed_courseID		
							";
		$this->select();
		$this->setRows();
		$week_name=$this->rows[0]['week_name'];
		echo json_encode($week_name);
	}
	/*public function set_count_adttend_class_val($coures_id_list_val,$set_count_adttend_class_val){
		$this->sql ="SELECT  *
					FROM tbl_set_term_year 			
							";
		$this->select();
		$this->setRows();
		$term_set=$this->rows[0]['term'];
		$year_set=$this->rows[0]['year'];
		$class_level=$this->rows[0]['class_level'];
		if ($class_level=='p1' || $class_level=='p2' || $class_level=='p3' || $class_level=='p4' || $class_level=='p5' || $class_level=='p6') {
			$term_set='1,2';
		}

		$registed_courseID=$this->get_registed_courseID($coures_id_list_val,$term_set,$year_set);
		$this->sql ="SELECT  COUNT(*) as num_row
					FROM tbl_set_count_adttend_class 	
					WHERE registed_courseID	=$registed_courseID	
							";
		$this->select();
		$this->setRows();
		$num_row=$this->rows[0]['num_row'];
		if ($num_row>0) {
			$this->sql ="UPDATE tbl_set_count_adttend_class SET week_name=$set_count_adttend_class_val WHERE registed_courseID=$registed_courseID
							";
			$this->query();
		}else{
			$this->sql ="INSERT INTO tbl_set_count_adttend_class(registed_courseID,week_name) VALUES($registed_courseID,$set_count_adttend_class_val)		
							";
			$this->query();
		}
		

	}*/
	public function chk_value_attend_1($score_status){
		if ($score_status=="1") {
			$data_response="selected";
		}
		return $data_response;
	}
	public function chk_value_attend_l($score_status){
		if ($score_status=="ล") {
			$data_response="selected";
		}
		return $data_response;
	}
	public function chk_value_attend_p($score_status){
		if ($score_status=="ป") {
			$data_response="selected";
		}
		return $data_response;
	}
	public function chk_value_attend_k($score_status){
		if ($score_status=="ข") {
			$data_response="selected";
		}
		return $data_response;
	}
	public function chk_value_attend_n($score_status){
		if ($score_status=="น") {
			$data_response="selected";
		}
		return $data_response;
	}
	public function chk_value_attend__($score_status){
		if ($score_status=="0" || $score_status=="-") {
			$data_response="selected";
		}
		return $data_response;
	}
	public function get_score_col($std_ID,$registed_courseID,$start_data,$end_data){

		$this->sql ="SELECT  *
					FROM tbl_course_teaching_std 	
					WHERE registed_courseID=$registed_courseID
					AND stdID='$std_ID'
					";
			$this->select();
			$this->setRows();	
			$course_teaching_stdID=$this->rows[0]['DataID'];	
		$this->sql ="SELECT  *
					FROM tbl_attend_class 	
					WHERE course_teaching_stdID=$course_teaching_stdID		
					AND week BETWEEN $start_data AND $end_data	
					ORDER BY week ASC 	
					";
			$this->select();
			$this->setRows();	
			foreach($this->rows as $key => $value) {					
				$attendID=$value['DataID'];
				$week=$value['week'];
				$score_status=$value['score_status'];	
				$data_response['score_col'].="
							<td class=\"relative\">
			                    <select  disabled=\"disabled\" name=\"attend_score_std[]\" class=\"select-table-form class_col_set_new class_col_attend_{$week} value_attend_week_{$week}\">
			                      <option value=\"1\" {$this->chk_value_attend_1($score_status)}>1</option>
			                      <option value=\"ล\" {$this->chk_value_attend_l($score_status)}>ล</option>
			                      <option value=\"ป\" {$this->chk_value_attend_p($score_status)}>ป</option>
			                      <option value=\"ข\" {$this->chk_value_attend_k($score_status)}>ข</option>
			                      <option value=\"น\" {$this->chk_value_attend_n($score_status)}>น</option>
			                      <option value=\"-\" {$this->chk_value_attend__($score_status)}>-</option>
			                    </select>
			                  </td>
				"; 
				
			}
			
			return $data_response;
	}	

	public function get_score_col_total($std_ID,$registed_courseID,$start_data,$end_data,$num_row_std,$no_std){
		$this->sql ="SELECT  *
					FROM tbl_course_teaching_std 	
					WHERE registed_courseID=$registed_courseID
					AND stdID='$std_ID'
					";
		$this->select();
		$this->setRows();
		$course_teaching_stdID=$this->rows[0]['DataID'];
		$this->sql ="SELECT  SUM(score_status) as sum_score_status
					FROM tbl_attend_class 	
					WHERE course_teaching_stdID=$course_teaching_stdID		
					AND week BETWEEN $start_data AND $end_data	
					ORDER BY week ASC 	
					";
		$this->select();
		$this->setRows();
		return $this->rows[0]['sum_score_status'];

	}
	public function get_all_attendID($std_ID,$registed_courseID,$start_data,$end_data,$num_row_std,$no_std){
		$this->sql ="SELECT  *
					FROM tbl_course_teaching_std 	
					WHERE registed_courseID=$registed_courseID
					AND stdID='$std_ID'
					";
			$this->select();
			$this->setRows();	
			$course_teaching_stdID=$this->rows[0]['DataID'];	
			$this->sql ="SELECT  count(*) as num_attend_row
					FROM tbl_attend_class 	
					WHERE course_teaching_stdID=$course_teaching_stdID		
					AND week BETWEEN $start_data AND $end_data	
					ORDER BY week ASC 	
					";
			$this->select();
			$this->setRows();	
			$num_attend_row=$this->rows[0]['num_attend_row'];	
			$this->sql ="SELECT  *
					FROM tbl_attend_class 	
					WHERE course_teaching_stdID=$course_teaching_stdID		
					AND week BETWEEN $start_data AND $end_data	
					ORDER BY week ASC 	
					";
			$this->select();
			$this->setRows();	
			$num_set=1;
			foreach($this->rows as $key => $value) {
				if ($num_row_std==$no_std) {
					if ($num_set==$num_attend_row) {
						$attendID.=$value['DataID'];
					}else{
						$attendID.=$value['DataID'].'-';
					}
				}else{
					$attendID.=$value['DataID'].'-';
				}
				
				$num_set++;
			}
			return $attendID;
	}
	public function get_detail_std($coures_id_list_val,$start_data,$end_data,$room_search){
		$this->sql ="SELECT  *
					FROM tbl_set_term_year 			
							";
		$this->select();
		$this->setRows();
		$term_set=$this->rows[0]['term'];
		$year_set=$this->rows[0]['year'];
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 	
					WHERE DataID=$coures_id_list_val					
					";
		$this->select();
		$this->setRows();
		$class_level=$this->rows[0]['class_level'];
		if ($class_level=='p1' || $class_level=='p2' || $class_level=='p3' || $class_level=='p4' || $class_level=='p5' || $class_level=='p6') {
			$term_set='1,2';
		}

		$this->sql ="SELECT  COUNT(*) as num_row_std
					FROM tbl_student 	
					WHERE room='$room_search'
					AND std_ID in(
						SELECT stdID
					    FROM tbl_course_teaching_std
					    WHERE registed_courseID IN(
					    	SELECT DataID
					        FROM tbl_registed_course
					        WHERE courseID=$coures_id_list_val
					        AND term='$term_set'
					        AND year='$year_set'
					    )
					)

					";
		$this->select();
		$this->setRows();
		$num_row_std=$this->rows[0]['num_row_std'];
		$this->sql ="SELECT  *
					FROM tbl_student 	
					WHERE room='$room_search'
					AND std_ID in(
						SELECT stdID
					    FROM tbl_course_teaching_std
					    WHERE registed_courseID IN(
					    	SELECT DataID
					        FROM tbl_registed_course
					        WHERE courseID=$coures_id_list_val
					        AND term='$term_set'
					        AND year='$year_set'
					    )
					)
					";
		$this->select();
		$this->setRows();
		$no_std=1;
		foreach($this->rows as $key => $value) {
			$std_ID=$value['std_ID'];
			$fname=$value['fname'];
			$lname=$value['lname'];
			$class_level_status=$this->get_class_level_status($coures_id_list_val);
			if ($class_level_status=='p') {
				$term_set='1,2';
			}
			$registed_courseID=$this->get_registed_courseID($coures_id_list_val,$term_set,$year_set);
			$all_attendID.=$this->get_all_attendID($std_ID,$registed_courseID,$start_data,$end_data,$num_row_std,$no_std);
			$score_col=$this->get_score_col($std_ID,$registed_courseID,$start_data,$end_data);		
			$score_col_total=$this->get_score_col_total($std_ID,$registed_courseID,$start_data,$end_data,$num_row_std,$no_std);
			$data_response['detail_std'].='<tr>
										<td>'.$no_std.'</td>
						                  <td>'.$fname.' '.$lname.'</td>
						                  '.$score_col['score_col'].'
						                 <td>'.$score_col_total.'</td>
						             </tr>
			';	
			$no_std++;		
		}
		$data_response['all_attendID'].=$all_attendID;
		return $data_response;
	}
	public function get_class_level_status($coures_id_list_val){
		$data_response = array();	
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 	
					WHERE DataID=$coures_id_list_val
					";
		$this->select();
		$this->setRows();		
		$class_level=$this->rows[0]['class_level'];	
		if ($class_level=='p1' || $class_level=='p2' || $class_level=='p3' || $class_level=='p4' || $class_level=='p5' || $class_level=='p6') {
			$data='p';
		}else{
			$data='m';
		}
		return $data;
	}
	public function get_registed_courseID($coures_id_list_val,$term_set,$year_set){
		$data_response = array();	
		$this->sql ="SELECT  *
					FROM tbl_registed_course 	
					WHERE courseID=$coures_id_list_val
					AND term='$term_set'
					AND year='$year_set'

					";
		$this->select();
		$this->setRows();		
		return $this->rows[0]['DataID'];	
	}
	public function get_std_id_all($coures_id_list_val,$room_search){
		$this->sql ="SELECT  count(*) as num_row_std
					FROM tbl_student 
					WHERE room='$room_search'
					AND std_ID in(
						SELECT stdID
						FROM tbl_course_teaching_std
						WHERE registed_courseID in(
							SELECT DataID
							FROM tbl_registed_course
							WHERE courseID=$coures_id_list_val
						)
					)
					";
		$this->select();
		$this->setRows();	
		$num_row_std=$this->rows[0]['num_row_std'];	
		$this->sql ="SELECT *
					FROM tbl_student 
					WHERE room='$room_search'
					AND std_ID in(
						SELECT stdID
						FROM tbl_course_teaching_std
						WHERE registed_courseID in(
							SELECT DataID
							FROM tbl_registed_course
							WHERE courseID=$coures_id_list_val
						)
					)
					";
		$this->select();
		$this->setRows();
		$no_std=1;
		foreach($this->rows as $key => $value) {

			$std_ID=$value['std_ID'];		
			if ($num_row_std==$no_std) {
				$std_id_all.=$std_ID;
			}else{
				$std_id_all.=$std_ID.'-';
			}
			
			$no_std++;
			
		}
		$data_response=$std_id_all;
		return $data_response;
	}
	public function get_week_list_data($coures_id_list_val,$length_list_val,$room_search){
		$data_response = array();		
		list($start_data, $end_data) = split('[-]', $length_list_val);
		$find_start=$start_data-1;
		$find_end=$end_data-$find_start;
		
		$detail_std=$this->get_detail_std($coures_id_list_val,$start_data,$end_data,$room_search);
		$data_response['detail_std']=$detail_std['detail_std'];
		$data_response['all_attendID']=$detail_std['all_attendID'];
		
		$data_response['std_id_all']=$this->get_std_id_all($coures_id_list_val,$room_search);
		//$data_response['std_id_all']=$this->get_std_id_all($coures_id_list_val,$room_search);
		$data_response['data_objectiveID_of_title']=$data_objective;
		return json_encode($data_response);
	}
	public function get_week_list($length_list_val){
		$data_response = array();
		if ($length_list_val=='1-10') {
			for ($i=1; $i <=10 ; $i++) { 
				$data_response['week_list'].=' <option value="attend_'.$i.'">สัปดาห์ที่ '.$i.'</option>';
				$data_response['week_header'].='<td rowspan="3"><p>สัปดาห์ที่ '.$i.'</p></td>';
			}		
		}elseif($length_list_val=='11-20'){
			for ($i=11; $i <=20 ; $i++) { 
				$data_response['week_list'].=' <option value="attend_'.$i.'">สัปดาห์ที่ '.$i.'</option>';
				$data_response['week_header'].='<td rowspan="3"><p>สัปดาห์ที่ '.$i.'</p></td>';
			}
		}
		$data_response['week_header'].=' <td>รวม</td>';

		return json_encode($data_response);
	}
	public function search_course_detail($coures_id_list,$room_search){
		$data_response = array();	
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 	
					WHERE DataID=$coures_id_list
					";
		$this->select();
		$this->setRows();		
		$data_response['courseID']=$this->rows[0]['courseID'];	
		$data_response['name']=$this->rows[0]['name'];	
		$data_response['unit']=$this->rows[0]['unit'];	
		$data_response['hr_learn']=$this->rows[0]['hr_learn'];	
		$class_level_data=$this->rows[0]['class_level'];
		$class_level=$this->get_class_level_new($class_level_data);
		$data_response['class_level_co']=$class_level.'/'.$room_search;

		return json_encode($data_response);
	}
	public function get_class_level($coures_id_list_val){
		$this->sql ="SELECT  *
					FROM tbl_set_term_year 			
							";
		$this->select();
		$this->setRows();
		$term_set=$this->rows[0]['term'];
		$year_set=$this->rows[0]['year'];
		$data_response = array();	
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 	
					WHERE DataID=$coures_id_list_val
					AND DataID in(
                    	SELECT courseID
                        FROM tbl_registed_course 
                        WHERE term='$term_set'  
                        OR term='1,2'
                        AND year='$year_set'
                         AND DataID IN(
                            SELECT registed_courseID
                        	FROM tbl_registed_course_teaching
                        )
                    )
					";
		$this->select();
		$this->setRows();		
		$class_level_data=$this->rows[0]['class_level'];	
		$data_response['class_level']=$this->get_class_level_new($class_level_data);
		if ($class_level_data=='p1' || $class_level_data=='p2' || $class_level_data=='p3' || $class_level_data=='p4' || $class_level_data=='p5' || $class_level_data=='p6' ) {
			$term_set='1,2';
		}
		$this->sql ="SELECT distinct room
						FROM tbl_student 
						WHERE std_ID in(
							SELECT stdID
							FROM tbl_course_teaching_std
							WHERE registed_courseID in(
								SELECT DataID
								FROM tbl_registed_course
								WHERE courseID=$coures_id_list_val
                                AND term='$term_set'
                                AND year='$year_set'
								)
						)
						ORDER BY room ASC
							";
			$this->select();
			$this->setRows();
			foreach($this->rows as $key => $value) {
				$room=$value['room'];
				$data_response['room'].=' <option>'.$room.'</option>';
			}

		return json_encode($data_response);
	}

	public function get_registed_courseID_set($courseID,$term_set,$year_set){
		$this->sql ="SELECT  *
					FROM tbl_registed_course 			
					WHERE courseID=$courseID
					AND term='$term_set'
					AND year='$year_set'						
							";
		$this->select();
		$this->setRows();
		return	$this->rows[0]['DataID'];
	}
	public function get_coures_id_list(){
		$data_response = array();	
		$this->sql ="SELECT  *
					FROM tbl_set_term_year 			
							";
		$this->select();
		$this->setRows();
		$term_set=$this->rows[0]['term'];
		$year_set=$this->rows[0]['year'];
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 		
                    WHERE DataID in(
                    	SELECT courseID
                        FROM tbl_registed_course
                        WHERE term='$term_set'
                        AND year='$year_set'
                        AND DataID IN(
                        	SELECT registed_courseID
                            FROM tbl_registed_course_teaching
                        )                      
                    )
					ORDER BY courseID ASC								
							";
		$this->select();
		$this->setRows();
		foreach($this->rows as $key => $value) {
			$courseID=$value['DataID'];
			$registed_courseID=$this->get_registed_courseID_set($courseID,$term_set,$year_set);
			$courseID_long=$value['courseID'];
			$data_response['coures_id_list'].='
							<option value="'.$courseID.'">'.$courseID_long.'</option>
			';
		}
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 		
                    WHERE DataID in(
                    	SELECT courseID
                        FROM tbl_registed_course
                        WHERE term='1,2'
                        AND DataID IN(
                        	SELECT registed_courseID
                            FROM tbl_registed_course_teaching
                        )
                    )
					ORDER BY courseID ASC	
							";
		$this->select();
		$this->setRows();
		foreach($this->rows as $key => $value) {
			$DataID=$value['DataID'];
			$courseID_long=$value['courseID'];
			$data_response['coures_id_list'].='
							<option value="'.$DataID.'">'.$courseID_long.'</option>
			';
		}
		return json_encode($data_response);
	}
	public function get_class_level_new($class_level_data){
		if ($class_level_data=="p1") {
			$class_level="ป.1";
		}elseif($class_level_data=="p2"){
			$class_level="ป.2";	
		}elseif($class_level_data=="p3"){
			$class_level="ป.3";	
		}elseif($class_level_data=="p4"){
			$class_level="ป.4";	
		}elseif($class_level_data=="p5"){
			$class_level="ป.5";	
		}elseif($class_level_data=="p6"){
			$class_level="ป.6";	
		}elseif($class_level_data=="m1"){
			$class_level="ม.1";	
		}elseif($class_level_data=="m2"){
			$class_level="ม.2";	
		}elseif($class_level_data=="m3"){
			$class_level="ม.3";	
		}elseif($class_level_data=="m4"){
			$class_level="ม.4";	
		}elseif($class_level_data=="m5"){
			$class_level="ม.5";	
		}elseif($class_level_data=="m6"){
			$class_level="ม.6";	
		}
		return $class_level;
	}
}<file_sep>/modules/regis_student/process.php
<?php
@ob_start();
@session_start();

require_once('../../init.php');
include('../../src/class.pagination.php');
include('../../src/class.inputfilter.php');
$InputFilter = new InputFilter();

##CLASS_DB_CONNECT##
include('class_modules.php');
$class_data = new ClassData();
##CLASS_DB_CONNECT##

if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_term_year_now"){
	echo $class_data->get_term_year_now();
}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "chk_id"){
	$std_ID=$_GET['std_ID'];
	$card_ID=$_GET['card_ID'];
	echo $class_data->chk_id($std_ID,$card_ID);
}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_years"){
	echo $class_data->get_years();
}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_day"){
	$mouth=$_GET['mouth'];
	echo $class_data->get_day($mouth);
}
if(isset($_POST['acc_action']) and $_POST['acc_action'] == "save_data"){
	$arr_sql = array();
	$arr_sql_class_room = array();
		$year_main=$_POST['year_main'];
		$day=$_POST['day'];
		$mouth=$_POST['mouth'];
		$years=$_POST['years']-543;
		$password="<PASSWORD>";
		$birthday=$years.'-'.$mouth.'-'.$day;
			$arr_sql["std_ID"]="'".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['std_ID'])))."'";		
			$arr_sql["card_ID"]="'".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['card_ID'])))."'";	
			$arr_sql["password"]= "'".MD5($password)."'";
			
			$arr_sql_class_room["std_ID"]="'".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['std_ID'])))."'";	
			$arr_sql_class_room["class_level"]="'".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['class_level'])))."'";
			$arr_sql_class_room["room"]="'".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['room'])))."'";
			$arr_sql_class_room["year"]="'".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['year_main'])))."'";
			$arr_sql_class_room["status"]=1;

			$arr_sql["name_title"]="'".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['name_title'])))."'";	
			$arr_sql["fname"]="'".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['fname'])))."'";
			$arr_sql["lname"]="'".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['lname'])))."'";
			$arr_sql["birthday"]="'".chkhtmlspecialchars($InputFilter->clean_script(trim($birthday)))."'";
			$arr_sql["blood_group"]="'".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['blood_group'])))."'";
			$arr_sql["address"]="'".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['address'])))."'";
			$arr_sql["parent_name_title"]="'".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['parent_name_title'])))."'";
			$arr_sql["parent_fname"]="'".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['parent_fname'])))."'";
			$arr_sql["parent_lname"]="'".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['parent_lname'])))."'";
			$arr_sql["tell"]="'".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['tell'])))."'";	
			$arr_sql["parent_address"]="'".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['parent_address'])))."'";			
	
			$arr_sql["cdate"]="now()"; 		

		if ($class_data->insert_data($arr_sql,$arr_sql_class_room)) {
			echo "Y";
		}else{
			echo "N";
		}
}<file_sep>/modules/save_score/back/test.php
<?php

public function get_std_exam($coures_id_list_val,$course_teachingID,$room_search){
		$this->sql ="SELECT  *
					FROM tbl_set_term_year 			
							";
		$this->select();
		$this->setRows();
		$term_set=$this->rows[0]['term'];
		$year_set=$this->rows[0]['year'];
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 	
					WHERE DataID=$coures_id_list_val					
					";
		$this->select();
		$this->setRows();
		$class_level=$this->rows[0]['class_level'];
		if ($class_level=='p1' || $class_level=='p2' || $class_level=='p3' || $class_level=='p4' || $class_level=='p5' || $class_level=='p6') {
			$term_set='1,2';
		}
		$this->sql ="SELECT  COUNT(*) as num_row_std
					FROM tbl_student 	
					WHERE room='$room_search'
					AND std_ID in(
						SELECT stdID
					    FROM tbl_course_teaching_std
					    WHERE registed_courseID IN(
					    	SELECT DataID
					        FROM tbl_registed_course
					        WHERE courseID=$coures_id_list_val
					        AND term='$term_set'
					        AND year='$year_set'
					    )
					)

					";
		$this->select();
		$this->setRows();
		$num_row_std=$this->rows[0]['num_row_std'];
		$this->sql ="SELECT  *
					FROM tbl_student 	
					WHERE room='$room_search'
					AND std_ID in(
						SELECT stdID
					    FROM tbl_course_teaching_std
					    WHERE registed_courseID IN(
					    	SELECT DataID
					        FROM tbl_registed_course
					        WHERE courseID=$coures_id_list_val
					        AND term='$term_set'
					        AND year='$year_set'

					    )
					)
					";
		$this->select();
		$this->setRows();
		$num_set=1;
		foreach($this->rows as $key => $value) {
			$std_ID=$value['std_ID'];
			$name_title_data=$value['name_title'];
			$name_title=$this->get_name_title($name_title_data);
			$score_mid_exam=$this->get_score_mid_exam($std_ID,$course_teachingID);
			$score_final_exam=$this->get_score_final_exam($std_ID,$course_teachingID);
			$score_total=$score_mid_exam+$score_final_exam;
			$fname=$value['fname'];
			$lname=$value['lname'];
			if ($num_row_std==$num_set) {
				$std_id_all_exam.=$std_ID;
			}else{
				$std_id_all_exam.=$std_ID.'-';
			}
			$data_response.='							
						 		<tr>
                                  	<td>1</td>
                                  	<td>'.$name_title.$fname.' '.$lname.'</td>
                                 	 <td class="relative "><input name="score_mid_exam[]" disabled="disabled" class="select-table-form value_score_mid class_col_set_new_edit class_col_exam_mid text-center" type="text"  value="'.$score_mid_exam.'"></td>
                                 	  <td class="relative"><input name="score_final_exam[]" disabled="disabled" class="select-table-form value_score_final class_col_set_new_edit class_col_exam_final text-center" type="text"  value="'.$score_final_exam.'"></td>
                                  	<td>'.$score_total.'</td>                
                                </tr>
			';
			$num_set++;
		}
		$data_response.='<input id="std_id_all_exam" type="text" hidden="hidden" value="'.$std_id_all_exam.'" name="">';
		return $data_response;
	}<file_sep>/modules/conclusion/class_modules/learning_result_desirable.php
<?php 
class ClassData extends Databases {
	
	public function get_loop_data($class_level,$year,$term){
		$this->sql ="SELECT DISTINCT(department) AS department,courseID
						FROM tbl_sub_pp6
						WHERE status=1
						AND pp6_ID in(
							SELECT DataID
							FROM tbl_pp6
							WHERE class_level='$class_level'
							AND term='$term'
							AND year='$year'
							
						)
						ORDER BY pp6_ID ASC
							";
			$this->select();
			$this->setRows();
			$order=1;
			$amount_std_all=0;
			$amount_data_desirable_verygood=0;
			$amount_data_desirable_good=0;
			$amount_data_desirable_pass=0;
			$amount_data_desirable_nopass=0;
			foreach($this->rows as $key => $value) {
				$department_set=$value['department'];
				$courseID=$value['courseID'];
				$department=$this->get_department($department_set);
				$amount_std=$this->get_amount_std($department_set,$class_level,$year,$term);
				$desirable=$this->get_desirable($department_set,$class_level,$year,$term);	

				$data_response.='
					<tr>
						<td>'.$order.'</td>
						<td>'.$courseID.'</td>
						<td style="text-align:left;padding-left:15px;">'.$department.'</td>
						<td>'.$amount_std.'</td>
						<td>'.$desirable['data_desirable_verygood'].'</td>
						<td>'.$desirable['data_desirable_good'].'</td>
						<td>'.$desirable['data_desirable_pass'].'</td>
						<td>'.$desirable['data_desirable_nopass'].'</td>
						<td></td>
					</tr>
				';
				$amount_std_all=$amount_std_all+$amount_std;
				$amount_data_desirable_verygood=$amount_data_desirable_verygood+$desirable['data_desirable_verygood'];
				$amount_data_desirable_good=$amount_data_desirable_good+$desirable['data_desirable_good'];
				$amount_data_desirable_pass=$amount_data_desirable_pass+$desirable['data_desirable_pass'];
				$amount_data_desirable_nopass=$amount_data_desirable_nopass+$desirable['data_desirable_nopass'];
			}
			$data_response.='
					<tr class="text-middle">
		            	<td colspan="3"  style="width: 5%;height: 0px;text-align: center;">
		                	รวม
		              	</td>
		            	<td>'.$amount_std_all.'</td>
		              	<td>'.$amount_data_desirable_verygood.'</td>  	
		              	<td>'.$amount_data_desirable_good.'</td>
		              	<td>'.$amount_data_desirable_pass.'</td>
		              	<td>'.$amount_data_desirable_nopass.'</td>
		              	<td></td>
		            </tr>
		            <tr class="text-middle">
		            	<td colspan="3"  style="width: 5%;height: 0px;text-align: center;">
		                	ร้อยละ
		              	</td>
		            	<td>100.00</td>
		              	<td>'.number_format(($amount_data_desirable_verygood*100)/$amount_std_all,2).'</td>  	
		              	<td>'.number_format(($amount_data_desirable_good*100)/$amount_std_all,2).'</td>
		              	<td>'.number_format(($amount_data_desirable_pass*100)/$amount_std_all,2).'</td>
		              	<td>'.number_format(($amount_data_desirable_nopass*100)/$amount_std_all,2).'</td>
		              	<td></td>

		            </tr>
		            <tr class="text-middle">
		            	<td colspan="4"  style="width: 5%;height: 0px;text-align: center;">
		                	ภาพรวมคิดเป็นร้อยละ
		              	</td>
		            	<td colspan="4" style="width: 5%;height: 0px;text-align: center;">100.00</td>
		              	<td style="width: 5%;height: 0px;text-align: center;"></td>

		            </tr>
			';


		return $data_response;
	}
	public function get_desirable($department_set,$class_level,$year,$term){
		$this->sql ="SELECT *
						FROM tbl_sub_pp6
						WHERE status=1
						AND department=$department_set
						AND pp6_ID in(
							SELECT DataID
							FROM tbl_pp6
							WHERE class_level='$class_level'
							AND term='$term'
							AND year='$year'
							
						)
							";
			$this->select();
			$this->setRows();
			$data_desirable_nopass=0;
			$data_desirable_pass=0;
			$data_desirable_good=0;
			$data_desirable_verygood=0;
			foreach($this->rows as $key => $value) {
				$score_desirable=$value['score_desirable'];
				if ($score_desirable<1) {
					$data_desirable_nopass++;
				}elseif($score_desirable<1.5){
					$data_desirable_pass++;
				}elseif($score_desirable<2.5){
					$data_desirable_good++;
				}elseif($score_desirable>=2.5){
					$data_desirable_verygood++;
				}

			}
			$data_response['data_desirable_nopass']=$data_desirable_nopass;
			$data_response['data_desirable_pass']=$data_desirable_pass;
			$data_response['data_desirable_good']=$data_desirable_good;
			$data_response['data_desirable_verygood']=$data_desirable_verygood;
	
			return $data_response;
		}
		public function get_amount_std($department_set,$class_level,$year,$term){
		$this->sql ="SELECT COUNT(*) as num_row
						FROM tbl_sub_pp6
						WHERE status=1
						AND department=$department_set
						AND pp6_ID in(
							SELECT DataID
							FROM tbl_pp6
							WHERE class_level='$class_level'
							AND term='$term'
							AND year='$year'
							
						)
							";
			$this->select();
			$this->setRows();
			return $this->rows[0]['num_row'];
		}
	public function get_desirable_data($class_level,$year,$term,$image_logo,$footer_text_cen_normal){
		if ($class_level=='p1' || $class_level=='p2' || $class_level=='p3' || $class_level=='p4' || $class_level=='p5' || $class_level=='p6') {
				$class_front_text='ประถมศึกษาปีที่';
			}else{
				$class_front_text='มัธยมศึกษาปีที่';
			}
		$loop_data=$this->get_loop_data($class_level,$year,$term);
		$data_response['std_list'].='
						<div style="page-break-after:always;">
					      <page >
					        <div style="text-align: center;line-height: 0.6;font-weight: bold;padding-top: 20px;font-size:16px">
					          <img class="logo-print-size-level" src="'.$image_logo.'">
					          <p >รายงานการพัฒนาคุณลักษณะอันพึงประสงค์ตามระดับชั้น</p>
					          <p >โรงเรียนเทศบาลวัดสระทอง สังกัดเทศบาลเมืองร้อยเอ็ด อ.เมือง จ.ร้อยเอ็ด</p>
					          <p>
					            <span style="margin-right: 20px;">ระดับชั้น 
					              <span style="font-weight: normal;">'.$class_front_text.' '.substr($class_level,1).'</span>
					            </span> 
					           
					            <span style="margin-right: 20px;">ภาคเรียนที่ 
						              <span style="font-weight: normal;">'.$term.'</span>
						            </span> 
					            <span>ปีการศึกษา <span style="font-weight: normal;">'.$year.'</span> </span>
					          </p>
					         
					        </div>
					        <table cellspacing="0"  style=" text-align: center; font-size: 14px;width:100%;margin-top: 20px;">
					          <thead>
					            <tr class="text-middle">
					              <th rowspan="2" class="rotate" style="width: 3%;height: 0px;text-align: center;">
					                <div >ที่</div>
					              </th>
					              <th rowspan="2" class="rotate" style="width: 10%;height: 0px;text-align: center;">
					                <div >รหัสวิชา</div>
					              </th>
					              <th rowspan="2" style="width: 25%;vertical-align: middle;text-align: center;">
					              	สาระการเรียนรู้
					              </th>
					              <th rowspan="2" class="rotate" style="width: 5%;height: 0px;text-align: center;">
					                <div >จำนวนนักเรียน</div>
					              </th>
					              <th colspan="4" class="rotate" style="width: 5%;height: 0px;text-align: center;">
					                <div >ระดับคุณภาพ</div>
					              </th>
					              <th rowspan="2" class="rotate" style="width: 5%;height: 0px;text-align: center;">
					                <div >หมายเหตุ</div>
					              </th>
					            </tr> 
					            <tr class="text-middle">
					            	<th  class="rotate" style="width: 5%;height: 0px;text-align: center;">
					                	ดีเยี่ยม
					                	<br>
					                	(3)
					              	</th>
					            	<th  class="rotate" style="width: 5%;height: 0px;text-align: center;">
					                	ดี
					                	<br>
					                	(2)
					              	</th>
					              	<th  class="rotate" style="width: 5%;height: 0px;text-align: center;">
					                	ผ่าน
					                	<br>
					                	(1)
					              	</th>
					              	<th  class="rotate" style="width: 5%;height: 0px;text-align: center;">
					                	ไม่ผ่าน
					                	<br>
					                	(0)
					              	</th>
					            </tr>
					          </thead>
					          <tbody >
					            '.$loop_data.'
					          </tbody>
					        </table>
					        <div style="margin-top:40px;">
					        	'.$footer_text_cen_normal.'
					        </div>
					      </page>
					    </div>
					   
			';
		return $data_response;
	}
	
	public function get_year(){
		$this->sql ="SELECT  distinct(year) as year
					FROM tbl_registed_course
					ORDER BY year DESC
							";
		$this->select();
		$this->setRows();
		foreach($this->rows as $key => $value) {
			$year=  $value['year'];	
			$data_response.='
					 <option value="'.$year.'">'.$year.'</option>
			';
		}
		return json_encode($data_response);
	}
	public function get_name_title($name_title_data){
		if ($name_title_data=="dekchai") {
			$name_title="เด็กชาย";
		}elseif($name_title_data=="dekying"){
			$name_title="เด็กหญิง";
		}elseif($name_title_data=="nai"){
			$name_title="นาย";
		}else{
			$name_title="นางสาว";
		}
		return $name_title;
	}
	public function get_class_level($class_level_data){
		if ($class_level_data=="p1") {
			$class_level="ป.1";
		}elseif($class_level_data=="p2"){
			$class_level="ป.2";	
		}elseif($class_level_data=="p3"){
			$class_level="ป.3";	
		}elseif($class_level_data=="p4"){
			$class_level="ป.4";	
		}elseif($class_level_data=="p5"){
			$class_level="ป.5";	
		}elseif($class_level_data=="p6"){
			$class_level="ป.6";	
		}elseif($class_level_data=="m1"){
			$class_level="ม.1";	
		}elseif($class_level_data=="m2"){
			$class_level="ม.2";	
		}elseif($class_level_data=="m3"){
			$class_level="ม.3";	
		}elseif($class_level_data=="m4"){
			$class_level="ม.4";	
		}elseif($class_level_data=="m5"){
			$class_level="ม.5";	
		}elseif($class_level_data=="m6"){
			$class_level="ม.6";	
		}
		return $class_level;
	}
	public function get_department($data){
		
		switch ($data) {
		    case 1:
		       	$department='ภาษาไทย';
		        break;
		    case 2:
		        $department='คณิตศาสตร์';
		        break;
		    case 3:
		        $department='วิทยาศาสตร์';
		        break;
		    case 31:
		        $department='วิทยาศาสตร์และเทคโนโลยี';
		        break;    
		    case 4:
		        $department='สังคมศึกษา ศาสนาและวัฒนธรรม';
		        break;
		    case 41:
		        $department='สังคมศึกษา';
		        break;
		    case 42:
		        $department='ภูมิศาสตร์';
		        break;
		    case 43:
		        $department='ประวัติศาสตร์';
		        break;
		    case 5:
		        $department='สุขศึกษาและพลศึกษา';
		        break;
		    case 6:
		        $department='ศิลปะ';
		        break;
		    case 7:
		        $department='การงานอาชีพฯ';
		        break; 
		    case 71:
		        $department='การงานอาชีพ';
		        break; 
		    case 8:
		        $department='ภาษาต่างประเทศ';
		        break;  
		    case 9:
		        $department='หน้าที่พลเมือง';
		        break;     
		    case 10:
		        $department='ศิลปะพื้นบ้าน';
		        break;     
		    case 11:
		        $department='ศักยภาพ';
		        break;     
		    case 12:
		        $department='ภาษาจีน';
		        break;        
		    default:
		     	$department='';
		}
		return $department;
	}
	public function get_grade($total){
		if ($total<50) {
			$grade='0.0';
		}elseif($total<55){
			$grade='1.0';
		}elseif($total<60){
			$grade='1.5';
		}elseif($total<65){
			$grade='2.0';
		}elseif($total<70){
			$grade='2.5';
		}elseif($total<75){
			$grade='3.0';
		}elseif($total<80){
			$grade='3.5';
		}elseif($total>=80){
			$grade='4.0';
		}
		return $grade;
	}
}<file_sep>/modules/save_score/back/class_modules.php
<?php 

class ClassData extends Databases {
	
	public function get_end_data_find($start_data,$end_data){
		$end_data_last=$end_data+1;
		return $end_data_last-$start_data;
	}
	public function set_col_header($length_list_val){
		$data_response = array();	
		list($start_data,$end_data) = split('[-]', $length_list_val);
		$data_response['end_data_find']=$this->get_end_data_find($start_data,$end_data);
		return json_encode($data_response);
	}
	public function get_score_col_total($std_ID,$registed_courseID){
		$num_of_i=0;
		$this->sql ="SELECT  count(score) as num_of_i
					FROM tbl_objective_score_std 	
					WHERE staID='$std_ID'
					AND registed_courseID=$registed_courseID
					AND score=-1;
					";
			$this->select();
			$this->setRows();	
			$num_of_i=$this->rows[0]['num_of_i'];
		$this->sql ="SELECT  SUM(score) as score_total
					FROM tbl_objective_score_std 	
					WHERE staID='$std_ID'
					AND registed_courseID=$registed_courseID
					";
			$this->select();
			$this->setRows();	
			$score_total_data=$this->rows[0]['score_total'];
			if ($score_total_data==0) {
				$score_total=0;	
			}else{
				$score_total=$score_total_data;	
			}
			return $score_total+$num_of_i;
	}
	public function get_total_proportion($data_id){
		$data_response = array();	
		$this->sql ="SELECT  *
					FROM tbl_proportion 	
					WHERE courseID=$data_id				
					";
			$this->select();
			$this->setRows();	
			$data_response['mid_exam'] =$this->rows[0]['mid_exam'];	
			$data_response['final_exam'] =$this->rows[0]['final_exam'];
			return $data_response;
	}
	public function get_total_ob_conclude($data_objective_ob){
		$this->sql ="SELECT  score
					FROM tbl_objective_conclude 	
					WHERE DataID=$data_objective_ob					
					";
			$this->select();
			$this->setRows();	
			return $this->rows[0]['score'];	
	}

	public function get_score_col($std_ID,$data_objective,$registed_courseID,$start_data){
		$arr_id = explode("-", $data_objective);	
		for ($i=0; $i < count($arr_id) ; $i++) { 
			if ($arr_id[$i]=='') {
				$arr_id[$i]=0;
			}else{
				$arr_id[$i]=$arr_id[$i];
			}
			$total_ob_conclude=$this->get_total_ob_conclude($arr_id[$i]);
			$this->sql ="SELECT  *
					FROM tbl_objective_score_std 	
					WHERE staID='$std_ID'
					AND objectiveID={$arr_id[$i]}
					AND registed_courseID=$registed_courseID
					";
			$this->select();
			$this->setRows();	
			$DataID=$this->rows[0]['DataID'];	
			$score=$this->rows[0]['score'];	
			if ($score=='' || $score==0) {
				$score=0;
			}else{
				if ($score==-1) {
					$score='ร';
				}else{
					$score=$score;
				}				
			}
			$data_response.='<td class="relative" ><input  onkeyup="chk_score_over(this,this.value)" class_name_change="'.$DataID.'" value_set="'.$score.'" data_main_chk_over="'.$total_ob_conclude.'" name="objective_score_std[]" disabled="disabled" class="select-table-form class_col_set_new class_name_'.$DataID.' class_col_'.$start_data.'" type="text"  value="'.$score.'"></td>';
			$start_data++;
		}
		return $data_response;
	}	
	public function get_detail_std($coures_id_list_val,$registed_courseID,$data_objective,$start_data,$room_search){
		$this->sql ="SELECT  *
					FROM tbl_set_term_year 			
							";
		$this->select();
		$this->setRows();
		$term_set=$this->rows[0]['term'];
		$year_set=$this->rows[0]['year'];	



		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 	
					WHERE DataID=$coures_id_list_val					
					";
		$this->select();
		$this->setRows();
		$class_level=$this->rows[0]['class_level'];
		if ($class_level=='p1' || $class_level=='p2' || $class_level=='p3' || $class_level=='p4' || $class_level=='p5' || $class_level=='p6') {
			$term_set='1,2';
		}
		$this->sql ="SELECT  *
					FROM tbl_student 	
					WHERE room='$room_search'
					AND std_ID in(
						SELECT stdID
					    FROM tbl_course_teaching_std
					    WHERE registed_courseID IN(
					    	SELECT DataID
					        FROM tbl_registed_course
					        WHERE courseID=$coures_id_list_val
					        AND term='$term_set'
					        AND year='$year_set'
					    )
					)
					";
		$this->select();
		$this->setRows();		
		$no_std=1;
		foreach($this->rows as $key => $value) {
			$std_ID=$value['std_ID'];
			$fname=$value['fname'];
			$lname=$value['lname'];
			$name_title_data=$value['name_title'];
			$name_title=$this->get_name_title($name_title_data);
			$class_level_status=$this->get_class_level_status($coures_id_list_val);
			$score_col=$this->get_score_col($std_ID,$data_objective,$registed_courseID,$start_data);
			$score_col_total=$this->get_score_col_total($std_ID,$registed_courseID);
			$data_response.='<tr>
										<td>'.$no_std.'</td>
						                  <td style="text-align:left;padding-left:4%;">'.$name_title.$fname.' '.$lname.'</td>
						                  '.$score_col.'
						                 <td>'.$score_col_total.'</td>
						             </tr>
			';
					
			$no_std++;
			
		}
		return $data_response;
	}
	public function get_class_level_status($coures_id_list_val){
		$data_response = array();	
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 	
					WHERE DataID=$coures_id_list_val
					";
		$this->select();
		$this->setRows();		
		$class_level=$this->rows[0]['class_level'];	
		if ($class_level=='p1' || $class_level=='p2' || $class_level=='p3' || $class_level=='p4' || $class_level=='p5' || $class_level=='p6') {
			$data='p';
		}else{
			$data='m';
		}
		return $data;
	}
	public function get_std_id_all($coures_id_list_val,$room_search){
		$this->sql ="SELECT  *
					FROM tbl_set_term_year 			
							";
		$this->select();
		$this->setRows();
		$term_set=$this->rows[0]['term'];
		$year_set=$this->rows[0]['year'];	
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 	
					WHERE DataID=$coures_id_list_val					
					";
		$this->select();
		$this->setRows();
		$class_level=$this->rows[0]['class_level'];
		if ($class_level=='p1' || $class_level=='p2' || $class_level=='p3' || $class_level=='p4' || $class_level=='p5' || $class_level=='p6') {
			$term_set='1,2';
		}

		$this->sql ="SELECT  count(*) as num_row_std
					FROM tbl_student 
					WHERE room='$room_search'
					AND std_ID in(
						SELECT stdID
						FROM tbl_course_teaching_std
						WHERE registed_courseID in(
							SELECT DataID
							FROM tbl_registed_course
							WHERE courseID=$coures_id_list_val
							AND term='$term_set'
					        AND year='$year_set'
						)
					)
					";
		$this->select();
		$this->setRows();
		$num_row_std=$this->rows[0]['num_row_std'];			
		$this->sql ="SELECT  *
					FROM tbl_student 
					WHERE room='$room_search'
					AND std_ID in(
						SELECT stdID
						FROM tbl_course_teaching_std
						WHERE registed_courseID in(
							SELECT DataID
							FROM tbl_registed_course
							WHERE courseID=$coures_id_list_val
							AND term='$term_set'
					        AND year='$year_set'
						)
					)
					";
		$this->select();
		$this->setRows();		
		$no_std=1;
		foreach($this->rows as $key => $value) {
			$std_ID=$value['std_ID'];		
			if ($num_row_std==$no_std) {
				$std_id_all.=$std_ID;
			}else{
				$std_id_all.=$std_ID.'-';
			}
			
			$no_std++;
			
		}
		$data_response=$std_id_all;
		return $data_response;
	}

	public function get_proportion_cumulative($coures_id_list_val){
		$this->sql ="SELECT  SUM(cumulative_before_mid + cumulative_after_mid) as cumulative_sum
					FROM tbl_proportion 	
					WHERE courseID=$coures_id_list_val
					";
		$this->select();
		$this->setRows();	
		return $this->rows[0]['cumulative_sum'];
	}
	public function get_objective_list($coures_id_list_val,$length_list_val,$room_search){
		$data_response = array();		
		//$data_response['proportion_cumulative']=$this->get_proportion_cumulative($coures_id_list_val);
		list($start_data, $end_data) = split('[-]', $length_list_val);
		$find_start=$start_data-1;
		$find_end=$end_data-$find_start;
		$this->sql ="SELECT  *
					FROM tbl_objective_conclude 	
					WHERE courseID=$coures_id_list_val
					LIMIT $find_start,$find_end
					";
		$this->select();
		$this->setRows();	
		$chk_loop=1;	
		foreach($this->rows as $key => $value) {
			$DataID=$value['DataID'];
			$no_order=$value['no_order'];
			$score=$value['score'];
			$data_response['objective_list'].=' <option value="'.$no_order.'">ข้อที่ '.$no_order.'</option>';
			$data_response['ob_title_table_col'].='<td>'.$no_order.'</td>';		
			$data_response['ob_score_max_table_col'].='<td>'.$score.'</td>';	

			if ($find_end==$chk_loop) {
				$data_objective.=$DataID; 
			}else{
				$data_objective.=$DataID.'-'; 
			}
			
			$chk_loop++;
		}
		$data_response['ob_score_max_table_col'].='<td style="background-color:#f3e7f9;">'.$this->get_proportion_cumulative($coures_id_list_val).'</td>';
		$registed_courseID=$this->get_registed_courseID($coures_id_list_val);
		$data_response['registed_courseID']=$registed_courseID;
		$data_response['detail_std']=$this->get_detail_std($coures_id_list_val,$registed_courseID,$data_objective,$start_data,$room_search);	
		$data_response['std_id_all']=$this->get_std_id_all($coures_id_list_val,$room_search);
		$data_response['data_objectiveID_of_title']=$data_objective;
		return json_encode($data_response);
	}

	public function get_registed_courseID($coures_id_list_val){
		$this->sql ="SELECT  *
					FROM tbl_set_term_year 			
							";
		$this->select();
		$this->setRows();
		$term_set=$this->rows[0]['term'];
		$year_set=$this->rows[0]['year'];	



		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 	
					WHERE DataID=$coures_id_list_val					
					";
		$this->select();
		$this->setRows();
		$class_level=$this->rows[0]['class_level'];
		if ($class_level=='p1' || $class_level=='p2' || $class_level=='p3' || $class_level=='p4' || $class_level=='p5' || $class_level=='p6') {
			$term_set='1,2';
		}
		$this->sql ="SELECT  *
					FROM tbl_registed_course 	
					WHERE courseID=$coures_id_list_val
					AND term='$term_set'	
					AND year='$year_set'				
					";
		$this->select();
		$this->setRows();
		return $this->rows[0]['DataID'];
	}
	public function get_config($legth_score,$coures_id_list_val,$room_search){
		$data_response = array();	
		if ($legth_score=="save-score-pick") {
			$data_response=$this->get_pick($coures_id_list_val);
		}elseif($legth_score=="save-score-exam"){
			$data_response=$this->get_exam($coures_id_list_val,$room_search);
		}elseif($legth_score=="save-score-desirable"){
			$data_response=$this->get_desirable($coures_id_list_val,$room_search);
		}elseif($legth_score=="save-score-read"){
			$data_response=$this->get_read($coures_id_list_val,$room_search);
		}
		return json_encode($data_response);
	}

	public function get_selected($num_loop_class){
		if (isset($_SESSION['status_active'])) {
			$active_length=$_SESSION['status_active'];
			$text='chk_active_'.$num_loop_class;
			if($active_length==$text){
				return "selected";
			}
		}
		
	}
	public function search_course_detail($coures_id_list,$room_search){
		$data_response = array();	
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 	
					WHERE DataID=$coures_id_list
					";
		$this->select();
		$this->setRows();		
		$data_response['courseID']=$this->rows[0]['courseID'];	
		$data_response['name']=$this->rows[0]['name'];	
		$data_response['unit']=$this->rows[0]['unit'];	
		$data_response['hr_learn']=$this->rows[0]['hr_learn'];	
		$data_response['status']=$this->rows[0]['status'];	
		$class_level_data=$this->rows[0]['class_level'];
		$class_level=$this->get_class_level_new($class_level_data);
		$data_response['class_level_co']=$class_level.'/'.$room_search;

		return json_encode($data_response);
	}
	public function get_class_level($coures_id_list_val){
		$this->sql ="SELECT  *
					FROM tbl_set_term_year 			
							";
		$this->select();
		$this->setRows();
		$term_set=$this->rows[0]['term'];
		$year_set=$this->rows[0]['year'];
		$data_response = array();	
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 	
					WHERE DataID=$coures_id_list_val
					AND DataID in(
                    	SELECT courseID
                        FROM tbl_registed_course 
                        WHERE term='$term_set'  
                        OR term='1,2'
                        AND year='$year_set'
                         AND DataID IN(
                            SELECT registed_courseID
                        	FROM tbl_registed_course_teaching
                        )
                    )
					";
		$this->select();
		$this->setRows();
		$class_level_data=$this->rows[0]['class_level'];	
		
		$data_response['class_level']=$this->get_class_level_new($class_level_data);
		if ($class_level_data=='p1' || $class_level_data=='p2' || $class_level_data=='p3' || $class_level_data=='p4' || $class_level_data=='p5' || $class_level_data=='p6' ) {
			$term_set='1,2';
		}
		$this->sql ="SELECT distinct room
						FROM tbl_student 
						WHERE std_ID in(
							SELECT stdID
							FROM tbl_course_teaching_std
							WHERE registed_courseID in(
								SELECT DataID
								FROM tbl_registed_course
								WHERE courseID=$coures_id_list_val
                                AND term='$term_set'
                                AND year='$year_set'
								)
						)
						ORDER BY room ASC
							";
			$this->select();
			$this->setRows();
			foreach($this->rows as $key => $value) {
				$room=$value['room'];
				$data_response['room'].=' <option>'.$room.'</option>';
			}

		return json_encode($data_response);
	}
	public function get_coures_id_list(){
		$data_response = array();	
		$this->sql ="SELECT  *
					FROM tbl_set_term_year 			
							";
		$this->select();
		$this->setRows();
		$term_set=$this->rows[0]['term'];
		$year_set=$this->rows[0]['year'];
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 		
                    WHERE DataID in(
                    	SELECT courseID
                        FROM tbl_registed_course
                        WHERE term='$term_set'                   
                        AND DataID IN(
                        	SELECT registed_courseID
                            FROM tbl_registed_course_teaching
                        )
                    )
					ORDER BY courseID ASC	
							";
		$this->select();
		$this->setRows();
		foreach($this->rows as $key => $value) {
			$DataID=$value['DataID'];
			
			$courseID_long=$value['courseID'];
			$data_response['coures_id_list'].='
							<option value="'.$DataID.'">'.$courseID_long.'</option>
			';
		}
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 		
                    WHERE DataID in(
                    	SELECT courseID
                        FROM tbl_registed_course
                        WHERE term='1,2'
                        AND DataID IN(
                        	SELECT registed_courseID
                            FROM tbl_registed_course_teaching
                        )
                    )
					ORDER BY courseID ASC	
							";
		$this->select();
		$this->setRows();
		foreach($this->rows as $key => $value) {
			$DataID=$value['DataID'];
			$courseID_long=$value['courseID'];
			$data_response['coures_id_list'].='
							<option value="'.$DataID.'">'.$courseID_long.'</option>
			';
		}
		return json_encode($data_response);
	}
	public function get_course_teachingID($DataID,$term_set,$year_set){
		$this->sql ="SELECT  *
					FROM tbl_registed_course_teaching 			
					WHERE registed_courseID in(
						SELECT DataID
						FROM tbl_registed_course
						WHERE courseID=$DataID
						AND term='$term_set'
						AND year='$year_set'
					)
							";
		$this->select();
		$this->setRows();
		return $this->rows[0]['DataID'];	
	}
	public function get_class_level_new($class_level_data){
		if ($class_level_data=="p1") {
			$class_level="ป.1";
		}elseif($class_level_data=="p2"){
			$class_level="ป.2";	
		}elseif($class_level_data=="p3"){
			$class_level="ป.3";	
		}elseif($class_level_data=="p4"){
			$class_level="ป.4";	
		}elseif($class_level_data=="p5"){
			$class_level="ป.5";	
		}elseif($class_level_data=="p6"){
			$class_level="ป.6";	
		}elseif($class_level_data=="m1"){
			$class_level="ม.1";	
		}elseif($class_level_data=="m2"){
			$class_level="ม.2";	
		}elseif($class_level_data=="m3"){
			$class_level="ม.3";	
		}elseif($class_level_data=="m4"){
			$class_level="ม.4";	
		}elseif($class_level_data=="m5"){
			$class_level="ม.5";	
		}elseif($class_level_data=="m6"){
			$class_level="ม.6";	
		}
		return $class_level;
	}
	public function get_propotion_total($coures_id_list_val){
		$data_response = array();	
		$this->sql ="SELECT  *
					FROM tbl_proportion 			
					WHERE courseID=$coures_id_list_val";
		$this->select();
		$this->setRows();
		$data_response['mid_exam']=$this->rows[0]['mid_exam'];
		$data_response['final_exam']=$this->rows[0]['final_exam'];
		$mid_exam=$this->rows[0]['mid_exam'];
		$final_exam=$this->rows[0]['final_exam'];
		$data_response['total']=$mid_exam+$final_exam;
		return $data_response;
	}
	public function get_std_exam($coures_id_list_val,$course_teachingID,$room_search){
		$total_total_proportion=$this->get_total_proportion($coures_id_list_val);
		$this->sql ="SELECT  *
					FROM tbl_set_term_year 			
							";
		$this->select();
		$this->setRows();
		$term_set=$this->rows[0]['term'];
		$year_set=$this->rows[0]['year'];
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 	
					WHERE DataID=$coures_id_list_val					
					";
		$this->select();
		$this->setRows();
		
		$class_level=$this->rows[0]['class_level'];
		if ($class_level=='p1' || $class_level=='p2' || $class_level=='p3' || $class_level=='p4' || $class_level=='p5' || $class_level=='p6') {
			$term_set='1,2';
		}
		$this->sql ="SELECT  COUNT(*) as num_row_std
					FROM tbl_student 	
					WHERE room='$room_search'
					AND std_ID in(
						SELECT stdID
					    FROM tbl_course_teaching_std
					    WHERE registed_courseID IN(
					    	SELECT DataID
					        FROM tbl_registed_course
					        WHERE courseID=$coures_id_list_val
					        AND term='$term_set'
					        AND year='$year_set'
					    )
					)

					";
		$this->select();
		$this->setRows();
		$num_row_std=$this->rows[0]['num_row_std'];
		$this->sql ="SELECT  *
					FROM tbl_student 	
					WHERE room='$room_search'
					AND std_ID in(
						SELECT stdID
					    FROM tbl_course_teaching_std
					    WHERE registed_courseID IN(
					    	SELECT DataID
					        FROM tbl_registed_course
					        WHERE courseID=$coures_id_list_val
					        AND term='$term_set'
					        AND year='$year_set'

					    )
					)
					";
		$this->select();
		$this->setRows();
		$num_set=1;
		foreach($this->rows as $key => $value) {
			$std_ID=$value['std_ID'];
			$name_title_data=$value['name_title'];
			$name_title=$this->get_name_title($name_title_data);
			$score_mid_exam=$this->get_score_mid_exam($std_ID,$course_teachingID);
			$score_final_exam=$this->get_score_final_exam($std_ID,$course_teachingID);
			$score_total=$score_mid_exam['score']+$score_final_exam['score'];
			$fname=$value['fname'];
			$lname=$value['lname'];
			if ($num_row_std==$num_set) {
				$std_id_all_exam.=$std_ID;
			}else{
				$std_id_all_exam.=$std_ID.'-';
			}
			$data_response.='							
						 		<tr>
                                  	<td>'.$num_set.'</td>
                                  	<td style="text-align:left;padding-left:10%;">'.$name_title.$fname.' '.$lname.'</td>
                                 	 <td class="relative "><input onkeyup="chk_score_over(this,this.value)" class_name_change="1'.$score_mid_exam['DataID'].'" data_main_chk_over="'.$total_total_proportion['mid_exam'].'" value_set="'.$score_mid_exam['score'].'"   name="score_mid_exam[]" disabled="disabled" class="class_name_1'.$score_mid_exam['DataID'].' select-table-form value_score_mid class_col_set_new_edit class_col_exam_mid text-center" type="text"  value="'.$score_mid_exam['score'].'"></td>
                                 	  <td class="relative"><input onkeyup="chk_score_over(this,this.value)" class_name_change="2'.$score_final_exam['DataID'].'" data_main_chk_over="'.$total_total_proportion['final_exam'].'" value_set="'.$score_final_exam['score'].'"  name="score_final_exam[]" disabled="disabled" class="class_name_2'.$score_final_exam['DataID'].' select-table-form value_score_final class_col_set_new_edit class_col_exam_final text-center" type="text"  value="'.$score_final_exam['score'].'"></td>
                                  	<td>'.$score_total.'</td>                
                                </tr>
			';
			$num_set++;
		}
		$data_response.='<input id="std_id_all_exam" type="text" hidden="hidden" value="'.$std_id_all_exam.'" name="">';
		return $data_response;
	}
	public function get_score_final_exam($std_ID,$course_teachingID){
		$data_response = array();
		$this->sql ="SELECT  *
					FROM tbl_final_exam_score 			
					WHERE course_teachingID=$course_teachingID
					AND stdID='$std_ID'
					";
		$this->select();
		$this->setRows();
		$data_response['DataID']=$this->rows[0]['DataID'];
		$score=$this->rows[0]['score'];
		if ($score=='' || $score==0) {
				$data_response['score']=0;
			}else{
				if ($score==-1) {
					$data_response['score']='ร';
				}else{
					$data_response['score']=$score;
				}				
			}
		return $data_response;
	}
	public function get_score_mid_exam($std_ID,$course_teachingID){
		$data_response = array();
		$this->sql ="SELECT  *
					FROM tbl_mid_exam_score 			
					WHERE course_teachingID=$course_teachingID
					AND stdID='$std_ID'
					";
		$this->select();
		$this->setRows();
		$data_response['DataID']=$this->rows[0]['DataID'];
		$score=$this->rows[0]['score'];
		if ($score=='' || $score==0) {
				$data_response['score']=0;
			}else{
				if ($score==-1) {
					$data_response['score']='ร';
				}else{
					$data_response['score']=$score;
				}				
			}
		return $data_response;
	}
	public function get_name_title($name_title_data){
		if ($name_title_data=="dekchai") {
			$name_title="เด็กชาย";
		}elseif($name_title_data=="dekying"){
			$name_title="เด็กหญิง";
		}elseif($name_title_data=="nai"){
			$name_title="นาย";
		}elseif($name_title_data=="nangsaw"){
			$name_title="นางสาว";
		}
		return $name_title;
	}
	public function get_score_desirable_1($std_ID,$course_teachingID){
		$data_response = array();
		$this->sql ="SELECT  *
					FROM tbl_desirable_1 			
					WHERE course_teachingID=$course_teachingID
					AND stdID='$std_ID'
					";
		$this->select();
		$this->setRows();
		$data_response['DataID']=$this->rows[0]['DataID'];
		$score=$this->rows[0]['score'];
		if ($score=='') {
			$data_response['score']=0;
		}else{
			$data_response['score']=$score;
		}
		return $data_response;
	}
	public function get_score_desirable_2($std_ID,$course_teachingID){
		$data_response = array();
		$this->sql ="SELECT  *
					FROM tbl_desirable_2 			
					WHERE course_teachingID=$course_teachingID
					AND stdID='$std_ID'
					";
		$this->select();
		$this->setRows();
		$data_response['DataID']=$this->rows[0]['DataID'];
		$score=$this->rows[0]['score'];
		if ($score=='') {
			$data_response['score']=0;
		}else{
			$data_response['score']=$score;
		}
		return $data_response;
	}
	public function get_score_desirable_3($std_ID,$course_teachingID){
		$data_response = array();
		$this->sql ="SELECT  *
					FROM tbl_desirable_3 			
					WHERE course_teachingID=$course_teachingID
					AND stdID='$std_ID'
					";
		$this->select();
		$this->setRows();
		$data_response['DataID']=$this->rows[0]['DataID'];
		$score=$this->rows[0]['score'];
		if ($score=='') {
			$data_response['score']=0;
		}else{
			$data_response['score']=$score;
		}
		return $data_response;
	}
	public function get_score_desirable_4($std_ID,$course_teachingID){
		$data_response = array();
		$this->sql ="SELECT  *
					FROM tbl_desirable_4 			
					WHERE course_teachingID=$course_teachingID
					AND stdID='$std_ID'
					";
		$this->select();
		$this->setRows();
		$data_response['DataID']=$this->rows[0]['DataID'];
		$score=$this->rows[0]['score'];
		if ($score=='') {
			$data_response['score']=0;
		}else{
			$data_response['score']=$score;
		}
		return $data_response;
	}
	public function get_score_desirable_5($std_ID,$course_teachingID){
		$data_response = array();
		$this->sql ="SELECT  *
					FROM tbl_desirable_5 			
					WHERE course_teachingID=$course_teachingID
					AND stdID='$std_ID'
					";
		$this->select();
		$this->setRows();
		$data_response['DataID']=$this->rows[0]['DataID'];
		$score=$this->rows[0]['score'];
		if ($score=='') {
			$data_response['score']=0;
		}else{
			$data_response['score']=$score;
		}
		return $data_response;
	}
	public function get_score_desirable_6($std_ID,$course_teachingID){
		$data_response = array();
		$this->sql ="SELECT  *
					FROM tbl_desirable_6 			
					WHERE course_teachingID=$course_teachingID
					AND stdID='$std_ID'
					";
		$this->select();
		$this->setRows();
		$data_response['DataID']=$this->rows[0]['DataID'];
		$score=$this->rows[0]['score'];
		if ($score=='') {
			$data_response['score']=0;
		}else{
			$data_response['score']=$score;
		}
		return $data_response;
	}
	public function get_score_desirable_7($std_ID,$course_teachingID){
		$data_response = array();
		$this->sql ="SELECT  *
					FROM tbl_desirable_7 			
					WHERE course_teachingID=$course_teachingID
					AND stdID='$std_ID'
					";
		$this->select();
		$this->setRows();
		$data_response['DataID']=$this->rows[0]['DataID'];
		$score=$this->rows[0]['score'];
		if ($score=='') {
			$data_response['score']=0;
		}else{
			$data_response['score']=$score;
		}
		return $data_response;
	}
	public function get_score_desirable_8($std_ID,$course_teachingID){
		$data_response = array();
		$this->sql ="SELECT  *
					FROM tbl_desirable_8 			
					WHERE course_teachingID=$course_teachingID
					AND stdID='$std_ID'
					";
		$this->select();
		$this->setRows();
		$data_response['DataID']=$this->rows[0]['DataID'];
		$score=$this->rows[0]['score'];
		if ($score=='') {
			$data_response['score']=0;
		}else{
			$data_response['score']=$score;
		}
		return $data_response;
	}
	public function get_std_desirable($coures_id_list_val,$course_teachingID,$room_search){
		$this->sql ="SELECT  *
					FROM tbl_set_term_year 			
							";
		$this->select();
		$this->setRows();
		$term_set=$this->rows[0]['term'];
		$year_set=$this->rows[0]['year'];
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 	
					WHERE DataID=$coures_id_list_val					
					";
		$this->select();
		$this->setRows();
		$class_level=$this->rows[0]['class_level'];
		if ($class_level=='p1' || $class_level=='p2' || $class_level=='p3' || $class_level=='p4' || $class_level=='p5' || $class_level=='p6') {
			$term_set='1,2';
		}
		$this->sql ="SELECT  COUNT(*) as num_row_std
					FROM tbl_student 	
					WHERE room='$room_search'
					AND std_ID in(
						SELECT stdID
					    FROM tbl_course_teaching_std
					    WHERE registed_courseID IN(
					    	SELECT DataID
					        FROM tbl_registed_course
					        WHERE courseID=$coures_id_list_val
					        AND term='$term_set'
					        AND year='$year_set'
					    )
					)

					";
		$this->select();
		$this->setRows();
		$num_row_std=$this->rows[0]['num_row_std'];
		$this->sql ="SELECT  *
					FROM tbl_student 	
					WHERE room='$room_search'
					AND std_ID in(
						SELECT stdID
					    FROM tbl_course_teaching_std
					    WHERE registed_courseID IN(
					    	SELECT DataID
					        FROM tbl_registed_course
					        WHERE courseID=$coures_id_list_val
					        AND term='$term_set'
					        AND year='$year_set'

					    )
					)
					";
		$this->select();
		$this->setRows();
		$num_set=1;
		foreach($this->rows as $key => $value) {
			$std_ID=$value['std_ID'];
			$name_title_data=$value['name_title'];
			$name_title=$this->get_name_title($name_title_data);
			$score_desirable_1=$this->get_score_desirable_1($std_ID,$course_teachingID);
			$score_desirable_2=$this->get_score_desirable_2($std_ID,$course_teachingID);
			$score_desirable_3=$this->get_score_desirable_3($std_ID,$course_teachingID);
			$score_desirable_4=$this->get_score_desirable_4($std_ID,$course_teachingID);
			$score_desirable_5=$this->get_score_desirable_5($std_ID,$course_teachingID);
			$score_desirable_6=$this->get_score_desirable_6($std_ID,$course_teachingID);
			$score_desirable_7=$this->get_score_desirable_7($std_ID,$course_teachingID);
			$score_desirable_8=$this->get_score_desirable_8($std_ID,$course_teachingID);
			$score_total=round(($score_desirable_1['score']+$score_desirable_2['score']+$score_desirable_3['score']+$score_desirable_4['score']+$score_desirable_5['score']+$score_desirable_6['score']+$score_desirable_7['score']+$score_desirable_8['score'])/8,2);
			$fname=$value['fname'];
			$lname=$value['lname'];
			if ($num_row_std==$num_set) {
				$std_id_all_desirable.=$std_ID;
			}else{
				$std_id_all_desirable.=$std_ID.'-';
			}
			$data_response.='							
						 		<tr>
                                  	<td>'.$num_set.'</td>
                                  	<td style="text-align:left;padding-left:4%;">'.$name_title.$fname.' '.$lname.'</td>
                                 	<td class="relative "><input name="score_final_desirable_1[]" value_set="'.$score_desirable_1['score'].'" onkeyup="chk_score_over_fix(this,this.value)" class_name_change="1'.$score_desirable_1['DataID'].'"   disabled="disabled" class="class_name_1'.$score_desirable_1['DataID'].' select-table-form value_score_desirable_1 class_col_set_new_edit class_col_desirable_1 text-center" type="text"  value="'.$score_desirable_1['score'].'"></td>

                                 	<td class="relative"><input name="score_final_desirable_2[]" value_set="'.$score_desirable_2['score'].'" onkeyup="chk_score_over_fix(this,this.value)" class_name_change="2'.$score_desirable_1['DataID'].'" disabled="disabled" class="class_name_2'.$score_desirable_2['DataID'].' select-table-form value_score_desirable_2 class_col_set_new_edit class_col_desirable_2 text-center" type="text"  value="'.$score_desirable_2['score'].'"></td>
                                 	<td class="relative"><input name="score_final_desirable_3[]" value_set="'.$score_desirable_3['score'].'" onkeyup="chk_score_over_fix(this,this.value)" class_name_change="3'.$score_desirable_1['DataID'].'" disabled="disabled" class="class_name_3'.$score_desirable_3['DataID'].' select-table-form value_score_desirable_3 class_col_set_new_edit class_col_desirable_3 text-center" type="text"  value="'.$score_desirable_3['score'].'"></td>
                                 	<td class="relative"><input name="score_final_desirable_4[]" value_set="'.$score_desirable_4['score'].'" onkeyup="chk_score_over_fix(this,this.value)" class_name_change="4'.$score_desirable_1['DataID'].'" disabled="disabled" class="class_name_4'.$score_desirable_4['DataID'].' select-table-form value_score_desirable_4 class_col_set_new_edit class_col_desirable_4 text-center" type="text"  value="'.$score_desirable_4['score'].'"></td>
                                 	<td class="relative"><input name="score_final_desirable_5[]" value_set="'.$score_desirable_5['score'].'" onkeyup="chk_score_over_fix(this,this.value)" class_name_change="5'.$score_desirable_1['DataID'].'" disabled="disabled" class="class_name_5'.$score_desirable_1['DataID'].' select-table-form value_score_desirable_5 class_col_set_new_edit class_col_desirable_5 text-center" type="text"  value="'.$score_desirable_5['score'].'"></td>
                                 	<td class="relative"><input name="score_final_desirable_6[]" value_set="'.$score_desirable_6['score'].'" onkeyup="chk_score_over_fix(this,this.value)" class_name_change="6'.$score_desirable_1['DataID'].'" disabled="disabled" class="class_name_6'.$score_desirable_6['DataID'].' select-table-form value_score_desirable_6 class_col_set_new_edit class_col_desirable_6 text-center" type="text"  value="'.$score_desirable_6['score'].'"></td>
                                 	<td class="relative"><input name="score_final_desirable_7[]" value_set="'.$score_desirable_7['score'].'" onkeyup="chk_score_over_fix(this,this.value)" class_name_change="7'.$score_desirable_1['DataID'].'" disabled="disabled" class="class_name_7'.$score_desirable_7['DataID'].' select-table-form value_score_desirable_7 class_col_set_new_edit class_col_desirable_7 text-center" type="text"  value="'.$score_desirable_7['score'].'"></td>
                                 	<td class="relative"><input name="score_final_desirable_8[]" value_set="'.$score_desirable_8['score'].'" onkeyup="chk_score_over_fix(this,this.value)" class_name_change="8'.$score_desirable_1['DataID'].'" disabled="disabled" class="class_name_8'.$score_desirable_8['DataID'].' select-table-form value_score_desirable_8 class_col_set_new_edit class_col_desirable_8 text-center" type="text"  value="'.$score_desirable_8['score'].'"></td>
                           
                                  	<td>'.$score_total.'</td>            
                                </tr>
			';
			$num_set++;
		}
		$data_response.='<input id="std_id_all_desirable" type="text" hidden="hidden" value="'.$std_id_all_desirable.'" name="">';
		return $data_response;
	}
	public function get_score_read($std_ID,$course_teachingID){
		$data_response = array();
		$this->sql ="SELECT  *
					FROM tbl_read_score 			
					WHERE course_teachingID=$course_teachingID
					AND stdID='$std_ID'
					";
		$this->select();
		$this->setRows();
		$data_response['DataID']=$this->rows[0]['DataID'];
		$score=$this->rows[0]['score'];
		if ($score=='') {
			$data_response['score']=0;
		}else{
			$data_response['score']=$score;
		}
		return $data_response;
	}
	public function get_score_write($std_ID,$course_teachingID){
		$data_response = array();
		$this->sql ="SELECT  *
					FROM tbl_write_score 			
					WHERE course_teachingID=$course_teachingID
					AND stdID='$std_ID'
					";
		$this->select();
		$this->setRows();
		$data_response['DataID']=$this->rows[0]['DataID'];
		$score=$this->rows[0]['score'];
		if ($score=='') {
			$data_response['score']=0;
		}else{
			$data_response['score']=$score;
		}
		return $data_response;
	}
	public function get_score_think($std_ID,$course_teachingID){
		$data_response = array();
		$this->sql ="SELECT  *
					FROM tbl_think_score 			
					WHERE course_teachingID=$course_teachingID
					AND stdID='$std_ID'
					";
		$this->select();
		$this->setRows();
		$data_response['DataID']=$this->rows[0]['DataID'];
		$score=$this->rows[0]['score'];
		if ($score=='') {
			$data_response['score']=0;
		}else{
			$data_response['score']=$score;
		}
		return $data_response;
	}
	public function get_std_read($coures_id_list_val,$course_teachingID,$room_search){
		$this->sql ="SELECT  *
					FROM tbl_set_term_year 			
							";
		$this->select();
		$this->setRows();
		$term_set=$this->rows[0]['term'];
		$year_set=$this->rows[0]['year'];
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 	
					WHERE DataID=$coures_id_list_val					
					";
		$this->select();
		$this->setRows();
		$class_level=$this->rows[0]['class_level'];
		if ($class_level=='p1' || $class_level=='p2' || $class_level=='p3' || $class_level=='p4' || $class_level=='p5' || $class_level=='p6') {
			$term_set='1,2';
		}
		$this->sql ="SELECT  COUNT(*) as num_row_std
					FROM tbl_student 	
					WHERE room='$room_search'
					AND std_ID in(
						SELECT stdID
					    FROM tbl_course_teaching_std
					    WHERE registed_courseID IN(
					    	SELECT DataID
					        FROM tbl_registed_course
					        WHERE courseID=$coures_id_list_val
					        AND term='$term_set'
					        AND year='$year_set'
					    )
					)

					";
		$this->select();
		$this->setRows();
		$num_row_std=$this->rows[0]['num_row_std'];
		$this->sql ="SELECT  *
					FROM tbl_student 	
					WHERE room='$room_search'
					AND std_ID in(
						SELECT stdID
					    FROM tbl_course_teaching_std
					    WHERE registed_courseID IN(
					    	SELECT DataID
					        FROM tbl_registed_course
					        WHERE courseID=$coures_id_list_val
					        AND term='$term_set'
					        AND year='$year_set'

					    )
					)
					";
		$this->select();
		$this->setRows();
		$num_set=1;
		foreach($this->rows as $key => $value) {
			$std_ID=$value['std_ID'];
			$name_title_data=$value['name_title'];
			$name_title=$this->get_name_title($name_title_data);
			$get_score_read=$this->get_score_read($std_ID,$course_teachingID);
			$get_score_write=$this->get_score_write($std_ID,$course_teachingID);
			$get_score_think=$this->get_score_think($std_ID,$course_teachingID);
			$score_total=round(($get_score_read['score']+$get_score_write['score']+$get_score_think['score'])/3,2);
			$fname=$value['fname'];
			$lname=$value['lname'];
			if ($num_row_std==$num_set) {
				$std_id_all_read.=$std_ID;
			}else{
				$std_id_all_read.=$std_ID.'-';
			}
			$data_response.='							
						 		<tr>
                                  	<td>'.$num_set.'</td>
                                  	<td style="text-align:left;padding-left:10%;">'.$name_title.$fname.' '.$lname.'</td>
                                 	<td class="relative "><input onkeyup="chk_score_over_fix(this,this.value)" value_set="'.$get_score_read['score'].'" class_name_change="1'.$get_score_read['DataID'].'" name="score_read[]" disabled="disabled" class="class_name_1'.$get_score_read['DataID'].' select-table-form value_score_read class_col_set_new_edit class_col_read text-center" type="text"  value="'.$get_score_read['score'].'"></td>

                                 	<td class="relative"><input onkeyup="chk_score_over_fix(this,this.value)" value_set="'.$get_score_write['score'].'" class_name_change="2'.$get_score_write['DataID'].'" name="score_write[]" disabled="disabled" class="class_name_2'.$get_score_write['DataID'].' select-table-form value_score_write class_col_set_new_edit class_col_write text-center" type="text"  value="'.$get_score_write['score'].'"></td>
                                 	<td class="relative"><input onkeyup="chk_score_over_fix(this,this.value)" value_set="'.$get_score_think['score'].'" class_name_change="3'.$get_score_think['DataID'].'" name="score_think[]" disabled="disabled" class="class_name_3'.$get_score_think['DataID'].' select-table-form value_score_think class_col_set_new_edit class_col_think text-center" type="text"  value="'.$get_score_think['score'].'"></td>
                                                        
                                  	<td>'.$score_total.'</td>            
                                </tr>
			';
			$num_set++;
		}
		$data_response.='<input id="std_id_all_read" type="text" hidden="hidden" value="'.$std_id_all_read.'" name="">';
		return $data_response;
	}
	public function get_read($coures_id_list_val,$room_search){
		$data_response = array();
		$this->sql ="SELECT  *
					FROM tbl_set_term_year 			
							";
		$this->select();
		$this->setRows();
		$term_set=$this->rows[0]['term'];
		$year_set=$this->rows[0]['year'];
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 	
					WHERE DataID=$coures_id_list_val					
					";
		$this->select();
		$this->setRows();
		$class_level=$this->rows[0]['class_level'];
		if ($class_level=='p1' || $class_level=='p2' || $class_level=='p3' || $class_level=='p4' || $class_level=='p5' || $class_level=='p6') {
			$term_set='1,2';
		}
		$course_teachingID=$this->get_course_teachingID($coures_id_list_val,$term_set,$year_set);
		$std_read=$this->get_std_read($coures_id_list_val,$course_teachingID,$room_search);
		$data_response='
					<input id="teaching_id_find" type="text" hidden="hidden" name="" value='.$course_teachingID.'>
					 <div  id="hr-co-text-depart_course" class="row">
				      <div class="hr-co-text-depart"></div> 
				    </div>
                     <div class="row pd-50 stage-set" >                  
                        <div class="col-sm-12 col-xs-12 mt-nega-20">                        
                          <div class="set-line">
                                  <p class="text-bold text-inline">คะแนนอ่าน เขียน คิด วิเคราะห์</p>
                                 
                          </div>
                        </div>
                      </div>
                      <div class="ml-36 mr-50 mt-nega-50" >               
                        <div class="col-sm-12 col-xs-12">                        
                          <div class="set-line">                               
                                  <p class="text-inline">คะแนน</p>
                                  <select onchange="open_edit_read()" id="read_select" name="read_select" class="form-control search-drop-sub-id mr-30">
                                    <option value="read">การอ่าน</option>
                                    <option value="write">การเขียน</option>
                                    <option value="think">การคิด วิเคราะห์</option>
                                  </select>
                                  <p class=" text-inline" >ระบุคะแนนทั้งหมดเป็น</p>
                                  <div class="input-group form-serch-width-small">
                                    <input id="input_set_data_seem_read" type="text" class="form-control form-set"  aria-describedby="basic-addon1">
                                  </div>
                                  <div class="btn-search-save-score">
                                    <div id="btn_set_data_seem_read" class="btn-search">
                                      <span class="glyphicon glyphicon-arrow-right" aria-hidden="true"></span>
                                    </div>  
                                  </div>
                          </div>
                        </div>
                      </div>     
                      <div class=" ml-50 mr-50 mt-30" >
                    
                         <div class="row">
                          <div class="col-md-12">
             
                            <table class="table table-striped-violet border-set-violet" style="text-align: center;">
                              <thead class="header-table">
                                 <tr class="text-middle">
                                    <td  rowspan = "4" width="8%" style="  vertical-align: middle;">เลขที่</td>
                                    <td rowspan = "4" width="50%" style="  vertical-align: middle;">ชื่อ-สกุล</td>                                  
                                  </tr>
                                  <tr>
                                    <td colspan="10">คะแนนอ่าน เขียน คิด วิเคราะห์</td>                                  
                                  </tr>
                                 <tr>
                                    <td width="120px">การอ่าน</td>
                                    <td width="120px">การเขียน</td>
                                    <td width="120px">การคิด วิเคราะห์</td>     
                                    <td width="120px">รวมเฉลี่ย</td>
                                                             
                                 </tr>
                                 <tr class="table-bg-white">
                                    <td>3</td>
                                    <td>3</td>
                                    <td>3</td> 
                                    <td>3.00</td>
                                    

                                 </tr>
                              </thead>
                              <tbody class="body-table">
                                
                                '.$std_read.'                         
                              </tbody>
                            </table> 
                          
                          </div>                                     
                        </div>   
                        <div class="btn-group-set-add-delete row pd-30 ">                                                     
                              <div class="btn-grey">
                                ยกเลิก
                              </div>    
                              <div data-toggle="modal" data-target="#modalReadScore" class="btn-violet">
                                บันทึก
                              </div>                   
                            </div>  
                        </div>
		';
		return $data_response;
	}
	public function get_desirable($coures_id_list_val,$room_search){
		$data_response = array();
		$this->sql ="SELECT  *
					FROM tbl_set_term_year 			
							";
		$this->select();
		$this->setRows();
		$term_set=$this->rows[0]['term'];
		$year_set=$this->rows[0]['year'];
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 	
					WHERE DataID=$coures_id_list_val					
					";
		$this->select();
		$this->setRows();
		$class_level=$this->rows[0]['class_level'];
		if ($class_level=='p1' || $class_level=='p2' || $class_level=='p3' || $class_level=='p4' || $class_level=='p5' || $class_level=='p6') {
			$term_set='1,2';
		}
		$course_teachingID=$this->get_course_teachingID($coures_id_list_val,$term_set,$year_set);
		$std_desirable=$this->get_std_desirable($coures_id_list_val,$course_teachingID,$room_search);
		$data_response='
					<input id="teaching_id_find" type="text" hidden="hidden" name="" value='.$course_teachingID.'>
					 <div  id="hr-co-text-depart_course" class="row">
				      <div class="hr-co-text-depart"></div> 
				    </div>
					<div class="row pd-50 stage-set" >                  
                        <div class="col-sm-12 col-xs-12 mt-nega-20">                        
                          <div class="set-line">
                                  <p class="text-bold text-inline">คะแนนคุณลักษณะอันพึงประสงค์</p>
                                 
                          </div>
                        </div>
                      </div>
                      <div class="ml-36 mr-50 mt-nega-50" >               
                        <div class="col-sm-12 col-xs-12">                        
                          <div class="set-line">                               
                                  <p class="text-inline">คะแนน</p>
                                  <select onchange="open_edit_desirable()" id="desirable_select" name="desirable_select" class="form-control search-drop-sub-id mr-30">
                                    <option value="desirable_1">ข้อที่ 1</option>
                                    <option value="desirable_2">ข้อที่ 2</option>
                                    <option value="desirable_3">ข้อที่ 3</option>
                                    <option value="desirable_4">ข้อที่ 4</option>
                                    <option value="desirable_5">ข้อที่ 5</option>
                                    <option value="desirable_6">ข้อที่ 6</option>
                                    <option value="desirable_7">ข้อที่ 7</option>
                                    <option value="desirable_8">ข้อที่ 8</option>
                                  </select>
                                  <p class=" text-inline" >ระบุคะแนนทั้งหมดเป็น</p>
                                  <div class="input-group form-serch-width-small">
                                    <input id="input_set_data_seem_desirable" type="text" class="form-control form-set"  aria-describedby="basic-addon1">
                                  </div>
                                  <div class="btn-search-save-score">
                                    <div id="btn_set_data_seem_desirable" class="btn-search">
                                      <span class="glyphicon glyphicon-arrow-right" aria-hidden="true"></span>
                                    </div>  
                                  </div>
                          </div>
                        </div>
                      </div>  
                       <div class=" ml-50 mr-50 mt-30" >
 
                         <div class="row">
                          <div class="col-md-12">
             
                            <table class="table table-striped-violet border-set-violet" style="text-align: center;">
                              <thead class="header-table">
                                 <tr class="text-middle">
                                    <td  rowspan = "4" width="8%" style="  vertical-align: middle;">เลขที่</td>
                                    <td rowspan = "4" width="35%" style="  vertical-align: middle;">ชื่อ-สกุล</td>                                  
                                  </tr>
                                  <tr>
                                    <td colspan="10">คะแนนคุณลักษณะอันพึงประสงค์</td>                                  
                                  </tr>
                                 <tr>
                                    <td>ข้อที่ 1</td>
                                    <td>ข้อที่ 2</td>
                                    <td>ข้อที่ 3</td>     
                                    <td>ข้อที่ 4</td>
                                    <td>ข้อที่ 5</td>
                                    <td>ข้อที่ 6</td>
                                    <td>ข้อที่ 7</td>
                                    <td>ข้อที่ 8</td> 
                                    <td>รวมเฉลี่ย</td>                           
                                 </tr>
                                 <tr class="table-bg-white">
                                    <td>3</td>
                                    <td>3</td>
                                    <td>3</td> 
                                    <td>3</td>
                                    <td>3</td>
                                    <td>3</td>
                                    <td>3</td>
                                    <td>3</td>
                                    <td>3.00</td>  

                                 </tr>
                              </thead>
                              <tbody class="body-table">
                                
                                '.$std_desirable.'
                              </tbody>
                            </table> 
                          
                          </div>                                     
                        </div>   
                        <div class="btn-group-set-add-delete row pd-30 ">                                                     
                              <div class="btn-grey">
                                ยกเลิก
                              </div>    
                              <div data-toggle="modal" data-target="#modalDesirableScore" class="btn-violet">
                                บันทึก
                              </div>                   
                            </div>  
                        </div>
		';
		return $data_response;
	}
	public function get_exam($coures_id_list_val,$room_search){
		$data_response = array();
		$this->sql ="SELECT  *
					FROM tbl_set_term_year 			
							";
		$this->select();
		$this->setRows();
		$term_set=$this->rows[0]['term'];
		$year_set=$this->rows[0]['year'];
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 	
					WHERE DataID=$coures_id_list_val					
					";
		$this->select();
		$this->setRows();
		$class_level=$this->rows[0]['class_level'];
		if ($class_level=='p1' || $class_level=='p2' || $class_level=='p3' || $class_level=='p4' || $class_level=='p5' || $class_level=='p6') {
			$term_set='1,2';
		}
		$propotion_total=$this->get_propotion_total($coures_id_list_val);
		$course_teachingID=$this->get_course_teachingID($coures_id_list_val,$term_set,$year_set);
		$std_exam=$this->get_std_exam($coures_id_list_val,$course_teachingID,$room_search);
		$data_response='
				 <input id="teaching_id_find" type="text" hidden="hidden" name="" value='.$course_teachingID.'>
					<div  id="hr-co-text-depart_course" class="row">
				      <div class="hr-co-text-depart"></div> 
				    </div>
			    <div id="course_detal_box" class="ml-50 mr-50 mt-10" >
			      <div class="row">
			        <div class="box-search-depart">
				     <table>
                  		<tbody style="border: none;">
                  			<tr >
		                      <td class="text-before-box3 text-bold" style="float: right;padding-left:45px;">
		                        คะแนน
		                      </td> 
		                      <td width="200px">
		                        <form>
		                          	<select onchange="open_edit_exam()" id="exam_score_select" name="exam_score_select" class="form-control search-drop-length-ob mt-5">
		                          		<option value="mid">กลางภาค</option>     
		                          		<option value="final">ปลายภาค</option>                                  
		                        	</select> 
		                        </form>
		                        
		                      </td>
		                     
		                    </tr>
                  		</tbody>
                  	<table>
                  	</div>
                  	</div>
                  	</div>
						<div class=" ml-50 mr-50 mt-30" >
                        
                         <div class="row">
                          <div class="col-md-12">
             
                            <table class="table table-striped-violet border-set-violet" style="text-align: center;">
                              <thead class="header-table">
                                 <tr class="text-middle">
                                    <td  rowspan = "4" width="8%" style="  vertical-align: middle;">เลขที่</td>
                                    <td rowspan = "4" width="60%" style="  vertical-align: middle;">ชื่อ-สกุล</td>                                  
                                  </tr>
                                  <tr>
                                    <td colspan="10">คะแนนสอบ</td>                                  
                                  </tr>
                                 <tr>
                                    <td>กลางภาค</td>
                                    <td>ปลายภาค</td>
                                    <td>รวม</td>                                 
                                 </tr>
                                 <tr class="table-bg-white">
                                    <td>'.$propotion_total['mid_exam'].'</td>
                                    <td>'.$propotion_total['final_exam'].'</td>
                                    <td>'.$propotion_total['total'].'</td>                                    
                                 </tr>
                              </thead>
                              <tbody class="body-table">
                                '.$std_exam.'
                              </tbody>
                            </table> 
                          
                          </div>                                     
                        </div>   
                        <div class="btn-group-set-add-delete row pd-60 ">                                                     
                              <div class="btn-grey">
                                ยกเลิก
                              </div>    
                              <div data-toggle="modal" data-target="#modalExamScore" class="btn-violet">
                                บันทึก
                              </div>                   
                            </div>  
                        </div>

				
		';
		return $data_response;
	}
	
	
	
	public function get_pick($coures_id_list_val,$active_length){
		$data_response = array();	
		$this->sql ="SELECT  count(*) as num_row
					FROM tbl_objective_conclude 	
					WHERE courseID=$coures_id_list_val
					";
		$this->select();
		$this->setRows();	

		$num_row=$this->rows[0]['num_row'];
			$num=0;
			$loop_set=ceil($num_row/10);
			$scrap=$num_row%10;
			if ($num_row<=10) {
					if ($num_row==10) {
						$length_list="<option class=\"chk_active_1\" status=\"chk_active_1\" value=\"1-10\">ตัวชี้วัดข้อที่ 1-10 </option>" ;
					}elseif($num_row<10){
						if ($num_row==1) {
							$length_list="<option class=\"chk_active_1\" status=\"chk_active_1\" value=\"1-1\">ตัวชี้วัดข้อที่ 1</option>" ;
						}else{
							$length_list="<option class=\"chk_active_1\" status=\"chk_active_1\" value=\"1-{$num_row}\">ตัวชี้วัดข้อที่ 1-{$num_row} </option>" ;
						}
						
					}				
				}else{
					$num_loop_class=1;
					for ($i=1; $i <=$loop_set ; $i++) { 

							if ($i==1) {
								$length_list.="<option class=\"chk_active_1\" status=\"chk_active_1\" value=\"1-10\">ตัวชี้วัดข้อที่ 1-10 </option>" ;
							}else{
								if ($loop_set==$i) {
									if ($scrap==0) {
											$length_list.="<option {$this->get_selected($num_loop_class)} class=\"chk_active_{$num_loop_class}\" status=\"chk_active_{$num_loop_class}\" value=\"{$num}1-{$loop_set}0\">ตัวชี้วัดข้อที่ {$num}1-{$loop_set}0 </option>" ;
									}else{
										if ($scrap==1) {
											$length_list.="<option {$this->get_selected($num_loop_class)} class=\"chk_active_{$num_loop_class}\" status=\"chk_active_{$num_loop_class}\" value=\"{$num}1-{$num}1\">ตัวชี้วัดข้อที่ {$num}1 </option>" ;
										}else{
											$length_list.="<option {$this->get_selected($num_loop_class)}  class=\"chk_active_{$num_loop_class}\" status=\"chk_active_{$num_loop_class}\" value=\"{$num}1-{$num}{$scrap}\">ตัวชี้วัดข้อที่ {$num}1-{$num}{$scrap} </option>" ;
										}										
									}									
								}else{
									$length_list.="<option {$this->get_selected($num_loop_class)} class=\"chk_active_{$num_loop_class}\" status=\"chk_active_{$num_loop_class}\" value=\"{$num}1-{$i}0\">ตัวชี้วัดข้อที่ {$num}1-{$i}0 </option>" ;
								}							
							}	
						$num++;
						$num_loop_class++;
					}					
				}
		$this->sql ="SELECT  no_order,detail
					FROM tbl_objective_conclude 	
					WHERE courseID=$coures_id_list_val
					ORDER BY no_order ASC
					";
		$this->select();
		$this->setRows();	
		foreach($this->rows as $key => $value) {
			$no_order=$value['no_order'];
			$detail=$value['detail'];
			$objective_conclude_desc.='
									<tr>
					                    <td width="80px">ตัวชี้วัดที่ '.$no_order.'</td>		
					                    <td >'.$detail.'</td>			                    
					                 </tr>
			';
		}
		$data_response='
						<div  id="hr-co-text-depart_course" class="row">
				      <div class="hr-co-text-depart"></div> 
				    </div>
						<div id="text_header_config" class="row pd-50 stage-set" >                  
						      <div class="col-sm-12 col-xs-12 mt-nega-20">                        
						        <div class="set-line">
						          <p class="text-bold text-before-box fs-18">คะแนนเก็บ</p>

						        </div>
						      </div>
						    </div>
						     <div id="course_config_box" class="ml-36 mr-50 mt-nega-50" >               
						      <div class="col-sm-12 col-xs-12">                        
						        <div class="set-line"> 
						          <div id="rate_score_box" class="col-sm-12 col-xs-12" style="display: block;">  
						            <div class="row">

						              <table>
						                <tbody style="border: none;">
						                  <tr >
						                    <td class="text-before-box3 text-bold" style="float: right;">
						                      ช่วงคะแนน
						                    </td>
						                    <td width="250px">
						                      <select onchange="get_objective_list()"  id="length_list_val" name="length_list_val"  class="form-control search-drop-length-ob mt-5">
						                       '.$length_list.'   	   
						                      </select> 
						                    </td>  

						                  </tr>
						                  <tr >
						                    <td class="text-before-box3 text-bold" style="float: right;">
						                      คะแนน
						                    </td>
						                    <td width="200px">
						                      <select onchange="open_edit_score()" id="objective_list" name="objective_list" class="form-control search-drop-length-ob mt-5">
						                                          	      
						                      </select> 
						                    </td>  

						                    <td class="text-before-box3 text-bold" style="float: right;">
						                      ระบุคะแนนทั้งหมดเป็น
						                    </td>
						                    <td>
						                      <div class="input-group form-serch-width-small">
						                        <input id="input_set_data_seem" type="text" class="form-control form-set"  aria-describedby="basic-addon1">
						                      </div>
						                    </td>
						                    <td>
						                      <div class="btn-search-save-score ">
						                        <div id="btn_set_data_seem" class="btn-search">						                        
						                            <span class="glyphicon glyphicon-arrow-right" aria-hidden="true"></span>						                      
						                        </div>                                                                           
						                      </div>  
						                    </td>
						                  </tr>
						                </tbody>                                         
						              </table>
						            </div>                               
						          </div>                        
						        </div>
						      </div>
						    </div>
						    <!--table-->
						    <div class=" ml-50 mr-50 mt-80" >
						      <div class="row">
						        <div class="col-md-12">
						          <div class="table-responsive">
						            <table class="table table-striped-violet border-set-violet" style="text-align: center;">
						              <thead class="header-table">
						                <tr class="text-middle">
						                  <td  rowspan = "5" width="8%" style="  vertical-align: middle;">เลขที่</td>
						                  <td rowspan = "5" width="40%" style="  vertical-align: middle;">ชื่อ-สกุล</td>
						                  <td colspan="11">คะแนนเก็บ</td>      
						                </tr>
						                <tr>
						                  <td id="end_data_find" colspan="10">ตัวชี้วัดทื่/คะแนน</td> 
						                  <td rowspan = "2">รวม</td>
						                </tr>
						                <tr id="ob_title_table_col">
						               
						                </tr>
						               	<tr id="ob_score_max_table_col" class="table-bg-white">
						               
						                </tr>
						              </thead>
						              <form id="frm_objective_score_std">
						              <tbody id="detail_std" class="body-table">
						              	
						              </tbody>
						              </form>
						            </table> 
						          </div>
						        </div>                                     
						      </div>   
						      <div class="btn-group-set-add-delete row pd-30 ">                                                     
						        <div class="btn-grey">
						          ยกเลิก
						        </div>    
						        <div data-toggle="modal" data-target="#modalConScore" class="btn-violet">
						          บันทึก
						        </div>                   
						      </div>  
						    </div>
							<div class=" ml-50 mr-50 " >
						      <div class="row">
						        <div class="col-md-12">
						        <table>
					                <tbody class="border-none">
					                  '.$objective_conclude_desc.'
					                </tbody>
					              </table>
						        </div>
						       </div>
						    </div>
		';
		return $data_response;
	}

	
}
?><file_sep>/modules/chk_grade/process.php
<?php
@ob_start();
@session_start();

require_once('../../init.php');
include('../../src/class.pagination.php');
include('../../src/class.inputfilter.php');
$InputFilter = new InputFilter();

##CLASS_DB_CONNECT##
include('class_modules.php');
$class_data = new ClassData();
##CLASS_DB_CONNECT##
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_grade"){	
	echo $class_data->get_grade();
}<file_sep>/index.php
<?php
/*
 * Web-Based Instruction PHP Programming 
 * Copyright (C) 2007-2015
 * This is the integration file for PHP (versions 5)
*/
@ob_start();
@session_start();

if( !$_SESSION['ss_user_id'] ){
	header('location:login.php');
} 
if ($_SERVER["SERVER_NAME"]=='192.168.3.11') {
  header('location:index.php?op=messages-error404');
}
require_once('init.php');


/////// CLASS ROLE MANAGEMENT /////
require_once(HOME_PATH.'src/class_role.php');
$role = new ClassRole();
$_db = new Databases();
$user_role_id = (int)$_SESSION['ss_user_id'];

function cURLData($url, $data){

	$postData = http_build_query($data);

	$ch = curl_init();
	curl_setopt_array(
	    $ch, array( 
	    CURLOPT_URL => $url,
	   	CURLOPT_RETURNTRANSFER => true,
	    CURLOPT_POST => true,
	    CURLOPT_POSTFIELDS => $postData,
	    CURLOPT_FOLLOWLOCATION => true
	));
	$response = curl_exec($ch);
	curl_close ($ch); //close curl handle	
	return $response;
}

$BACKOFFICE_ACCOUNT_NAME = "{$_SESSION['ss_prefix_name']} {$_SESSION['ss_first_name']} {$_SESSION['ss_last_name']}";


//BODY_PAGE
if(!empty($_GET['op'])){
	$OPURL			=	trim($_GET['op']);
	$GETOP			=	explode("-",$OPURL);
	$OPEN_PAGE		= 	"modules/".$GETOP[0];
  $MODAL_PAGE    =   "modules/".$GETOP[0]."/modal.php";
	$CONFIG_PAGE 	= 	"{$OPEN_PAGE}/{$GETOP[1]}.php";
    $CONFIG_JS_PAGE =   "{$OPEN_PAGE}/{$GETOP[1]}.js";
    $CONFIG_CSS_PAGE =   "{$OPEN_PAGE}/{$GETOP[1]}.css";
	if (empty($GETOP[1]) || !file_exists($CONFIG_PAGE)) {
		header('location:index.php?op=messages-error404');
	}
}else{
	$OPEN_PAGE		= 	"modules/home";
	$CONFIG_PAGE 	=	$OPEN_PAGE."/index.php";
    $CONFIG_JS_PAGE =   $OPEN_PAGE."/index.js";
    $CONFIG_CSS_PAGE =   $OPEN_PAGE."/index.css";
    $MODAL_PAGE =   $OPEN_PAGE."/modal.php";

}


$POSTDATA = array();
foreach ($_GET as $key => $value) { $POSTDATA[$key] = $value; }
foreach ($_POST as $key => $value) { $POSTDATA[$key] = $value; }


//OTHER_JS_PAGE
$CONFIG_JS_PAGE = (file_exists($CONFIG_JS_PAGE)) ? '<script src="'.$CONFIG_JS_PAGE.'" type="text/javascript"></script>' : '';
$CONFIG_CSS_PAGE = (file_exists($CONFIG_CSS_PAGE)) ? '<link href="'.$CONFIG_CSS_PAGE.'" rel="stylesheet" type="text/css" />' : '';

$view_user_ath = $role->ath_chk_role($user_role_id);
// USER AUTHEN MENU
/*$view_user_ath = $role->ath_user_reletion_tasks('view_user_ath',$user_role_id);
$view_acp = $role->ath_user_reletion_tasks('view_acp',$user_role_id);
$view_prt = $role->ath_user_reletion_tasks('view_prt',$user_role_id);
$view_mst = $role->ath_user_reletion_tasks('view_mst',$user_role_id);
$view_mct = $role->ath_user_reletion_tasks('view_mct',$user_role_id);
$view_eps = $role->ath_user_reletion_tasks('view_eps',$user_role_id);
$reset_rps = $role->ath_user_reletion_tasks('reset_rps',$user_role_id);
$view_usr = $role->ath_user_reletion_tasks('view_usr',$user_role_id);*/
?>

<!DOCTYPE html>
<html>

<head>
   <meta charset="utf-8">
      <meta http-equiv="X-UA-Compatible" content="IE=edge">
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
      <title>ระบบวัดและประเมินผล</title>

      <!-- Bootstrap -->
      <link href="assets/css/bootstrap.css" rel="stylesheet">
      <link href="assets/css/custom.css" rel="stylesheet">
      <link href="assets/css/margin-padding.css" rel="stylesheet">
      
      
      <link rel="icon" type="image/gif/png" href="assets/images/logo.png">
      <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
      <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
      <!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
        <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
      <![endif]-->
      <link rel="stylesheet" type="text/css" media="screen and (max-width:768px)" href="assets/css/extrasmall.css">
      <link rel="stylesheet" type="text/css" media="screen and (min-width:768px)" href="assets/css/small.css">
      <link rel="stylesheet" type="text/css" media="screen and (min-width:992px)" href="assets/css/medium.css">
      <link rel="stylesheet" type="text/css" media="screen and (min-width:1200px)" href="assets/css/large.css">
      <link href="assets/css/responsive.css" rel="stylesheet">
      <link href="assets/css/modal-alert.css" rel="stylesheet">
    <!--[if lte IE 9]>
        <link href="assets/pages/css/ie9.css" rel="stylesheet" type="text/css" />
    <![endif]-->

    <script type="text/javascript">
    window.onload = function() {
        // fix for windows 8
        if (navigator.appVersion.indexOf("Windows NT 6.2") != -1)
            document.head.innerHTML += '<link rel="stylesheet" type="text/css" href="assets/pages/css/windows.chrome.fix.css" />'
    }

    var _get = function () {
      // This function is anonymous, is executed immediately and 
      // the return value is assigned to QueryString!
      var query_string = {};
      var query = window.location.search.substring(1);
      var vars = query.split("&");
      for (var i=0;i<vars.length;i++) {
        var pair = vars[i].split("=");
            // If first entry with this name
        if (typeof query_string[pair[0]] === "undefined") {
          query_string[pair[0]] = pair[1];
            // If second entry with this name
        } else if (typeof query_string[pair[0]] === "string") {
          var arr = [ query_string[pair[0]], pair[1] ];
          query_string[pair[0]] = arr;
            // If third or later entry with this name
        } else {
          query_string[pair[0]].push(pair[1]);
        }
      } 
        return query_string;
    } ();
    
    </script>
</head>

<body class="fixed-header" style="background-color: white;">
    <section class="nav-tab">
        <div class="container-flult" >
          <?php include(HOME_PATH."includes/mobile-menu.php");?>
          <?php include(HOME_PATH."includes/left-tab.php");?>
             <div class="col-sm-9"><!-- user tab-->   
                <?php include(HOME_PATH."includes/name-tab.php");?>
                      <div class="row main-content" id="content"><!-- main content-->
                        <?php include(HOME_PATH.$CONFIG_PAGE);?>

                      </div>
             </div>
        </div>
    </section>
    <?php include(HOME_PATH.$MODAL_PAGE);?>


 <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
      <script type="text/javascript" src="assets/js/jquery.js"></script>
      <script type="text/javascript" src="assets/js/jquery.nailthumb.1.1.min.js"></script>
      <!-- Include all compiled plugins (below), or include individual files as needed -->
      <script src="assets/js/bootstrap.min.js"></script>
      
      <script src="assets/js/custom.js"></script>
       <script src="assets/js/pdfmake.min.js"></script>
       <script src="assets/js/vfs_fonts.js"></script>
       
    <!--  <script src="assets/js/modal-alert.js"></script>-->
    <!-- END PAGE LEVEL JS -->
 
    <script src="includes/name-tab.js"></script>
    <?=$CONFIG_JS_PAGE;?>
    <?=$CONFIG_CSS_PAGE;?>

</body>
</html>


<file_sep>/init.php
<?php

if( !session_id() ){ session_start(); }

$_domain_url = 'http';
if( isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"]){
	$_domain_url .= 's';
}
$_domain_url .= '://'.$_SERVER['SERVER_NAME'].'/';


if( $_SERVER['SERVER_NAME'] != 'localhost' ){ 
	// serverhost
	define( 'BASE_PATH', dirname(__DIR__).'/');
	define( 'MAIN_BACKOFFICE', 'sratong-app/');
}else{ 
	// localhost
	define('BASE_PATH', str_replace('\\','/',dirname(__DIR__)).'/');
	define( 'MAIN_BACKOFFICE', 'sratong-app/');
}

define( 'HOME_PATH', BASE_PATH.MAIN_BACKOFFICE);

define( 'HOME_URL', $_domain_url.MAIN_BACKOFFICE);
define( 'BASE_URL', $_domain_url);


// Main Class
require_once(HOME_PATH.'config.php');
require_once(HOME_PATH.'src/database.php');
require_once(HOME_PATH.'src/function.php');

define( 'TODAY', date('Y-m-d'));
define( 'TOTIME', date('H:i:s'));
define( 'DATETIME', date('Y-m-d H:i:s'));
define( 'LASTTIME', time()*1000);
define( 'MICROTIME', microtime()); 

define("TITLE_PAGE", "Evaluation System");






	<file_sep>/modules/attend_class/class_modules.php
<?php 

class ClassData extends Databases {
	public function get_day_list($length_list_val,$registed_course_id,$room_search){
		$this->sql ="SELECT status,status_form
					FROM tbl_add_delete_course 		
					WHERE DataID in(
						SELECT courseID
						FROM tbl_registed_course
						WHERE DataID in(
							SELECT registed_courseID
							FROM tbl_registed_course_teaching
							WHERE DataID=$registed_course_id
						)
					)	
							";
		$this->select();
		$this->setRows();
		$status=$this->rows[0]['status'];
		$status_form=$this->rows[0]['status_form'];
		if ($status==1) {
			$sql_condition="AND room='$room_search'";
		}else{
			if ($status_form==25 || $status_form==26 || $status_form==27) {
				$sql_condition="AND room='$room_search'";
			}else{
				$sql_condition="";
			}
			
		}
		$data_response = array();
		$this->sql ="SELECT  COUNT(*) as num_attend_day
					FROM tbl_set_attend_day 		
					WHERE registed_course_teachingID=$registed_course_id	
					$sql_condition
							";
		$this->select();
		$this->setRows();
		$data_response['num_attend_day']=$this->rows[0]['num_attend_day'];

		$data_response['week_title']='สัปดาห์ที่ '.$length_list_val.'';
		$this->sql ="SELECT  *
					FROM tbl_set_attend_day 		
					WHERE registed_course_teachingID=$registed_course_id	
					$sql_condition
					ORDER BY attend_class_week_listID ASC
							";
		$this->select();
		$this->setRows();
		$data_count=0;
		foreach($this->rows as $key => $value) {
			$attend_class_week_listID=$value['attend_class_week_listID'];
			$day_name=$this->get_day_name($attend_class_week_listID);
			$data_response['week_header'].='<td class="set_header_width" width="70px">'.$day_name.'</td>';
			$data_count++;
		}
		$data_response['week_header'].='<td id="header_sum_score">0</td>';
		$data_response['week_header'].='<td >100</td>';
		$data_response['data_count']=$data_count;
		echo json_encode($data_response);
	}
	public function get_day_name($day_id){
		$this->sql ="SELECT  *
					FROM tbl_attend_class_week_list 		
					WHERE DataID=$day_id	
							";
		$this->select();
		$this->setRows();
		return $this->rows[0]['name'];
	}
	public function set_hr($registed_course_id,$value_day,$hr_set){
		$this->sql ="UPDATE tbl_set_attend_day SET hr=$hr_set WHERE registed_course_teachingID=$registed_course_id AND attend_class_week_listID=$value_day";
		$this->query();
		$this->sql ="SELECT  DataID
					FROM tbl_set_attend_day 		
					WHERE registed_course_teachingID=$registed_course_id	
					AND attend_class_week_listID=$value_day
							";
		$this->select();
		$this->setRows();
		$DataID=$this->rows[0]['DataID'];
		$this->sql ="DELETE FROM tbl_attend_class_std WHERE set_attend_day_id=$DataID" ;
		$this->query();
		echo json_encode('1');
	}
	public function set_day($registed_course_id,$value_day,$hr_set,$room_search,$coures_id_list_val){
		
			$this->sql ="SELECT  COUNT(*) as num_row_day
					FROM tbl_set_attend_day 		
					WHERE registed_course_teachingID=$registed_course_id	
					AND attend_class_week_listID=$value_day
					AND room='$room_search'
							";
			$this->select();
			$this->setRows();
			$num_row_day=$this->rows[0]['num_row_day'];
			if ($num_row_day==0) {
				$this->sql ="SELECT  hr_learn,class_level
					FROM tbl_add_delete_course 		
					WHERE DataID=$coures_id_list_val
							";
				$this->select();
				$this->setRows();
				$hr_learn=$this->rows[0]['hr_learn'];
				$class_level=$this->rows[0]['class_level'];
				if ($class_level=='p1' || $class_level=='p2' || $class_level=='p3' || $class_level=='p4' || $class_level=='p5' || $class_level=='p6') {
					$main_hr_set=40;
				}else{
					$main_hr_set=20;
				}
				$this->sql ="SELECT  SUM(hr) as amount_hr
							FROM tbl_set_attend_day 		
							WHERE registed_course_teachingID=$registed_course_id	
							AND room='$room_search'
									";
				$this->select();
				$this->setRows();
				$amount_hr=$this->rows[0]['amount_hr'];
				$find_hr_amount_now=$main_hr_set*($amount_hr+$hr_set);
				if ($find_hr_amount_now<=$hr_learn) {
					$this->sql ="INSERT INTO tbl_set_attend_day(registed_course_teachingID,attend_class_week_listID,hr,room) VALUES($registed_course_id,$value_day,$hr_set,'$room_search')";
					$this->query();
					$data_response=1;
				}else{
					$data_response=0;
				}
			}else{
				$this->sql ="DELETE FROM tbl_set_attend_day WHERE registed_course_teachingID=$registed_course_id AND attend_class_week_listID=$value_day AND room='$room_search'" ;
				$this->query();
				$data_response=1;
			}
			
		echo json_encode($data_response);
	}
	
	public function get_hr_list($hr){
		if ($hr==1) {
			$data_response='  
                               <option selected value="1">1</option>
                               <option value="2">2</option>
                               <option value="3">3</option>
                               
			'; 
		}elseif($hr==2) {
			$data_response='
                               <option value="1">1</option>
                               <option selected value="2">2</option>
                               <option value="3">3</option>     
			'; 
		}elseif($hr==3) {
			$data_response='						                               
                               <option value="1">1</option>
                               <option value="2">2</option>
                               <option selected value="3">3</option>
			'; 
		}
		return $data_response;
	}
	public function get_day_set($registed_course_id,$room_search){

		$this->sql ="SELECT status,status_form 
					FROM tbl_add_delete_course 		
					WHERE DataID in(
						SELECT courseID
						FROM tbl_registed_course
						WHERE DataID in(
							SELECT registed_courseID
							FROM tbl_registed_course_teaching
							WHERE DataID=$registed_course_id
						)
					)	
							";
		$this->select();
		$this->setRows();
		$status=$this->rows[0]['status'];
		$status_form=$this->rows[0]['status_form'];

		if ($status==1) {
			$sql_condition="AND room='$room_search'";
		}else{
			if ($status_form==25 || $status_form==26 || $status_form==27) {
				$sql_condition="AND room='$room_search'";
			}else{
				$sql_condition="";
			}
			
		}
		$this->sql ="SELECT  *
					FROM tbl_set_attend_day 		
					WHERE registed_course_teachingID=$registed_course_id	
					$sql_condition
							";
		$this->select();
		$this->setRows();
		$monday="";
		$tuesday="";
		$wednesday ="";
		$thursday ="";
		$friday="";

		$monday_hr="disabled";
		$tuesday_hr="disabled";
		$wednesday_hr="disabled";
		$thursday_hr="disabled";
		$friday_hr="disabled";
			
		$hr_list_1='<option value="1">1</option><option value="2">2</option><option value="3">3</option>';
		$hr_list_2='<option value="1">1</option><option value="2">2</option><option value="3">3</option>';
		$hr_list_3='<option value="1">1</option><option value="2">2</option><option value="3">3</option>';
		$hr_list_4='<option value="1">1</option><option value="2">2</option><option value="3">3</option>';
		$hr_list_5='<option value="1">1</option><option value="2">2</option><option value="3">3</option>';

		foreach($this->rows as $key => $value) {
			
			$day_find=$value['attend_class_week_listID'];
			$hr=$value['hr'];
			if ($day_find==1) {
				$monday='checked';
				$monday_hr="";
				$hr_list_1=$this->get_hr_list($hr);
			}
			if ($day_find==2) {
				$tuesday='checked';
				$tuesday_hr="";
				$hr_list_2=$this->get_hr_list($hr);
			}
			if ($day_find==3) {
				$wednesday='checked';
				$wednesday_hr="";
				$hr_list_3=$this->get_hr_list($hr);
			}
			if ($day_find==4) {
				$thursday='checked';
				$thursday_hr="";
				$hr_list_4=$this->get_hr_list($hr);
			}
			if ($day_find==5) {
				$friday='checked';
				$friday_hr="";
				$hr_list_5=$this->get_hr_list($hr);
			}		
		}
		$data_response['btn_place']='
				 	<td class="text-before-box3 text-bold mt-10" style="float: right;">
                          วันที่สอน
                        </td> 
                        <td>
                                                                                                  
                          <div data-toggle="modal" data-target="#modalSetTime" class="btn-violet">
                                ระบุวันที่สอน
                          </div>                   
               
                    </td>          
			';
		$data_response['modal_group_set']='
				 	 
						             	<td  style="padding-left:25px;">
				                          <div class="checkbox mr-20 ml-10">
				                            <label><input class="day_set_1" onclick="set_day(this)" '.$monday.' type="checkbox" name="day_set" value="1">จันทร์</label>
				                          </div>
				                          <div>
				                          	<select '.$monday_hr.' onchange="set_hr(this,1)" style="width:75px;" class="form-control search-drop-length-ob mt-5 hr_set_1">
				                              '.$hr_list_1.'
				                            </select>
				                          </div>
				                        </td>
				                        <td  style="padding-left:25px;">
				                          <div class="checkbox mr-20 ml-10 ">
				                            <label><input class="day_set_2" onclick="set_day(this)" '.$tuesday.' type="checkbox" name="day_set" value="2">อังคาร</label>
				                          </div>
				                          <div>
				                          	<select '.$tuesday_hr.' onchange="set_hr(this,2)" style="width:75px;" class="form-control search-drop-length-ob mt-5 hr_set_2">
				                              '.$hr_list_2.'
				                            </select>
				                          </div>
				                        </td>
				                        <td  style="padding-left:25px;">
				                          <div class="checkbox mr-20 ml-10">
				                            <label><input class="day_set_3" onclick="set_day(this)" '.$wednesday.' type="checkbox" name="day_set" value="3">พุธ</label>
				                          </div>
				                          <div>
				                          	<select '.$wednesday_hr.' onchange="set_hr(this,3)" style="width:75px;" class="form-control search-drop-length-ob mt-5 hr_set_3">
				                              '.$hr_list_3.'
				                            </select>
				                          </div>
				                        </td>
				                        <td  style="padding-left:25px;">
				                          <div class="checkbox mr-20 ml-10">
				                            <label><input class="day_set_4" onclick="set_day(this)" '.$thursday.' type="checkbox" name="day_set" value="4">พฤหัสบดี</label>
				                          </div>
				                          <div>
				                          	<select '.$thursday_hr.' onchange="set_hr(this,4)" style="width:75px;" class="form-control search-drop-length-ob mt-5 hr_set_4">
				                          	
				                              '.$hr_list_4.'
				                            </select>
				                          </div>
				                        </td>
				                        <td  style="padding-left:25px;">
				                          <div class="checkbox mr-20 ml-10">
				                            <label><input class="day_set_5" onclick="set_day(this)" '.$friday.' type="checkbox" name="day_set" value="5">ศุกร์</label>
				                          </div>
				                          <div>
				                          	<select '.$friday_hr.' onchange="set_hr(this,5)" style="width:75px;" class="form-control search-drop-length-ob mt-5 hr_set_5">
				                          	
				                              '.$hr_list_5.'
				                            </select>
				                          </div>
				                        </td>
						         
						            
                              
			';
		echo json_encode($data_response);
	}
	public function get_week_between($coures_id_list_val){
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 		
					WHERE DataID=$coures_id_list_val	
							";
		$this->select();
		$this->setRows();
		$class_level=$this->rows[0]['class_level'];
		if ($class_level=='p1' || $class_level=='p2' || $class_level=='p3' || $class_level=='p4' || $class_level=='p5' || $class_level=='p6') {
			$data_response='
							<option value="1-10">สัปดาห์ที่ 1-10</option>
                             <option value="11-20">สัปดาห์ที่ 11-20</option>    
                             <option value="21-31">สัปดาห์ที่ 21-31</option>   
                             <option value="31-40">สัปดาห์ที่ 31-40</option>  
			';
		}else{
			$data_response='
							<option value="1-10">สัปดาห์ที่ 1-10</option>
                             <option value="11-20">สัปดาห์ที่ 11-20</option>    
			';
		}
		echo json_encode($data_response);
	}
	public function get_count_adttend_class_val($coures_id_list_val){
		$this->sql ="SELECT  *
					FROM tbl_set_term_year 			
							";
		$this->select();
		$this->setRows();
		$term_set=$this->rows[0]['term'];
		$year_set=$this->rows[0]['year'];
		$class_level=$this->rows[0]['class_level'];
		if ($class_level=='p1' || $class_level=='p2' || $class_level=='p3' || $class_level=='p4' || $class_level=='p5' || $class_level=='p6') {
			$term_set='1,2';
		}
		$registed_courseID=$this->get_registed_courseID($coures_id_list_val,$term_set,$year_set);
		$this->sql ="SELECT  *
					FROM tbl_set_count_adttend_class
					WHERE registed_courseID=$registed_courseID		
							";
		$this->select();
		$this->setRows();
		$week_name=$this->rows[0]['week_name'];
		echo json_encode($week_name);
	}
	/*public function set_count_adttend_class_val($coures_id_list_val,$set_count_adttend_class_val){
		$this->sql ="SELECT  *
					FROM tbl_set_term_year 			
							";
		$this->select();
		$this->setRows();
		$term_set=$this->rows[0]['term'];
		$year_set=$this->rows[0]['year'];
		$class_level=$this->rows[0]['class_level'];
		if ($class_level=='p1' || $class_level=='p2' || $class_level=='p3' || $class_level=='p4' || $class_level=='p5' || $class_level=='p6') {
			$term_set='1,2';
		}

		$registed_courseID=$this->get_registed_courseID($coures_id_list_val,$term_set,$year_set);
		$this->sql ="SELECT  COUNT(*) as num_row
					FROM tbl_set_count_adttend_class 	
					WHERE registed_courseID	=$registed_courseID	
							";
		$this->select();
		$this->setRows();
		$num_row=$this->rows[0]['num_row'];
		if ($num_row>0) {
			$this->sql ="UPDATE tbl_set_count_adttend_class SET week_name=$set_count_adttend_class_val WHERE registed_courseID=$registed_courseID
							";
			$this->query();
		}else{
			$this->sql ="INSERT INTO tbl_set_count_adttend_class(registed_courseID,week_name) VALUES($registed_courseID,$set_count_adttend_class_val)		
							";
			$this->query();
		}
		

	}*/
	public function chk_value_attend_1($score_status){
		if ($score_status=="1") {
			$data_response="selected";
		}
		return $data_response;
	}
	public function chk_value_attend_l($score_status){
		if ($score_status=="ล") {
			$data_response="selected";
		}
		return $data_response;
	}
	public function chk_value_attend_p($score_status){
		if ($score_status=="ป") {
			$data_response="selected";
		}
		return $data_response;
	}
	public function chk_value_attend_k($score_status){
		if ($score_status=="ข") {
			$data_response="selected";
		}
		return $data_response;
	}
	public function chk_value_attend_n($score_status){
		if ($score_status=="น") {
			$data_response="selected";
		}
		return $data_response;
	}
	public function chk_value_attend__($score_status){
		if ($score_status=="0" || $score_status=="-") {
			$data_response="selected";
		}
		return $data_response;
	}
	public function get_score_col($std_ID,$registed_courseID,$start_data,$end_data){

		$this->sql ="SELECT  *
					FROM tbl_course_teaching_std 	
					WHERE registed_courseID=$registed_courseID
					AND stdID='$std_ID'
					";
			$this->select();
			$this->setRows();	
			$course_teaching_stdID=$this->rows[0]['DataID'];	
		$this->sql ="SELECT  *
					FROM tbl_attend_class 	
					WHERE course_teaching_stdID=$course_teaching_stdID		
					AND week BETWEEN $start_data AND $end_data	
					ORDER BY week ASC 	
					";
			$this->select();
			$this->setRows();	
			foreach($this->rows as $key => $value) {					
				$attendID=$value['DataID'];
				$week=$value['week'];
				$score_status=$value['score_status'];	
				$data_response['score_col'].='
								<td class="relative">
		                          <select name="attend_score_std[]" class="select-table-form class_col_set_new class_col_attend_1 value_attend_week_1">
		                            <option value="1" selected="">1</option>
		                            <option value="ล">ล</option>
		                            <option value="ป">ป</option>
		                            <option value="ข">ข</option>		                            
		                            <option value="-">-</option>
		                          </select>
		                        </td>
				'; 	
				
			}
			
			return $data_response;
	}	

	public function get_score_col_total($std_ID,$registed_courseID,$start_data,$end_data,$num_row_std,$no_std){
		$this->sql ="SELECT  *
					FROM tbl_course_teaching_std 	
					WHERE registed_courseID=$registed_courseID
					AND stdID='$std_ID'
					";
		$this->select();
		$this->setRows();
		$course_teaching_stdID=$this->rows[0]['DataID'];
		$this->sql ="SELECT  SUM(score_status) as sum_score_status
					FROM tbl_attend_class 	
					WHERE course_teaching_stdID=$course_teaching_stdID		
					AND week BETWEEN $start_data AND $end_data	
					ORDER BY week ASC 	
					";
		$this->select();
		$this->setRows();
		return $this->rows[0]['sum_score_status'];

	}
	public function get_all_attendID($std_ID,$registed_courseID,$start_data,$end_data,$num_row_std,$no_std){
		$this->sql ="SELECT  *
					FROM tbl_course_teaching_std 	
					WHERE registed_courseID=$registed_courseID
					AND stdID='$std_ID'
					";
			$this->select();
			$this->setRows();	
			$course_teaching_stdID=$this->rows[0]['DataID'];	
			$this->sql ="SELECT  count(*) as num_attend_row
					FROM tbl_attend_class 	
					WHERE course_teaching_stdID=$course_teaching_stdID		
					AND week BETWEEN $start_data AND $end_data	
					ORDER BY week ASC 	
					";
			$this->select();
			$this->setRows();	
			$num_attend_row=$this->rows[0]['num_attend_row'];	
			$this->sql ="SELECT  *
					FROM tbl_attend_class 	
					WHERE course_teaching_stdID=$course_teaching_stdID		
					AND week BETWEEN $start_data AND $end_data	
					ORDER BY week ASC 	
					";
			$this->select();
			$this->setRows();	
			$num_set=1;
			foreach($this->rows as $key => $value) {
				if ($num_row_std==$no_std) {
					if ($num_set==$num_attend_row) {
						$attendID.=$value['DataID'];
					}else{
						$attendID.=$value['DataID'].'-';
					}
				}else{
					$attendID.=$value['DataID'].'-';
				}
				
				$num_set++;
			}
			return $attendID;
	}
	
	public function get_detail_std_admin($coures_id_list_val,$room_search,$registed_course_teaching_id,$length_list_val,$term_set,$year_set){

		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 	
					WHERE DataID=$coures_id_list_val					
					";
		$this->select();
		$this->setRows();
		$class_level=$this->rows[0]['class_level'];
		$status=$this->rows[0]['status'];
		$status_form=$this->rows[0]['status_form'];
		if ($class_level=='p1' || $class_level=='p2' || $class_level=='p3' || $class_level=='p4' || $class_level=='p5' || $class_level=='p6') {
			$term_set='1,2';
		}
		$registed_courseID=$this->get_registed_courseID($coures_id_list_val,$term_set,$year_set);
		if ($status==1) {
			$sql_condition="
							AND tbl_std_class_room.room='$room_search'
				                    AND tbl_std_class_room.status=1 
				                    AND tbl_std_class_room.year='$year_set'
									AND";
			$sql_condition_count="WHERE tbl_student.std_ID in(
								SELECT std_ID
								FROM tbl_std_class_room
								WHERE room='$room_search'
								AND status=1 
								AND year='$year_set'
							) 
							AND";
		}else{
			if($status_form==25 || $status_form==26 || $status_form==27){
				$sql_condition="
							AND tbl_std_class_room.room='$room_search'
				                    AND tbl_std_class_room.status=1 
				                    AND tbl_std_class_room.year='$year_set'
									AND";
				$sql_condition_count="WHERE tbl_student.std_ID in(
									SELECT std_ID
									FROM tbl_std_class_room
									WHERE room='$room_search'
									AND status=1 
									AND year='$year_set'
								) 
								AND";
			}else{
				$sql_condition="
							
				                    AND tbl_std_class_room.status=1 
				                    AND tbl_std_class_room.year='$year_set'
									AND
					";
				$sql_condition_count="WHERE tbl_student.std_ID in(
									SELECT std_ID
									FROM tbl_std_class_room
									WHERE status=1 
									AND year='$year_set'
								) 
								AND
					";
			}
				
		}
		
		$this->sql ="SELECT  COUNT(*) as num_row_std
					FROM tbl_student 
					$sql_condition_count
					std_ID IN(
						SELECT stdID
						FROM tbl_course_teaching_std
						WHERE registed_courseID=$registed_courseID	
											
					)
				
					";
		$this->select();
		$this->setRows();
		$num_row_std=$this->rows[0]['num_row_std'];
		$this->sql ="SELECT  tbl_student.std_ID,tbl_student.fname,tbl_student.lname,tbl_student.name_title,tbl_std_class_room.room
					FROM tbl_student,tbl_std_class_room 
					WHERE tbl_student.std_ID=tbl_std_class_room.std_ID
					$sql_condition
					tbl_student.std_ID IN(
						SELECT stdID
						FROM tbl_course_teaching_std
						WHERE registed_courseID=$registed_courseID						
					)
					ORDER BY tbl_std_class_room.class_level,tbl_std_class_room.room,
					CASE
						WHEN name_title LIKE '%dekchai%' THEN 0
				        WHEN name_title LIKE '%nai%' THEN 1
				        WHEN name_title LIKE '%dekying%' THEN 2
				        WHEN name_title LIKE '%nangsaw%'THEN 3
				        WHEN tbl_student.std_ID THEN 4      
				    END
					";
		$this->select();
		$this->setRows();
		$no_std=1;
		foreach($this->rows as $key => $value) {
			$std_ID=$value['std_ID'];
			$fname=$value['fname'];
			$lname=$value['lname'];
			$name_title_data=$value['name_title'];
			$room=$value['room'];
			$name_title=$this->get_name_title($name_title_data);

			$class_level_status=$this->get_class_level_status($coures_id_list_val);
			if ($class_level_status=='p') {
				$term_set='1,2';
			}
			$attend_data=$this->get_attend_data($registed_course_teaching_id,$std_ID,$registed_courseID,$length_list_val,$class_level_status,$status,$status_form,$room_search);
			
			if($status==1){
				$data_response['detail_std'].='<tr>
										<td>'.$no_std.'</td>
										<td>'.$std_ID.'</td>
						                <td style="text-align:left;padding-left:7%;">'.$name_title.$fname.' '.$lname.'</td>	

						                '.$attend_data.'
						             </tr>
			';	
			}elseif($status==2){
				if($status_form==25 || $status_form==26 || $status_form==27){
					$data_response['detail_std'].='<tr>
										<td>'.$no_std.'</td>
										<td>'.$std_ID.'</td>
						                <td style="text-align:left;padding-left:7%;">'.$name_title.$fname.' '.$lname.'</td>	

						                '.$attend_data.'
						             </tr>
				';	
				}else{
					$data_response['detail_std'].='<tr>
										<td>'.$no_std.'</td>
										<td>'.$std_ID.'</td>
										<td>'.$room.'</td>	
						                <td style="text-align:left;padding-left:7%;">'.$name_title.$fname.' '.$lname.'</td>	

						                '.$attend_data.'
						             </tr>
			';	
				}
				
			}
			
			$no_std++;		
		}
		$data_response['all_attendID'].=$all_attendID;

		$this->sql ="SELECT  SUM(hr) as num_hr
					FROM tbl_set_attend_day 						
					WHERE registed_course_teachingID=$registed_course_teaching_id
					AND room='$room_search'
					";
		$this->select();
		$this->setRows();
		$num_hr=$this->rows[0]['num_hr'];
		$class_level_status=$this->get_class_level_status($coures_id_list_val);
		if ($class_level_status=='p') {
			$week_all=40;
		}else{
			$week_all=20;
		}
		$data_response['num_day']=($num_hr)*$week_all;	

		return $data_response;
	}
	public function get_detail_std($coures_id_list_val,$room_search,$registed_course_teaching_id,$length_list_val){
		$this->sql ="SELECT  *
					FROM tbl_set_term_year 			
							";
		$this->select();
		$this->setRows();
		$term_set=$this->rows[0]['term'];
		$year_set=$this->rows[0]['year'];
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 	
					WHERE DataID=$coures_id_list_val					
					";
		$this->select();
		$this->setRows();
		$class_level=$this->rows[0]['class_level'];
		$status=$this->rows[0]['status'];
		$status_form=$this->rows[0]['status_form'];
		if ($class_level=='p1' || $class_level=='p2' || $class_level=='p3' || $class_level=='p4' || $class_level=='p5' || $class_level=='p6') {
			$term_set='1,2';
		}
		$registed_courseID=$this->get_registed_courseID($coures_id_list_val,$term_set,$year_set);
		if ($status==1) {
			$sql_condition="
							AND tbl_std_class_room.room='$room_search'
				                    AND tbl_std_class_room.status=1 
				                    AND tbl_std_class_room.year='$year_set'
									AND";
			$sql_condition_count="WHERE tbl_student.std_ID in(
								SELECT std_ID
								FROM tbl_std_class_room
								WHERE room='$room_search'
								AND status=1 
								AND year='$year_set'
							) 
							AND";
		}else{
			if($status_form==25 || $status_form==26 || $status_form==27){
				$sql_condition="
							AND tbl_std_class_room.room='$room_search'
				                    AND tbl_std_class_room.status=1 
				                    AND tbl_std_class_room.year='$year_set'
									AND";
				$sql_condition_count="WHERE tbl_student.std_ID in(
									SELECT std_ID
									FROM tbl_std_class_room
									WHERE room='$room_search'
									AND status=1 
									AND year='$year_set'
								) 
								AND";
			}else{
				$sql_condition="
							
				                    AND tbl_std_class_room.status=1 
				                    AND tbl_std_class_room.year='$year_set'
									AND
					";
				$sql_condition_count="WHERE tbl_student.std_ID in(
									SELECT std_ID
									FROM tbl_std_class_room
									WHERE status=1 
									AND year='$year_set'
								) 
								AND
					";
			}
				
		}
		
		$this->sql ="SELECT  COUNT(*) as num_row_std
					FROM tbl_student 
					$sql_condition_count
					std_ID IN(
						SELECT stdID
						FROM tbl_course_teaching_std
						WHERE registed_courseID=$registed_courseID	
											
					)
				
					";
		$this->select();
		$this->setRows();
		$num_row_std=$this->rows[0]['num_row_std'];
		$this->sql ="SELECT  tbl_student.std_ID,tbl_student.fname,tbl_student.lname,tbl_student.name_title,tbl_std_class_room.room
					FROM tbl_student,tbl_std_class_room 
					WHERE tbl_student.std_ID=tbl_std_class_room.std_ID
					$sql_condition
					tbl_student.std_ID IN(
						SELECT stdID
						FROM tbl_course_teaching_std
						WHERE registed_courseID=$registed_courseID						
					)
					ORDER BY tbl_std_class_room.room ASC,
					CASE
						WHEN name_title LIKE '%dekchai%' THEN 0
				        WHEN name_title LIKE '%nai%' THEN 1
				        WHEN name_title LIKE '%dekying%' THEN 2
				        WHEN name_title LIKE '%nangsaw%'THEN 3
				        WHEN tbl_student.std_ID THEN 4      
				    END
					";
		$this->select();
		$this->setRows();
		$no_std=1;
		foreach($this->rows as $key => $value) {
			$std_ID=$value['std_ID'];
			$fname=$value['fname'];
			$lname=$value['lname'];
			$name_title_data=$value['name_title'];
			$room=$value['room'];
			$name_title=$this->get_name_title($name_title_data);

			$class_level_status=$this->get_class_level_status($coures_id_list_val);
			if ($class_level_status=='p') {
				$term_set='1,2';
			}
			$attend_data=$this->get_attend_data($registed_course_teaching_id,$std_ID,$registed_courseID,$length_list_val,$class_level_status,$status,$status_form,$room_search);
			
			if($status==1){
				$data_response['detail_std'].='<tr>
										<td>'.$no_std.'</td>
										<td>'.$std_ID.'</td>
						                <td style="text-align:left;padding-left:7%;">'.$name_title.$fname.' '.$lname.'</td>	

						                '.$attend_data.'
						             </tr>
			';	
			}elseif($status==2){
				if($status_form==25 || $status_form==26 || $status_form==27){
					$data_response['detail_std'].='<tr>
										<td>'.$no_std.'</td>
										<td>'.$std_ID.'</td>
						                <td style="text-align:left;padding-left:7%;">'.$name_title.$fname.' '.$lname.'</td>	

						                '.$attend_data.'
						             </tr>
				';	
				}else{
					$data_response['detail_std'].='<tr>
										<td>'.$no_std.'</td>
										<td>'.$std_ID.'</td>
										<td>'.$room.'</td>	
						                <td style="text-align:left;padding-left:7%;">'.$name_title.$fname.' '.$lname.'</td>	

						                '.$attend_data.'
						             </tr>
			';	
				}
				
			}
			
			$no_std++;		
		}
		$data_response['all_attendID'].=$all_attendID;

		$this->sql ="SELECT  SUM(hr) as num_hr
					FROM tbl_set_attend_day 						
					WHERE registed_course_teachingID=$registed_course_teaching_id
					AND room='$room_search'
					";
		$this->select();
		$this->setRows();
		$num_hr=$this->rows[0]['num_hr'];
		$class_level_status=$this->get_class_level_status($coures_id_list_val);
		if ($class_level_status=='p') {
			$week_all=40;
		}else{
			$week_all=20;
		}
		$data_response['num_day']=($num_hr)*$week_all;	

		return $data_response;
	}
	public function get_name_title($name_title_data){
		if ($name_title_data=="dekchai") {
			$name_title="เด็กชาย";
		}elseif($name_title_data=="dekying"){
			$name_title="เด็กหญิง";
		}elseif($name_title_data=="nai"){
			$name_title="นาย";
		}elseif($name_title_data=="nangsaw"){
			$name_title="นางสาว";
		}
		return $name_title;
	}
	
	public function add_attend($value_loop,$course_teaching_stdID,$set_attend_day_id,$length_list_val,$attend_value_1,$attend_value_2,$attend_value_3){
		$this->sql ="DELETE FROM tbl_attend_class_std WHERE set_attend_day_id=$set_attend_day_id AND course_teaching_std_id=$course_teaching_stdID AND week=$length_list_val
				";
		$this->query();
		if ($value_loop==3) {
			$this->sql ="INSERT INTO tbl_attend_class_std(course_teaching_std_id,set_attend_day_id,week,status) 
						VALUES($course_teaching_stdID,$set_attend_day_id,$length_list_val,'$attend_value_1');
				";
			$this->query();
			$this->sql ="INSERT INTO tbl_attend_class_std(course_teaching_std_id,set_attend_day_id,week,status) 
						VALUES($course_teaching_stdID,$set_attend_day_id,$length_list_val,'$attend_value_2');
				";
			$this->query();
			$this->sql ="INSERT INTO tbl_attend_class_std(course_teaching_std_id,set_attend_day_id,week,status) 
						VALUES($course_teaching_stdID,$set_attend_day_id,$length_list_val,'$attend_value_3');
				";
			$this->query();
		}elseif($value_loop==2){
			$this->sql ="INSERT INTO tbl_attend_class_std(course_teaching_std_id,set_attend_day_id,week,status) 
						VALUES($course_teaching_stdID,$set_attend_day_id,$length_list_val,'$attend_value_1');
				";
			$this->query();
			$this->sql ="INSERT INTO tbl_attend_class_std(course_teaching_std_id,set_attend_day_id,week,status) 
						VALUES($course_teaching_stdID,$set_attend_day_id,$length_list_val,'$attend_value_2');
				";
			$this->query();
		}
		elseif($value_loop==1){
			$this->sql ="INSERT INTO tbl_attend_class_std(course_teaching_std_id,set_attend_day_id,week,status) 
						VALUES($course_teaching_stdID,$set_attend_day_id,$length_list_val,'$attend_value_1');
				";
			$this->query();
		}
		echo json_encode("1");
	}
	public function insert_value_in_attend($registed_course_id,$value,$week,$set_attend_day_id,$course_teaching_stdID,$attend_class_week_listID){
		$this->sql ="SELECT  *
				FROM tbl_set_attend_day 	
				WHERE registed_course_teachingID=$registed_course_id
				AND attend_class_week_listID=$attend_class_week_listID
				";
		$this->select();
		$this->setRows();	
		$hr=$this->rows[0]['hr'];	
		if ($hr==$value) {
			$this->sql ="DELETE FROM tbl_attend_class_std WHERE set_attend_day_id=$set_attend_day_id AND course_teaching_std_id=$course_teaching_stdID AND week=$week
				";
			$this->query();
			$data_response['status']='deleted';
		}else{
			$data_response['status']='no';
			$value_loop=$hr-$value;
			
			if ($value_loop==3) {
				$data_response['place']='
							<select style="width:75px;" class="form-control search-drop-length-ob mt-5 attend_value_1">                            
							   	<option value="ล">ลา</option>
		                      	<option value="ป">ป่วย</option>
		                        <option value="ข">ขาด</option>		
		                        <option value="น">หนี</option>  		
                            </select>
                            <select style="width:75px;" class="form-control search-drop-length-ob mt-5 attend_value_2">                            
							   	<option value="ล">ลา</option>
		                      	<option value="ป">ป่วย</option>
		                        <option value="ข">ขาด</option>		
		                        <option value="น">หนี</option>  		
                            </select>
                            <select  style="width:75px;" class="form-control search-drop-length-ob mt-5 attend_value_3">                            
							   	<option value="ล">ลา</option>
		                      	<option value="ป">ป่วย</option>
		                        <option value="ข">ขาด</option>		
		                        <option value="น">หนี</option>  		
                            </select>
                            <input hidden value="'.$value_loop.'" id="value_loop" type="text" >
                            <input hidden value="'.$course_teaching_stdID.'" id="course_teaching_stdID" type="text" >
                            <input hidden value="'.$set_attend_day_id.'" id="set_attend_day_id" type="text" >

			';
			}elseif ($value_loop==2) {
				$data_response['place']='
							<select  style="width:75px;" class="form-control search-drop-length-ob mt-5 attend_value_1">                            
							   	<option value="ล">ลา</option>
		                      	<option value="ป">ป่วย</option>
		                        <option value="ข">ขาด</option>		
		                        <option value="น">หนี</option>  		
                            </select>
                            <select  style="width:75px;" class="form-control search-drop-length-ob mt-5 attend_value_2">                            
							   	<option value="ล">ลา</option>
		                      	<option value="ป">ป่วย</option>
		                        <option value="ข">ขาด</option>		
		                        <option value="น">หนี</option>  		
                            </select>
                           <input hidden value="'.$value_loop.'" id="value_loop" type="text" >
                           <input hidden value="'.$course_teaching_stdID.'" id="course_teaching_stdID" type="text" >
                           <input hidden value="'.$set_attend_day_id.'" id="set_attend_day_id" type="text" >
			';
			}elseif ($value_loop==1) {
				$data_response['place']='
							<select  style="width:75px;" class="form-control search-drop-length-ob mt-5 attend_value_1">                            
							   	<option value="ล">ลา</option>
		                      	<option value="ป">ป่วย</option>
		                        <option value="ข">ขาด</option>		
		                        <option value="น">หนี</option>  		
                            </select>
                          	<input hidden value="'.$value_loop.'" id="value_loop">
                          	<input hidden value="'.$course_teaching_stdID.'" id="course_teaching_stdID" type="text" >
                          	<input hidden value="'.$set_attend_day_id.'" id="set_attend_day_id" type="text" >
			';
			}
			
		}
		echo json_encode($data_response);
	}
	public function get_attend_data($registed_course_teaching_id,$std_ID,$registed_courseID,$length_list_val,$class_level_status,$status_class,$status_form,$room_search){
		$this->sql ="SELECT  *
				FROM tbl_course_teaching_std 	
				WHERE registed_courseID=$registed_courseID
				AND stdID='$std_ID'
				";
		$this->select();
		$this->setRows();	
		$course_teaching_stdID=$this->rows[0]['DataID'];	
		if ($status_class==1) {
			$sql_condition="AND room='$room_search'";
		}else{
			if ($status_form==25 || $status_form==26 || $status_form==27) {
				$sql_condition="AND room='$room_search'";
			}else{
				$sql_condition="";
			}
			
		}
		$this->sql ="SELECT  *
					FROM tbl_set_attend_day 	
					WHERE registed_course_teachingID=$registed_course_teaching_id
					$sql_condition
					ORDER BY attend_class_week_listID ASC
					";
		$this->select();
		$this->setRows();		

		foreach($this->rows as $key => $value) {
			$DataID=$value['DataID'];
			$hr=$value['hr'];
			$attend_class_week_listID=$value['attend_class_week_listID'];
			$attend_class_std=$this->get_attend_class_std($DataID,$std_ID,$registed_courseID,$length_list_val);
			$data_list='';
			if ($attend_class_std['num_row']>0) {	
				$num_row=$attend_class_std['num_row'];
				$total_att=$hr-$num_row;
				for ($i=$hr; $i >=0 ; $i--) {
					if ($i==$total_att) {
					 	$data_list.='<option selected value="'.$i.'">'.$i.'</option> ';
					 }else{
					 	$data_list.='<option value="'.$i.'">'.$i.'</option> ';
					 }			                            		                          
				}
				$data_response.='
								<td class="relative">
		                          <select onchange="insert_value_in_attend(this.value,'.$length_list_val.','.$DataID.','.$course_teaching_stdID.','.$attend_class_week_listID.')" class="select-table-form class_col_set_new ">	                                                       
		                           '.$data_list.'
		                          </select>
		                        </td>
			';
			
			}else{
				for ($i=$hr; $i >=0 ; $i--) { 
					$data_list.='<option value="'.$i.'">'.$i.'</option> ';	                            		                          
				}
				$data_response.='
								<td class="relative">
		                          <select onchange="insert_value_in_attend(this.value,'.$length_list_val.','.$DataID.','.$course_teaching_stdID.','.$attend_class_week_listID.')" class="select-table-form class_col_set_new ">
		                            '.$data_list.'
		                            	                                                 	                            
		                          </select>
		                        </td>
			';
			}


		}
		$this->sql ="SELECT  COUNT(*) as num_no_class
					FROM tbl_attend_class_std 	
					WHERE course_teaching_std_id=$course_teaching_stdID
					";
		$this->select();
		$this->setRows();
		$num_no_class=$this->rows[0]['num_no_class'];

		$this->sql ="SELECT  SUM(hr) as num_hr
					FROM tbl_set_attend_day 	
					WHERE registed_course_teachingID=$registed_course_teaching_id
					AND room='$room_search'
					";
		$this->select();
		$this->setRows();
		$num_hr=$this->rows[0]['num_hr'];	
		if ($class_level_status=='p') {
			$week_all=40;
		}else{
			$week_all=20;
		}
		$total_day=$num_hr*$week_all;

		$total_attend=$total_day-$num_no_class;
		$data_response.='
			<td class="relative">
				'.$total_attend.'
			</td>
		';

		$total_attend_per=round((($total_day-$num_no_class)*100)/$total_day);
		$data_response.='
			<td class="relative">
				'.$total_attend_per.'
			</td>
		';
		return $data_response;	
	}
	public function get_attend_class_std($set_attend_day_id,$std_ID,$registed_courseID,$length_list_val){
		$data_response = array();
		$this->sql ="SELECT  COUNT(*) as num_row
					FROM tbl_attend_class_std 	
					WHERE set_attend_day_id=$set_attend_day_id
					AND week=$length_list_val
					AND course_teaching_std_id IN(
						SELECT DataID
						FROM tbl_course_teaching_std
						WHERE registed_courseID=$registed_courseID
						AND stdID='$std_ID'
					)
					";
		$this->select();
		$this->setRows();	
		$data_response['num_row']=$this->rows[0]['num_row'];
		return $data_response;	
	}
	public function get_class_level_status($coures_id_list_val){
		$data_response = array();	
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 	
					WHERE DataID=$coures_id_list_val
					";
		$this->select();
		$this->setRows();		
		$class_level=$this->rows[0]['class_level'];	
		if ($class_level=='p1' || $class_level=='p2' || $class_level=='p3' || $class_level=='p4' || $class_level=='p5' || $class_level=='p6') {
			$data='p';
		}else{
			$data='m';
		}
		return $data;
	}
	public function get_registed_courseID($coures_id_list_val,$term_set,$year_set){
		$data_response = array();	
		$this->sql ="SELECT  *
					FROM tbl_registed_course 	
					WHERE courseID=$coures_id_list_val
					AND term='$term_set'
					AND year='$year_set'

					";
		$this->select();
		$this->setRows();		
		return $this->rows[0]['DataID'];	
	}
	
	public function get_std_id_all($coures_id_list_val,$room_search){
		$this->sql ="SELECT  count(*) as num_row_std
					FROM tbl_student 
					WHERE stdID in(
							SELECT std_ID
							FROM tbl_std_class_room
							WHERE room='$room_search'
							AND year='$year_set'
					) 
					AND std_ID in(
						SELECT stdID
						FROM tbl_course_teaching_std
						WHERE registed_courseID in(
							SELECT DataID
							FROM tbl_registed_course
							WHERE courseID=$coures_id_list_val
						)
					)
					";
		$this->select();
		$this->setRows();	
		$num_row_std=$this->rows[0]['num_row_std'];	
		$this->sql ="SELECT *
					FROM tbl_student 
					WHERE stdID in(
							SELECT std_ID
							FROM tbl_std_class_room
							WHERE room='$room_search'
							AND year='$year_set'
					) 
					AND std_ID in(
						SELECT stdID
						FROM tbl_course_teaching_std
						WHERE registed_courseID in(
							SELECT DataID
							FROM tbl_registed_course
							WHERE courseID=$coures_id_list_val
						)
					)
					";
		$this->select();
		$this->setRows();
		$no_std=1;
		foreach($this->rows as $key => $value) {

			$std_ID=$value['std_ID'];		
			if ($num_row_std==$no_std) {
				$std_id_all.=$std_ID;
			}else{
				$std_id_all.=$std_ID.'-';
			}
			
			$no_std++;
			
		}
		$data_response=$std_id_all;
		return $data_response;
	}
	public function get_week_list_data_admin($coures_id_list_val,$length_list_val,$room_search,$registed_course_teaching_id,$term_data,$year_data){
		$data_response = array();		
	/*	list($start_data, $end_data) = split('[-]', $length_list_val);
		$find_start=$start_data-1;
		$find_end=$end_data-$find_start;*/
		
		$detail_std=$this->get_detail_std_admin($coures_id_list_val,$room_search,$registed_course_teaching_id,$length_list_val,$term_data,$year_data);
		$data_response['detail_std']=$detail_std['detail_std'];
		$data_response['all_attendID']=$detail_std['all_attendID'];
		$data_response['num_day']=$detail_std['num_day'];
		
		//$data_response['std_id_all']=$this->get_std_id_all($coures_id_list_val,$room_search);
		//$data_response['std_id_all']=$this->get_std_id_all($coures_id_list_val,$room_search);
		$data_response['data_objectiveID_of_title']=$data_objective;
		return json_encode($data_response);
	}
	public function get_week_list_data($coures_id_list_val,$length_list_val,$room_search,$registed_course_teaching_id){
		$data_response = array();		
	/*	list($start_data, $end_data) = split('[-]', $length_list_val);
		$find_start=$start_data-1;
		$find_end=$end_data-$find_start;*/
		
		$detail_std=$this->get_detail_std($coures_id_list_val,$room_search,$registed_course_teaching_id,$length_list_val);
		$data_response['detail_std']=$detail_std['detail_std'];
		$data_response['all_attendID']=$detail_std['all_attendID'];
		$data_response['num_day']=$detail_std['num_day'];
		
		//$data_response['std_id_all']=$this->get_std_id_all($coures_id_list_val,$room_search);
		//$data_response['std_id_all']=$this->get_std_id_all($coures_id_list_val,$room_search);
		$data_response['data_objectiveID_of_title']=$data_objective;
		return json_encode($data_response);
	}

	public function get_registed_course_id($coures_id_list,$term_set,$year_set){
		if ($term_set=='' && $year_set=='') {
			$this->sql ="SELECT  *
					FROM tbl_set_term_year 			
							";
			$this->select();
			$this->setRows();
			$term_set=$this->rows[0]['term'];
			$year_set=$this->rows[0]['year'];
		}
		
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 	
					WHERE DataID=$coures_id_list
					/*AND DataID in(
                    	SELECT courseID
                        FROM tbl_registed_course 
                        WHERE term='$term_set'  
                        OR term='1,2'
                        AND year='$year_set'
                         AND DataID IN(
                            SELECT registed_courseID
                        	FROM tbl_registed_course_teaching
                        )
                    )*/
					";
		$this->select();
		$this->setRows();		
		$class_level_data=$this->rows[0]['class_level'];	
		$status=$this->rows[0]['status'];
		if ($class_level_data=='p1' || $class_level_data=='p2' || $class_level_data=='p3' || $class_level_data=='p4' || $class_level_data=='p5' || $class_level_data=='p6' ) {
			$term_set='1,2';
		}

		$this->sql ="SELECT  *
					FROM tbl_registed_course_teaching 	
					WHERE registed_courseID in(
						SELECT DataID
						FROM tbl_registed_course 
						WHERE term='$term_set'
						AND year='$year_set'
						AND courseID=$coures_id_list
					)
					";
		$this->select();
		$this->setRows();
		return $this->rows[0]['DataID'];	
	}
	public function search_course_detail($coures_id_list,$room_search,$term_data,$year_data){		
		$data_response = array();	
		$data_response['registed_course_id']=$this->get_registed_course_id($coures_id_list,$term_data,$year_data);
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 	
					WHERE DataID=$coures_id_list
					";
		$this->select();
		$this->setRows();		
		$data_response['courseID']=$this->rows[0]['courseID'];	
		$data_response['name']=$this->rows[0]['name'];	
		$data_response['hr_learn']=$this->rows[0]['hr_learn'];	
		$data_response['status']=$this->rows[0]['status'];	
		$class_level_data=$this->rows[0]['class_level'];
		$data_response['status_form']=$this->rows[0]['status_form'];	
		$status=$this->rows[0]['status'];
		if ($status==2) {
			$data_response['unit']='-';	
		}else{
			$data_response['unit']=$this->rows[0]['unit'];	
		}
		$status_form=$this->rows[0]['status_form'];
		$class_level=$this->get_class_level_new($class_level_data);
		if ($status==1) {
			$data_response['class_level_co']=$class_level.'/'.$room_search;
		}elseif($status==2){
			if ($status_form==25 || $status_form==26 || $status_form==27) {
				$data_response['class_level_co']=$class_level.'/'.$room_search;
			}else{
				$data_response['class_level_co']=$class_level;
			}
			
		}
		
		if ($class_level_data=='p1' || $class_level_data=='p2' || $class_level_data=='p3' || $class_level_data=='p4' || $class_level_data=='p5' || $class_level_data=='p6') {
			for ($i=1; $i <=40 ; $i++) { 
				$data_response['week_menu_data'].='
						<option value="'.$i.'">สัปดาห์ที่ '.$i.'</option>                         
			';
			}
			
		}else{
			for ($i=1; $i <=20 ; $i++) { 
				$data_response['week_menu_data'].='
						<option value="'.$i.'">สัปดาห์ที่ '.$i.'</option>                         
			';
			}
		}
		

		echo json_encode($data_response);
	}
	public function get_class_level_admin($coures_id_list_val,$term_set,$year_set){
		
		$data_response = array();	
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 	
					WHERE DataID=$coures_id_list_val				
					";
		$this->select();
		$this->setRows();		
		$class_level_data=$this->rows[0]['class_level'];	
		$data_response['status']=$this->rows[0]['status'];
		$data_response['status_form']=$this->rows[0]['status_form'];
		$data_response['class_level']=$this->get_class_level_new($class_level_data);
		if ($class_level_data=='p1' || $class_level_data=='p2' || $class_level_data=='p3' || $class_level_data=='p4' || $class_level_data=='p5' || $class_level_data=='p6') {
			$term_set='1,2';
		}
		$user_status=$_SESSION['ss_status'];
		$user_id=$_SESSION['ss_user_id'];
		if ($user_status==1) {
			$this->sql ="SELECT  room
					FROM tbl_room_teacher 
					WHERE course_teacherID in(
						SELECT DataID
						FROM tbl_course_teacher
						WHERE teacher_id=$user_id
						AND regis_course_id in(
							SELECT DataID
							FROM tbl_registed_course
							WHERE courseID=$coures_id_list_val
                            AND term='$term_set'
                            AND year='$year_set'
						)
						
					)	
					ORDER BY room ASC
						";
		}else{
			$this->sql ="
						SELECT distinct room
						FROM tbl_std_class_room
						WHERE std_ID in(
							SELECT std_ID
							FROM tbl_student 
							WHERE std_ID in(
								SELECT stdID
								FROM tbl_course_teaching_std
								WHERE registed_courseID in(
									SELECT DataID
									FROM tbl_registed_course
									WHERE courseID=$coures_id_list_val
	                                AND term='$term_set'
	                                AND year='$year_set'
									)
							)
						)
						ORDER BY room ASC
							";
		}
		
			$this->select();
			$this->setRows();
			foreach($this->rows as $key => $value) {
				$room=$value['room'];
				$chk_room_export=$this->get_chk_room_export_teacher($room,$term_set,$year_set,$coures_id_list_val,$user_status);
				if ($user_status==2) {
					if ($chk_room_export>0) {
						$data_response['room'].=' <option>'.$room.'</option>';
					}
				}else{
					if ($chk_room_export==0) {
						$data_response['room'].=' <option>'.$room.'</option>';
					}
				}
				
			}
		
		return json_encode($data_response);
	}
	public function get_class_level($coures_id_list_val){
		$this->sql ="SELECT  *
					FROM tbl_set_term_year 			
							";
		$this->select();
		$this->setRows();
		$term_set=$this->rows[0]['term'];
		$year_set=$this->rows[0]['year'];
		$data_response = array();	
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 	
					WHERE DataID=$coures_id_list_val				
					";
		$this->select();
		$this->setRows();		
		$class_level_data=$this->rows[0]['class_level'];	
		$data_response['status']=$this->rows[0]['status'];
		$data_response['status_form']=$this->rows[0]['status_form'];
		$data_response['class_level']=$this->get_class_level_new($class_level_data);
		if ($class_level_data=='p1' || $class_level_data=='p2' || $class_level_data=='p3' || $class_level_data=='p4' || $class_level_data=='p5' || $class_level_data=='p6') {
			$term_set='1,2';
		}
		$user_status=$_SESSION['ss_status'];
		$user_id=$_SESSION['ss_user_id'];
		if ($user_status==1) {
			$this->sql ="SELECT  room
					FROM tbl_room_teacher 
					WHERE course_teacherID in(
						SELECT DataID
						FROM tbl_course_teacher
						WHERE teacher_id=$user_id
						AND regis_course_id in(
							SELECT DataID
							FROM tbl_registed_course
							WHERE courseID=$coures_id_list_val
                            AND term='$term_set'
                            AND year='$year_set'
						)
						
					)	
					ORDER BY room ASC
						";
		}else{
			$this->sql ="
						SELECT distinct room
						FROM tbl_std_class_room
						WHERE std_ID in(
							SELECT std_ID
							FROM tbl_student 
							WHERE std_ID in(
								SELECT stdID
								FROM tbl_course_teaching_std
								WHERE registed_courseID in(
									SELECT DataID
									FROM tbl_registed_course
									WHERE courseID=$coures_id_list_val
	                                AND term='$term_set'
	                                AND year='$year_set'
									)
							)
						)
						ORDER BY room ASC
							";
		}
		
			$this->select();
			$this->setRows();
			foreach($this->rows as $key => $value) {
				$room=$value['room'];
				$chk_room_export=$this->get_chk_room_export_teacher($room,$term_set,$year_set,$coures_id_list_val,$user_status);
				if ($user_status==2) {
					if ($chk_room_export>0) {
						$data_response['room'].=' <option>'.$room.'</option>';
					}
				}else{
					if ($chk_room_export==0) {
						$data_response['room'].=' <option>'.$room.'</option>';
					}
				}
				
			}
		
		return json_encode($data_response);
	}
	public function get_chk_room_export_teacher($room,$term_set,$year_set,$courseID,$user_status){
		$registed_courseID=$this->get_registed_courseID($courseID,$term_set,$year_set);
		if ($user_status==2) {
			$sql_condition="AND status=1";
		}else{
			$sql_condition="";
		}
		$this->sql ="SELECT COUNT(*) as num_row
					FROM tbl_room_export
					WHERE room=$room
					$sql_condition
					AND sended_status!=99
					AND registed_courseID=$registed_courseID
				";
		$this->select();
		$this->setRows();
		return $this->rows[0]['num_row'];
	}
	public function get_chk_room_export($room,$term_set,$year_set,$courseID){
		$this->sql ="SELECT COUNT(*) as num_row
					FROM tbl_room_export
					WHERE room=$room
					AND sended_status!=99
					AND registed_courseID IN(
						SELECT DataID
						FROM tbl_registed_course
						WHERE term='$term_set'
						AND year='$year_set'
						AND courseID=$courseID
					)
				";
		$this->select();
		$this->setRows();
		return $this->rows[0]['num_row'];
	}
	public function get_registed_courseID_set($courseID,$term_set,$year_set){
		$this->sql ="SELECT  *
					FROM tbl_registed_course 			
					WHERE courseID=$courseID
					AND term='$term_set'
					AND year='$year_set'						
							";
		$this->select();
		$this->setRows();
		return	$this->rows[0]['DataID'];
	}
	
	public function get_coures_id_list(){
		$user_id=$_SESSION['ss_user_id'];
		$data_response = array();	
		$this->sql ="SELECT  *
					FROM tbl_set_term_year 			
							";
		$this->select();
		$this->setRows();
		$term_set=$this->rows[0]['term'];
		$year_set=$this->rows[0]['year'];
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 		
                    WHERE DataID in(
                    	SELECT courseID
                        FROM tbl_registed_course
                        WHERE year='$year_set'                   
                        AND DataID IN(
                        	SELECT registed_courseID
                            FROM tbl_registed_course_teaching    
                        )
                        AND DataID in(
                            	SELECT regis_course_id
								FROM tbl_course_teacher
								WHERE teacher_id=$user_id
                            )
                    )
					ORDER BY courseID ASC	
							";
		$this->select();
		$this->setRows();
		foreach($this->rows as $key => $value) {
			$DataID=$value['DataID'];
			
			$courseID_long=$value['courseID'];
			$status=$value['status'];
			$class_level=$value['class_level'];
			$data_dicision=$this->get_data_dicision($DataID,$courseID_long,$class_level,$status,$term_set,$year_set);
			$data_response['coures_id_list'].=$data_dicision;
		}
		echo json_encode($data_response);
	}
	public function get_class_level_new($class_level_data){
		if ($class_level_data=="p1") {
			$class_level="ป.1";
		}elseif($class_level_data=="p2"){
			$class_level="ป.2";	
		}elseif($class_level_data=="p3"){
			$class_level="ป.3";	
		}elseif($class_level_data=="p4"){
			$class_level="ป.4";	
		}elseif($class_level_data=="p5"){
			$class_level="ป.5";	
		}elseif($class_level_data=="p6"){
			$class_level="ป.6";	
		}elseif($class_level_data=="m1"){
			$class_level="ม.1";	
		}elseif($class_level_data=="m2"){
			$class_level="ม.2";	
		}elseif($class_level_data=="m3"){
			$class_level="ม.3";	
		}elseif($class_level_data=="m4"){
			$class_level="ม.4";	
		}elseif($class_level_data=="m5"){
			$class_level="ม.5";	
		}elseif($class_level_data=="m6"){
			$class_level="ม.6";	
		}
		return $class_level;
	}
	public function get_coures_id_list_admin($term_set,$year_set){
		$user_id=$_SESSION['ss_user_id'];
		$data_response = array();	
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 		
                    WHERE DataID in(
                    	SELECT courseID
                        FROM tbl_registed_course
                        WHERE year='$year_set'                                       
                        AND DataID IN(
                        	SELECT registed_courseID
                            FROM tbl_registed_course_teaching
                        )              
                    )
					ORDER BY courseID ASC	
							";
		$this->select();
		$this->setRows();
		foreach($this->rows as $key => $value) {
			$DataID=$value['DataID'];
			$courseID_long=$value['courseID'];
			$status=$value['status'];
			$class_level=$value['class_level'];
			$data_dicision=$this->get_data_dicision_admin($DataID,$courseID_long,$class_level,$status,$term_set,$year_set);

			$data_response['coures_id_list'].=$data_dicision;
		}
		if ($data_response['coures_id_list']=='') {
			$data_response['coures_id_list']='<option value="">ไม่พบรายวิชา</option>';
		}
		return json_encode($data_response);
	}
	public function get_data_dicision($DataID,$courseID_long,$class_level,$status,$term_set,$year_set){
		if ($class_level=='p1' || $class_level=='p2' || $class_level=='p3' || $class_level=='p4' || $class_level=='p5' || $class_level=='p6') {
			$term_set='1,2';
		}
		$this->sql ="SELECT  COUNT(*) as num_row_not_in
					FROM tbl_registed_course
					WHERE courseID=$DataID
					AND term='$term_set'
					AND year='$year_set'
					AND DataID not in(
						SELECT registed_courseID
						FROM tbl_room_export
					)
				";
		$this->select();
		$this->setRows();
		$num_row_not_in=$this->rows[0]['num_row_not_in'];

		$this->sql ="SELECT  COUNT(*) as num_row_in_99
					FROM tbl_registed_course
					WHERE courseID=$DataID
					AND term='$term_set'
					AND year='$year_set'
					AND DataID in(
						SELECT registed_courseID
						FROM tbl_room_export
						WHERE sended_status=99
					)
				";
		$this->select();
		$this->setRows();
		$num_row_in_99=$this->rows[0]['num_row_in_99'];
		if ($num_row_not_in>0 && $num_row_in_99==0) {//no have both in room export
			$data_response='<option value="'.$DataID.'">'.$courseID_long.'</option>';
		}elseif($num_row_not_in==0){//have in room export
			$this->sql ="SELECT  COUNT(*) as num_row_not_99
					FROM tbl_registed_course
					WHERE courseID=$DataID
					AND term='$term_set'
					AND year='$year_set'
					AND DataID in(
						SELECT registed_courseID
						FROM tbl_room_export
						WHERE sended_status!=99
					)
				";
			$this->select();
			$this->setRows();
			$num_row_not_99=$this->rows[0]['num_row_not_99'];
			if ($num_row_in_99>0 && $num_row_not_99==0) {//have only 99 in room export
				$data_response='<option value="'.$DataID.'">'.$courseID_long.'</option>';
			}elseif($num_row_not_99>0){//have only another in room export
				$this->sql ="
						SELECT distinct room
						FROM tbl_std_class_room
						WHERE std_ID in(
							SELECT std_ID
							FROM tbl_student 
							WHERE std_ID in(
								SELECT stdID
								FROM tbl_course_teaching_std
								WHERE registed_courseID in(
									SELECT DataID
									FROM tbl_registed_course
									WHERE courseID=$DataID
	                                AND term='$term_set'
	                                AND year='$year_set'
									)
							)
						)
						ORDER BY room ASC
							";
				$this->select();
				$this->setRows();
				$set_amount=0;
				$room_amount=0;
				foreach($this->rows as $key => $value) {
					$room=$value['room'];
					$chk_room_export=$this->get_chk_room_export($room,$term_set,$year_set,$DataID);
					if ($chk_room_export==1) {
						$set_amount++;
					}
					$room_amount++;
				}
				if ($set_amount<$room_amount) {
					$data_response='<option value="'.$DataID.'">'.$courseID_long.'</option>';
				}
				
			}
		}
		return $data_response;	
	}
	
	public function get_data_dicision_admin($DataID,$courseID_long,$class_level,$status,$term_set,$year_set){
		$this->sql ="SELECT  COUNT(*) AS num_row
					FROM tbl_room_export 
					WHERE status=1
					AND registed_courseID in(
						SELECT DataID
						FROM tbl_registed_course
						WHERE year='$year_set'
						AND term='$term_set'
						AND courseID=$DataID
					)
							";
		$this->select();
		$this->setRows();
		$num_row=$this->rows[0]['num_row'];
			if ($num_row>0) {
				$data_response='<option value="'.$DataID.'">'.$courseID_long.'</option>';
			}
		return $data_response;
			
	}
	public function get_year(){
		$this->sql ="SELECT  distinct(year) as year
					FROM tbl_pp6
					ORDER BY year DESC
							";
		$this->select();
		$this->setRows();
		foreach($this->rows as $key => $value) {
			$year=  $value['year'];	
			if($key==0){	
			$data_response.='
					 <option selected="selected" value="'.$year.'">'.$year.'</option>
			';
			}else{
				$data_response.='
					 <option  value="'.$year.'">'.$year.'</option>
			';
			}
			
		}
		return json_encode($data_response);
	}
}<file_sep>/modules/report/major.php
<?php
    require __DIR__.'/vendor/autoload.php';
    use Spipu\Html2Pdf\Html2Pdf;
    use Spipu\Html2Pdf\Exception\Html2PdfException;
    use Spipu\Html2Pdf\Exception\ExceptionFormatter;
   
if (isset($_POST['data_id'])) {
    
     try {

        $data_id=$_POST['data_id'];
        $room_search=$_POST['room_search'];
        $status=$_POST['status'];
        $page=$_POST['page'];
        
        ob_start();
        //$stylesheet = file_get_contents(__DIR__.'\pdf_form.php'); /// here call you external css file 
      
        include dirname(__FILE__).'/major_form.php';
        
        $content = ob_get_clean();

        $html2pdf = new Html2Pdf('P', 'A4', 'fr');
       
        $html2pdf->pdf->SetDisplayMode('fullpage');
        $html2pdf->addFont('THSarabun', '', dirname(__FILE__).'/html2pdf/fonts/THSarabun.php');
        $html2pdf->setDefaultFont('THSarabun');

        $html2pdf->writeHTML($content);
        $html2pdf->output('my_doc.pdf');
        
    } catch (Html2PdfException $e) {
        $formatter = new ExceptionFormatter($e);
        echo $formatter->getHtmlMessage();
    }
}
?>


 <file_sep>/modules/regis_teacher/index.js
var opPage = 'regis_teacher';
$(document).ready(function() {
	get_teacher();
	years_set();
	
}); 
$(function () {
  $('[data-toggle="tooltip"]').tooltip()
})
$('#uploadBtn_select').on('click', function() {
    $('#uploadBtn').trigger('click');

});

$( "#uploadBtn" ).change(function() {
	$("#modalWaitUp").modal("show");
	var file_data = $('#uploadBtn').prop('files')[0];   
    var form_data = new FormData();                  
    form_data.append('file', file_data);
    //alert(form_data);                             
    $.ajax({
                url: 'modules/regis_teacher/upload_one.php', // point to server-side PHP script 
                dataType: 'text',  // what to expect back from the PHP script, if anything
                cache: false,
                contentType: false,
                processData: false,
                data: form_data,                         
                type: 'post',
                success: function(data){
                	$(".modal").modal("hide");
                	$("#table_list").html(data);
                	$("#modalteachershow").modal("show");
                    //alert(php_script_response); // display response from the PHP script, if any
                }
     });


});
$(document).delegate('#exit_std', 'click', function(event) {
	window.location.reload();
});
function form_reset(form_se) {
	$("#"+form_se)[0].reset();
}
$(document).delegate('#btn__save', 'click', function(event) {
	var positionID =$("#positionID").val();
	var fname_th =$("#fname_th").val();
	var lname_th =$("#lname_th").val();
	var fname_en =$("#fname_en").val();
	var lname_en =$("#lname_en").val();
	var day_set =$("#day_set").val();
	var mouth_set =$("#mouth_set").val();
	var years_set =$("#years_set").val();

	if (day_set !=0 && mouth_set!=0 && years_set!=0) {
		$("#day_set").removeClass("born-box-day-red");
		$("#mouth_set").removeClass("born-box-day-red");
		$("#years_set").removeClass("born-box-day-red");
		if(positionID !='' && fname_th !='' && lname_th !='' && fname_en !='' && lname_en !='') {
			var formData = $( "#frm_data" ).serializeArray();
			formData.push({ "name": "acc_action", "value": "save_data" }); 
			$.post('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {
			// console.log(data);
			// return false;
			$(".modal").modal("hide");
			$("#modalRegistered").modal("show");
			window.location.reload();
			});
		}else{
			$(".modal").modal("hide");
			if (positionID=='') {
				$("#positionID").removeClass("form-set");
				$("#positionID").addClass("form-set-null-data");
				$("#positionID").attr( "placeholder", "กรุณาใส่ข้อมูล" );
			}
			if (fname_th=='') {
				$("#fname_th").removeClass("form-set");
				$("#fname_th").addClass("form-set-null-data");
				$("#fname_th").attr( "placeholder", "กรุณาใส่ข้อมูล" );
			}	
			if (lname_th=='') {
				$("#lname_th").removeClass("form-set");
				$("#lname_th").addClass("form-set-null-data");
				$("#lname_th").attr( "placeholder", "กรุณาใส่ข้อมูล" );
			}	
			if (fname_en=='') {
				$("#fname_en").removeClass("form-set");
				$("#fname_en").addClass("form-set-null-data");
				$("#fname_en").attr( "placeholder", "กรุณาใส่ข้อมูล" );
			}
			if (lname_en=='') {
				$("#lname_en").removeClass("form-set");
				$("#lname_en").addClass("form-set-null-data");
				$("#lname_en").attr( "placeholder", "กรุณาใส่ข้อมูล" );
			}
		
	 	}
	 }else{
	 		$(".modal").modal("hide");
	 		$("#mouth_set").removeClass("form-set");
			$("#mouth_set").addClass("born-box-day-red");
			$("#mouth_set").attr( "placeholder", "กรุณาใส่ข้อมูล" );

			$("#years_set").removeClass("form-set");
			$("#years_set").addClass("born-box-day-red");
			$("#years_set").attr( "placeholder", "กรุณาใส่ข้อมูล" );

			$("#day_set").removeClass("form-set");
			$("#day_set").addClass("born-box-day-red");
			$("#day_set").attr( "placeholder", "กรุณาใส่ข้อมูล" );
	 }
});
$('#id_search').on('keydown', function(event) {
   var x = event.which;
   if (x === 13) {
   get_teacher('id');
   	 event.preventDefault();
   }
});
$('#name_search').on('keydown', function(event) {
   var x = event.which;
   if (x === 13) {
   get_teacher('name');
   	 event.preventDefault();
   }
});
$(document).delegate('#btn_id_search', 'click', function(event) {
	get_teacher('id');
});
$(document).delegate('#btn_name_search', 'click', function(event) {
	get_teacher('name');
});
$(document).delegate('.bt_change_pass', 'click', function(event) {
 	var data_id = $(this).attr('data-id');
 	 $(document).delegate('#btn_to_change_pass', 'click', function(event) {
 		$.post('modules/' + opPage + '/process.php', {
			'acc_action' : 'change_pass',
			'data_val' : data_id
		}, function(response) {
			$("#modalChangePass").modal("hide");
			data_id='';
			
			$("#modalChaged").modal("show");
		});
 	});
 });
 $(document).delegate('.bt_delete', 'click', function(event) {
 	var data_id = $(this).attr('data-id');
 	 $(document).delegate('#btn_to_delete', 'click', function(event) {
 		$.post('modules/' + opPage + '/process.php', {
			'acc_action' : 'data_remove',
			'data_val' : data_id
		}, function(response) {
			data_id='';
			$(".modal").modal("hide");
			get_teacher() ;

		});
 	});
 });
function get_teacher(status) {
	var formData = new Array();
	if (status=='id') {
		var data_search=$("#id_search").val();
	}else if(status=='name'){
		var data_search=$("#name_search").val();
	}
	formData.push({ "name": "acc_action", "value": "get_teacher" });
	formData.push({ "name": "status", "value": status });  
	formData.push({ "name": "data_search", "value": data_search });
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {
		$("#table_list_teacher").html(data);
	});
}
function years_set() {
	var formData = new Array();
	formData.push({ "name": "acc_action", "value": "get_years" }); 
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {
		$("#years_set").html(data.set_years);
	});
}
<file_sep>/modules/attend_class/backup2/class_modules.php
<?php 

class ClassData extends Databases {
	public function get_day_list($length_list_val,$registed_course_id){
		$data_response = array();
		$this->sql ="SELECT  COUNT(*) as num_attend_day
					FROM tbl_set_attend_day 		
					WHERE registed_course_teachingID=$registed_course_id	

							";
		$this->select();
		$this->setRows();
		$data_response['num_attend_day']=$this->rows[0]['num_attend_day'];

		$data_response['week_title']='สัปดาห์ที่ '.$length_list_val.'';
		$this->sql ="SELECT  *
					FROM tbl_set_attend_day 		
					WHERE registed_course_teachingID=$registed_course_id	
					ORDER BY attend_class_week_listID ASC
							";
		$this->select();
		$this->setRows();
		$data_count=0;
		foreach($this->rows as $key => $value) {
			$attend_class_week_listID=$value['attend_class_week_listID'];
			$day_name=$this->get_day_name($attend_class_week_listID);
			$data_response['week_header'].='<td class="set_header_width" width="70px">'.$day_name.'</td>';
			$data_count++;
		}
		$data_response['week_header'].='<td id="header_sum_score">0</td>';
		$data_response['week_header'].='<td >100</td>';
		$data_response['data_count']=$data_count;
		echo json_encode($data_response);
	}
	public function get_day_name($day_id){
		$this->sql ="SELECT  *
					FROM tbl_attend_class_week_list 		
					WHERE DataID=$day_id	
							";
		$this->select();
		$this->setRows();
		return $this->rows[0]['name'];
	}
	public function set_day($registed_course_id,$value_day,$hr_set){
		$this->sql ="SELECT  COUNT(*) as num_row_day
					FROM tbl_set_attend_day 		
					WHERE registed_course_teachingID=$registed_course_id	
					AND attend_class_week_listID=$value_day
							";
		$this->select();
		$this->setRows();
		$num_row_day=$this->rows[0]['num_row_day'];
		if ($num_row_day==0) {
			$this->sql ="INSERT INTO tbl_set_attend_day(registed_course_teachingID,attend_class_week_listID,hr) VALUES($registed_course_id,$value_day,$hr_set)";
			$this->query();
		}else{
			$this->sql ="DELETE FROM tbl_set_attend_day WHERE registed_course_teachingID=$registed_course_id AND attend_class_week_listID=$value_day" ;
			$this->query();
		}

		echo json_encode("1");
	}
	public function get_day_set($registed_course_id){
		$this->sql ="SELECT  *
					FROM tbl_set_attend_day 		
					WHERE registed_course_teachingID=$registed_course_id	
							";
		$this->select();
		$this->setRows();
		$monday="";
		$tuesday="";
		$wednesday ="";
		$thursday ="";
		$friday="";

		$monday_hr="disabled";
		$tuesday_hr="disabled";
		$wednesday_hr="disabled";
		$thursday_hr="disabled";
		$friday_hr="disabled";
		
		foreach($this->rows as $key => $value) {
			
			$day_find=$value['attend_class_week_listID'];
			if ($day_find==1) {
				$monday='checked';
				$monday_hr="";
			}
			if ($day_find==2) {
				$tuesday='checked';
				$tuesday_hr="";
			}
			if ($day_find==3) {
				$wednesday='checked';
				$wednesday_hr="";
			}
			if ($day_find==4) {
				$thursday='checked';
				$thursday_hr="";
			}
			if ($day_find==5) {
				$friday='checked';
				$friday_hr="";
			}		
		}
		$data_response='
				 	<td class="text-before-box3 text-bold mt-10" style="float: right;">
                          วันที่สอน
                        </td> 

                        <td  style="padding-left:25px;">
                          <div class="checkbox mr-20 ml-10">
                            <label><input onclick="set_day(this)" '.$monday.' type="checkbox" name="day_set" value="1">จันทร์</label>
                          </div>
                          <div>
                          	<select '.$monday_hr.' style="width:75px;" class="form-control search-drop-length-ob mt-5 hr_set_1">
                              <option value="3">3</option>
                              <option value="2">2</option>
                              <option value="1">1</option>
                            </select>
                          </div>
                        </td>
                        <td  style="padding-left:25px;">
                          <div class="checkbox mr-20 ml-10 ">
                            <label><input onclick="set_day(this)" '.$tuesday.' type="checkbox" name="day_set" value="2">อังคาร</label>
                          </div>
                          <div>
                          	<select '.$tuesday_hr.' style="width:75px;" class="form-control search-drop-length-ob mt-5 hr_set_2">
                              <option value="3">3</option>
                              <option value="2">2</option>
                              <option value="1">1</option>
                            </select>
                          </div>
                        </td>
                        <td  style="padding-left:25px;">
                          <div class="checkbox mr-20 ml-10">
                            <label><input onclick="set_day(this)" '.$wednesday.' type="checkbox" name="day_set" value="3">พุธ</label>
                          </div>
                          <div>
                          	<select '.$wednesday_hr.' style="width:75px;" class="form-control search-drop-length-ob mt-5 hr_set_3">
                              <option value="3">3</option>
                              <option value="2">2</option>
                              <option value="1">1</option>
                            </select>
                          </div>
                        </td>
                        <td  style="padding-left:25px;">
                          <div class="checkbox mr-20 ml-10">
                            <label><input onclick="set_day(this)" '.$thursday.' type="checkbox" name="day_set" value="4">พฤหัสบดี</label>
                          </div>
                          <div>
                          	<select '.$thursday_hr.' style="width:75px;" class="form-control search-drop-length-ob mt-5 hr_set_4">
                          	
                              <option value="3">3</option>
                              <option value="2">2</option>
                              <option value="1">1</option>
                            </select>
                          </div>
                        </td>
                        <td  style="padding-left:25px;">
                          <div class="checkbox mr-20 ml-10">
                            <label><input onclick="set_day(this)" '.$friday.' type="checkbox" name="day_set" value="5">ศุกร์</label>
                          </div>
                          <div>
                          	<select '.$friday_hr.' style="width:75px;" class="form-control search-drop-length-ob mt-5 hr_set_5">
                          	
                              <option value="3">3</option>
                              <option value="2">2</option>
                              <option value="1">1</option>
                            </select>
                          </div>
                        </td>
			';
		echo json_encode($data_response);
	}
	public function get_week_between($coures_id_list_val){
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 		
					WHERE DataID=$coures_id_list_val	
							";
		$this->select();
		$this->setRows();
		$class_level=$this->rows[0]['class_level'];
		if ($class_level=='p1' || $class_level=='p2' || $class_level=='p3' || $class_level=='p4' || $class_level=='p5' || $class_level=='p6') {
			$data_response='
							<option value="1-10">สัปดาห์ที่ 1-10</option>
                             <option value="11-20">สัปดาห์ที่ 11-20</option>    
                             <option value="21-31">สัปดาห์ที่ 21-31</option>   
                             <option value="31-40">สัปดาห์ที่ 31-40</option>  
			';
		}else{
			$data_response='
							<option value="1-10">สัปดาห์ที่ 1-10</option>
                             <option value="11-20">สัปดาห์ที่ 11-20</option>    
			';
		}
		echo json_encode($data_response);
	}
	public function get_count_adttend_class_val($coures_id_list_val){
		$this->sql ="SELECT  *
					FROM tbl_set_term_year 			
							";
		$this->select();
		$this->setRows();
		$term_set=$this->rows[0]['term'];
		$year_set=$this->rows[0]['year'];
		$class_level=$this->rows[0]['class_level'];
		if ($class_level=='p1' || $class_level=='p2' || $class_level=='p3' || $class_level=='p4' || $class_level=='p5' || $class_level=='p6') {
			$term_set='1,2';
		}
		$registed_courseID=$this->get_registed_courseID($coures_id_list_val,$term_set,$year_set);
		$this->sql ="SELECT  *
					FROM tbl_set_count_adttend_class
					WHERE registed_courseID=$registed_courseID		
							";
		$this->select();
		$this->setRows();
		$week_name=$this->rows[0]['week_name'];
		echo json_encode($week_name);
	}
	/*public function set_count_adttend_class_val($coures_id_list_val,$set_count_adttend_class_val){
		$this->sql ="SELECT  *
					FROM tbl_set_term_year 			
							";
		$this->select();
		$this->setRows();
		$term_set=$this->rows[0]['term'];
		$year_set=$this->rows[0]['year'];
		$class_level=$this->rows[0]['class_level'];
		if ($class_level=='p1' || $class_level=='p2' || $class_level=='p3' || $class_level=='p4' || $class_level=='p5' || $class_level=='p6') {
			$term_set='1,2';
		}

		$registed_courseID=$this->get_registed_courseID($coures_id_list_val,$term_set,$year_set);
		$this->sql ="SELECT  COUNT(*) as num_row
					FROM tbl_set_count_adttend_class 	
					WHERE registed_courseID	=$registed_courseID	
							";
		$this->select();
		$this->setRows();
		$num_row=$this->rows[0]['num_row'];
		if ($num_row>0) {
			$this->sql ="UPDATE tbl_set_count_adttend_class SET week_name=$set_count_adttend_class_val WHERE registed_courseID=$registed_courseID
							";
			$this->query();
		}else{
			$this->sql ="INSERT INTO tbl_set_count_adttend_class(registed_courseID,week_name) VALUES($registed_courseID,$set_count_adttend_class_val)		
							";
			$this->query();
		}
		

	}*/
	public function chk_value_attend_1($score_status){
		if ($score_status=="1") {
			$data_response="selected";
		}
		return $data_response;
	}
	public function chk_value_attend_l($score_status){
		if ($score_status=="ล") {
			$data_response="selected";
		}
		return $data_response;
	}
	public function chk_value_attend_p($score_status){
		if ($score_status=="ป") {
			$data_response="selected";
		}
		return $data_response;
	}
	public function chk_value_attend_k($score_status){
		if ($score_status=="ข") {
			$data_response="selected";
		}
		return $data_response;
	}
	public function chk_value_attend_n($score_status){
		if ($score_status=="น") {
			$data_response="selected";
		}
		return $data_response;
	}
	public function chk_value_attend__($score_status){
		if ($score_status=="0" || $score_status=="-") {
			$data_response="selected";
		}
		return $data_response;
	}
	public function get_score_col($std_ID,$registed_courseID,$start_data,$end_data){

		$this->sql ="SELECT  *
					FROM tbl_course_teaching_std 	
					WHERE registed_courseID=$registed_courseID
					AND stdID='$std_ID'
					";
			$this->select();
			$this->setRows();	
			$course_teaching_stdID=$this->rows[0]['DataID'];	
		$this->sql ="SELECT  *
					FROM tbl_attend_class 	
					WHERE course_teaching_stdID=$course_teaching_stdID		
					AND week BETWEEN $start_data AND $end_data	
					ORDER BY week ASC 	
					";
			$this->select();
			$this->setRows();	
			foreach($this->rows as $key => $value) {					
				$attendID=$value['DataID'];
				$week=$value['week'];
				$score_status=$value['score_status'];	
				$data_response['score_col'].='
								<td class="relative">
		                          <select name="attend_score_std[]" class="select-table-form class_col_set_new class_col_attend_1 value_attend_week_1">
		                            <option value="1" selected="">1</option>
		                            <option value="ล">ล</option>
		                            <option value="ป">ป</option>
		                            <option value="ข">ข</option>		                            
		                            <option value="-">-</option>
		                          </select>
		                        </td>
				'; 	
				
			}
			
			return $data_response;
	}	

	public function get_score_col_total($std_ID,$registed_courseID,$start_data,$end_data,$num_row_std,$no_std){
		$this->sql ="SELECT  *
					FROM tbl_course_teaching_std 	
					WHERE registed_courseID=$registed_courseID
					AND stdID='$std_ID'
					";
		$this->select();
		$this->setRows();
		$course_teaching_stdID=$this->rows[0]['DataID'];
		$this->sql ="SELECT  SUM(score_status) as sum_score_status
					FROM tbl_attend_class 	
					WHERE course_teaching_stdID=$course_teaching_stdID		
					AND week BETWEEN $start_data AND $end_data	
					ORDER BY week ASC 	
					";
		$this->select();
		$this->setRows();
		return $this->rows[0]['sum_score_status'];

	}
	public function get_all_attendID($std_ID,$registed_courseID,$start_data,$end_data,$num_row_std,$no_std){
		$this->sql ="SELECT  *
					FROM tbl_course_teaching_std 	
					WHERE registed_courseID=$registed_courseID
					AND stdID='$std_ID'
					";
			$this->select();
			$this->setRows();	
			$course_teaching_stdID=$this->rows[0]['DataID'];	
			$this->sql ="SELECT  count(*) as num_attend_row
					FROM tbl_attend_class 	
					WHERE course_teaching_stdID=$course_teaching_stdID		
					AND week BETWEEN $start_data AND $end_data	
					ORDER BY week ASC 	
					";
			$this->select();
			$this->setRows();	
			$num_attend_row=$this->rows[0]['num_attend_row'];	
			$this->sql ="SELECT  *
					FROM tbl_attend_class 	
					WHERE course_teaching_stdID=$course_teaching_stdID		
					AND week BETWEEN $start_data AND $end_data	
					ORDER BY week ASC 	
					";
			$this->select();
			$this->setRows();	
			$num_set=1;
			foreach($this->rows as $key => $value) {
				if ($num_row_std==$no_std) {
					if ($num_set==$num_attend_row) {
						$attendID.=$value['DataID'];
					}else{
						$attendID.=$value['DataID'].'-';
					}
				}else{
					$attendID.=$value['DataID'].'-';
				}
				
				$num_set++;
			}
			return $attendID;
	}
	public function get_detail_std($coures_id_list_val,$room_search,$registed_course_teaching_id,$length_list_val){
		$this->sql ="SELECT  *
					FROM tbl_set_term_year 			
							";
		$this->select();
		$this->setRows();
		$term_set=$this->rows[0]['term'];
		$year_set=$this->rows[0]['year'];
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 	
					WHERE DataID=$coures_id_list_val					
					";
		$this->select();
		$this->setRows();
		$class_level=$this->rows[0]['class_level'];
		$status=$this->rows[0]['status'];
		if ($class_level=='p1' || $class_level=='p2' || $class_level=='p3' || $class_level=='p4' || $class_level=='p5' || $class_level=='p6') {
			$term_set='1,2';
		}
		$registed_courseID=$this->get_registed_courseID($coures_id_list_val,$term_set,$year_set);
		$this->sql ="SELECT  COUNT(*) as num_row_std
					FROM tbl_student 	
					WHERE room='$room_search'
					AND std_ID IN(
						SELECT stdID
						FROM tbl_course_teaching_std
						WHERE registed_courseID=$registed_courseID						
					)
					

					";
		$this->select();
		$this->setRows();
		$num_row_std=$this->rows[0]['num_row_std'];
		$this->sql ="SELECT  *
					FROM tbl_student 	
					WHERE room='$room_search'
					AND std_ID IN(
						SELECT stdID
						FROM tbl_course_teaching_std
						WHERE registed_courseID=$registed_courseID						
					)
					";
		$this->select();
		$this->setRows();
		$no_std=1;
		foreach($this->rows as $key => $value) {
			$std_ID=$value['std_ID'];
			$fname=$value['fname'];
			$lname=$value['lname'];
			$name_title_data=$value['name_title'];
			$name_title=$this->get_name_title($name_title_data);

			$class_level_status=$this->get_class_level_status($coures_id_list_val);
			if ($class_level_status=='p') {
				$term_set='1,2';
			}
			$attend_data=$this->get_attend_data($registed_course_teaching_id,$std_ID,$registed_courseID,$length_list_val,$class_level_status,$status);
			/*$all_attendID.=$this->get_all_attendID($std_ID,$registed_courseID,$start_data,$end_data,$num_row_std,$no_std);
			$score_col=$this->get_score_col($std_ID,$registed_courseID,$start_data,$end_data);	*/	
			//$score_col_total=$this->get_score_col_total($std_ID,$registed_courseID,$start_data,$end_data,$num_row_std,$no_std);
			$data_response['detail_std'].='<tr>
										<td>'.$no_std.'</td>
						                <td style="text-align:left;padding-left:7%;">'.$name_title.$fname.' '.$lname.'</td>				                  
						                '.$attend_data.'
						             </tr>
			';	
			$no_std++;		
		}
		$data_response['all_attendID'].=$all_attendID;

		$this->sql ="SELECT  COUNT(*) as num_day
					FROM tbl_set_attend_day 	
					WHERE registed_course_teachingID=$registed_course_teaching_id
					";
		$this->select();
		$this->setRows();
		$num_day=$this->rows[0]['num_day'];
		$class_level_status=$this->get_class_level_status($coures_id_list_val);
		if ($class_level_status=='p' || $status==2) {
			$week_all=40;
		}else{
			$week_all=20;
		}

		$data_response['num_day']=($num_day)*$week_all;	

		return $data_response;
	}
	public function get_name_title($name_title_data){
		if ($name_title_data=="dekchai") {
			$name_title="เด็กชาย";
		}elseif($name_title_data=="dekying"){
			$name_title="เด็กหญิง";
		}elseif($name_title_data=="nai"){
			$name_title="นาย";
		}elseif($name_title_data=="nangsaw"){
			$name_title="นางสาว";
		}
		return $name_title;
	}

	public function get_attend_data($registed_course_teaching_id,$std_ID,$registed_courseID,$length_list_val,$class_level_status,$status_class){
		$this->sql ="SELECT  *
				FROM tbl_course_teaching_std 	
				WHERE registed_courseID=$registed_courseID
				AND stdID='$std_ID'
				";
		$this->select();
		$this->setRows();	
		$course_teaching_stdID=$this->rows[0]['DataID'];	

		$this->sql ="SELECT  *
					FROM tbl_set_attend_day 	
					WHERE registed_course_teachingID=$registed_course_teaching_id
					ORDER BY attend_class_week_listID ASC
					";
		$this->select();
		$this->setRows();		

		foreach($this->rows as $key => $value) {
			$DataID=$value['DataID'];
			$attend_class_week_listID=$this->rows[0]['attend_class_week_listID'];
			$attend_class_std=$this->get_attend_class_std($DataID,$std_ID,$registed_courseID,$length_list_val);
			if ($attend_class_std['attend_id']!='') {
				$status=$attend_class_std['status'];
				if ($status=='ล') {
					$status_l='selected="selected"';
				}else{
					$status_l='';
				}

				if ($status=='ป') {
					$status_p='selected="selected"';
				}else{
					$status_p='';
				}

				if ($status=='ข') {
					$status_k='selected="selected"';
				}else{
					$status_k='';
				}

				if ($status=='น') {
					$status_n='selected="selected"';
				}else{
					$status_n='';
				}

				$data_response.='
								<td class="relative">
		                          <select onchange="save_attend(this,'.$attend_class_std['attend_id'].','.$course_teaching_stdID.','.$DataID.','.$length_list_val.')" class="select-table-form class_col_set_new ">
		                            <option value="1" >1</option>
		                            <option '.$status_l.' value="ล">ล</option>
		                            <option '.$status_p.' value="ป">ป</option>
		                            <option '.$status_k.' value="ข">ข</option>		
		                            <option '.$status_n.' value="น">น</option>	                            
		                           
		                          </select>
		                        </td>
			';
			
			}else{
				$data_response.='
								<td class="relative">
		                          <select onchange="save_attend(this,0,'.$course_teaching_stdID.','.$DataID.','.$length_list_val.')" class="select-table-form class_col_set_new ">
		                            <option value="1">1</option>
		                            <option value="ล">ล</option>
		                            <option value="ป">ป</option>
		                            <option value="ข">ข</option>		
		                            <option value="น">น</option>                          	                            
		                          </select>
		                        </td>
			';
			}


		}
		$this->sql ="SELECT  COUNT(*) as num_no_class
					FROM tbl_attend_class_std 	
					WHERE course_teaching_std_id=$course_teaching_stdID
					";
		$this->select();
		$this->setRows();
		$num_no_class=$this->rows[0]['num_no_class'];

		$this->sql ="SELECT  COUNT(*) as num_day
					FROM tbl_set_attend_day 	
					WHERE registed_course_teachingID=$registed_course_teaching_id
					";
		$this->select();
		$this->setRows();
		$num_day=$this->rows[0]['num_day'];	
		if ($class_level_status=='p' || $status_class==2) {
			$week_all=40;
		}else{
			$week_all=20;
		}
		$total_day=$num_day*$week_all;

		$total_attend=$total_day-$num_no_class;
		$data_response.='
			<td class="relative">
				'.$total_attend.'
			</td>
		';

		$total_attend_per=round((($total_day-$num_no_class)*100)/$total_day);
		$data_response.='
			<td class="relative">
				'.$total_attend_per.'
			</td>
		';
		return $data_response;	
	}
	public function get_attend_class_std($set_attend_day_id,$std_ID,$registed_courseID,$length_list_val){
		$data_response = array();
		$this->sql ="SELECT  *
					FROM tbl_attend_class_std 	
					WHERE set_attend_day_id=$set_attend_day_id
					AND week=$length_list_val
					AND course_teaching_std_id IN(
						SELECT DataID
						FROM tbl_course_teaching_std
						WHERE registed_courseID=$registed_courseID
						AND stdID='$std_ID'
					)
					";
		$this->select();
		$this->setRows();	
		$data_response['attend_id']=$this->rows[0]['DataID'];
		$data_response['week']=$this->rows[0]['week'];	
		$data_response['status']=$this->rows[0]['status'];	
		return $data_response;	
	}
	public function get_class_level_status($coures_id_list_val){
		$data_response = array();	
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 	
					WHERE DataID=$coures_id_list_val
					";
		$this->select();
		$this->setRows();		
		$class_level=$this->rows[0]['class_level'];	
		if ($class_level=='p1' || $class_level=='p2' || $class_level=='p3' || $class_level=='p4' || $class_level=='p5' || $class_level=='p6') {
			$data='p';
		}else{
			$data='m';
		}
		return $data;
	}
	public function get_registed_courseID($coures_id_list_val,$term_set,$year_set){
		$data_response = array();	
		$this->sql ="SELECT  *
					FROM tbl_registed_course 	
					WHERE courseID=$coures_id_list_val
					AND term='$term_set'
					AND year='$year_set'

					";
		$this->select();
		$this->setRows();		
		return $this->rows[0]['DataID'];	
	}
	public function get_std_id_all($coures_id_list_val,$room_search){
		$this->sql ="SELECT  count(*) as num_row_std
					FROM tbl_student 
					WHERE room='$room_search'
					AND std_ID in(
						SELECT stdID
						FROM tbl_course_teaching_std
						WHERE registed_courseID in(
							SELECT DataID
							FROM tbl_registed_course
							WHERE courseID=$coures_id_list_val
						)
					)
					";
		$this->select();
		$this->setRows();	
		$num_row_std=$this->rows[0]['num_row_std'];	
		$this->sql ="SELECT *
					FROM tbl_student 
					WHERE room='$room_search'
					AND std_ID in(
						SELECT stdID
						FROM tbl_course_teaching_std
						WHERE registed_courseID in(
							SELECT DataID
							FROM tbl_registed_course
							WHERE courseID=$coures_id_list_val
						)
					)
					";
		$this->select();
		$this->setRows();
		$no_std=1;
		foreach($this->rows as $key => $value) {

			$std_ID=$value['std_ID'];		
			if ($num_row_std==$no_std) {
				$std_id_all.=$std_ID;
			}else{
				$std_id_all.=$std_ID.'-';
			}
			
			$no_std++;
			
		}
		$data_response=$std_id_all;
		return $data_response;
	}
	public function get_week_list_data($coures_id_list_val,$length_list_val,$room_search,$registed_course_teaching_id){
		$data_response = array();		
	/*	list($start_data, $end_data) = split('[-]', $length_list_val);
		$find_start=$start_data-1;
		$find_end=$end_data-$find_start;*/
		
		$detail_std=$this->get_detail_std($coures_id_list_val,$room_search,$registed_course_teaching_id,$length_list_val);
		$data_response['detail_std']=$detail_std['detail_std'];
		$data_response['all_attendID']=$detail_std['all_attendID'];
		$data_response['num_day']=$detail_std['num_day'];
		
		$data_response['std_id_all']=$this->get_std_id_all($coures_id_list_val,$room_search);
		//$data_response['std_id_all']=$this->get_std_id_all($coures_id_list_val,$room_search);
		$data_response['data_objectiveID_of_title']=$data_objective;
		return json_encode($data_response);
	}

	public function get_registed_course_id($coures_id_list){
		$this->sql ="SELECT  *
					FROM tbl_set_term_year 			
							";
		$this->select();
		$this->setRows();
		$term_set=$this->rows[0]['term'];
		$year_set=$this->rows[0]['year'];
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 	
					WHERE DataID=$coures_id_list
					AND DataID in(
                    	SELECT courseID
                        FROM tbl_registed_course 
                        WHERE term='$term_set'  
                        OR term='1,2'
                        AND year='$year_set'
                         AND DataID IN(
                            SELECT registed_courseID
                        	FROM tbl_registed_course_teaching
                        )
                    )
					";
		$this->select();
		$this->setRows();		
		$class_level_data=$this->rows[0]['class_level'];	
		if ($class_level_data=='p1' || $class_level_data=='p2' || $class_level_data=='p3' || $class_level_data=='p4' || $class_level_data=='p5' || $class_level_data=='p6' ) {
			$term_set='1,2';
		}

		$this->sql ="SELECT  *
					FROM tbl_registed_course_teaching 	
					WHERE registed_courseID in(
						SELECT DataID
						FROM tbl_registed_course 
						WHERE term='$term_set'
						AND year='$year_set'
						AND courseID=$coures_id_list
					)
					";
		$this->select();
		$this->setRows();
		return $this->rows[0]['DataID'];	
	}
	public function search_course_detail($coures_id_list,$room_search){		
		$data_response = array();	
		$data_response['registed_course_id']=$this->get_registed_course_id($coures_id_list);
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 	
					WHERE DataID=$coures_id_list
					";
		$this->select();
		$this->setRows();		
		$data_response['courseID']=$this->rows[0]['courseID'];	
		$data_response['name']=$this->rows[0]['name'];	
		$data_response['unit']=$this->rows[0]['unit'];	
		$data_response['hr_learn']=$this->rows[0]['hr_learn'];	
		$class_level_data=$this->rows[0]['class_level'];
		$status=$this->rows[0]['status'];
		$class_level=$this->get_class_level_new($class_level_data);
		$data_response['class_level_co']=$class_level.'/'.$room_search;
		if ($class_level_data=='p1' || $class_level_data=='p2' || $class_level_data=='p3' || $class_level_data=='p4' || $class_level_data=='p5' || $class_level_data=='p6' || $status==2) {
			for ($i=1; $i <=40 ; $i++) { 
				$data_response['week_menu_data'].='
						<option value="'.$i.'">สัปดาห์ที่ '.$i.'</option>                         
			';
			}
			
		}else{
			for ($i=1; $i <=20 ; $i++) { 
				$data_response['week_menu_data'].='
						<option value="'.$i.'">สัปดาห์ที่ '.$i.'</option>                         
			';
			}
		}
		

		echo json_encode($data_response);
	}
	public function get_class_level($coures_id_list_val){
		$this->sql ="SELECT  *
					FROM tbl_set_term_year 			
							";
		$this->select();
		$this->setRows();
		$term_set=$this->rows[0]['term'];
		$year_set=$this->rows[0]['year'];
		$data_response = array();	
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 	
					WHERE DataID=$coures_id_list_val
					AND DataID in(
                    	SELECT courseID
                        FROM tbl_registed_course 
                        WHERE term='$term_set'  
                        OR term='1,2'
                        AND year='$year_set'
                         AND DataID IN(
                            SELECT registed_courseID
                        	FROM tbl_registed_course_teaching
                        )
                    )
					";
		$this->select();
		$this->setRows();		
		$class_level_data=$this->rows[0]['class_level'];	
		$data_response['class_level']=$this->get_class_level_new($class_level_data);
		if ($class_level_data=='p1' || $class_level_data=='p2' || $class_level_data=='p3' || $class_level_data=='p4' || $class_level_data=='p5' || $class_level_data=='p6' ) {
			$term_set='1,2';
		}
		$this->sql ="SELECT distinct room
						FROM tbl_student 
						WHERE std_ID in(
							SELECT stdID
							FROM tbl_course_teaching_std
							WHERE registed_courseID in(
								SELECT DataID
								FROM tbl_registed_course
								WHERE courseID=$coures_id_list_val
                                AND term='$term_set'
                                AND year='$year_set'
								)
						)
						ORDER BY room ASC
							";
			$this->select();
			$this->setRows();
			foreach($this->rows as $key => $value) {
				$room=$value['room'];
				$data_response['room'].=' <option>'.$room.'</option>';
			}

		return json_encode($data_response);
	}

	public function get_registed_courseID_set($courseID,$term_set,$year_set){
		$this->sql ="SELECT  *
					FROM tbl_registed_course 			
					WHERE courseID=$courseID
					AND term='$term_set'
					AND year='$year_set'						
							";
		$this->select();
		$this->setRows();
		return	$this->rows[0]['DataID'];
	}
	public function get_coures_id_list(){
		$data_response = array();	
		$this->sql ="SELECT  *
					FROM tbl_set_term_year 			
							";
		$this->select();
		$this->setRows();
		$term_set=$this->rows[0]['term'];
		$year_set=$this->rows[0]['year'];
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 		
                    WHERE DataID in(
                    	SELECT courseID
                        FROM tbl_registed_course
                        WHERE term='$term_set'
                        AND year='$year_set'
                        AND DataID IN(
                        	SELECT registed_courseID
                            FROM tbl_registed_course_teaching
                        )                      
                    )
					ORDER BY courseID ASC								
							";
		$this->select();
		$this->setRows();
		foreach($this->rows as $key => $value) {
			$courseID=$value['DataID'];
			$registed_courseID=$this->get_registed_courseID_set($courseID,$term_set,$year_set);
			$courseID_long=$value['courseID'];
			$data_response['coures_id_list'].='
							<option value="'.$courseID.'">'.$courseID_long.'</option>
			';
		}
		$this->sql ="SELECT  *
					FROM tbl_add_delete_course 		
                    WHERE DataID in(
                    	SELECT courseID
                        FROM tbl_registed_course
                        WHERE term='1,2'
                        AND DataID IN(
                        	SELECT registed_courseID
                            FROM tbl_registed_course_teaching
                        )
                    )
					ORDER BY courseID ASC	
							";
		$this->select();
		$this->setRows();
		foreach($this->rows as $key => $value) {
			$DataID=$value['DataID'];
			$courseID_long=$value['courseID'];
			$data_response['coures_id_list'].='
							<option value="'.$DataID.'">'.$courseID_long.'</option>
			';
		}
		echo json_encode($data_response);
	}
	public function get_class_level_new($class_level_data){
		if ($class_level_data=="p1") {
			$class_level="ป.1";
		}elseif($class_level_data=="p2"){
			$class_level="ป.2";	
		}elseif($class_level_data=="p3"){
			$class_level="ป.3";	
		}elseif($class_level_data=="p4"){
			$class_level="ป.4";	
		}elseif($class_level_data=="p5"){
			$class_level="ป.5";	
		}elseif($class_level_data=="p6"){
			$class_level="ป.6";	
		}elseif($class_level_data=="m1"){
			$class_level="ม.1";	
		}elseif($class_level_data=="m2"){
			$class_level="ม.2";	
		}elseif($class_level_data=="m3"){
			$class_level="ม.3";	
		}elseif($class_level_data=="m4"){
			$class_level="ม.4";	
		}elseif($class_level_data=="m5"){
			$class_level="ม.5";	
		}elseif($class_level_data=="m6"){
			$class_level="ม.6";	
		}
		return $class_level;
	}
}<file_sep>/modules/graduate/class_modules.php
<?php 

class ClassData extends Databases {

	public function edit_status($class_room_modal_id,$status_val){
		 $this->sql ="UPDATE tbl_std_class_room SET status=$status_val WHERE DataID = $class_room_modal_id";
	        $this->query();
		return '1';
	}
	public function data_add($data_val){
		$arr_id = explode(",", $data_val);
		for ($i=0; $i < count($arr_id) ; $i++) { 
            $this->sql ="UPDATE tbl_std_class_room SET status=2 WHERE DataID = {$arr_id[$i]}";
	        $this->query();
		}
		return '1';
	}
	public function get_status_text($status){
		if ($status==1) {
			$data_response='กำลังศึกษา';
		}elseif($status==2){
			$data_response='สำเร็จการศึกษา';
		}elseif($status==3){
			$data_response='ย้าย';
		}elseif($status==4){
			$data_response='ลาออก';
		}elseif($status==5){
			$data_response='เสียชีวิต';
		}elseif($status==6){
			$data_response='กำลังดำเนินการ';
		}
		return $data_response;
	}
	
	public function get_std_list($class_level,$room,$year){
		$data_response = array();	
		$this->sql ="
					SELECT tbl_student.std_ID,tbl_student.name_title,tbl_student.fname,tbl_student.lname,tbl_std_class_room.class_level,tbl_std_class_room.room,tbl_std_class_room.DataID as std_class_room_ID,tbl_std_class_room.status
					FROM tbl_student,tbl_std_class_room
					WHERE tbl_student.std_ID=tbl_std_class_room.std_ID
					AND tbl_std_class_room.class_level='$class_level'
					AND tbl_std_class_room.room='$room'
					AND tbl_std_class_room.year='$year'
					ORDER BY year DESC
							";
		$this->select();
		$this->setRows();
		foreach($this->rows as $key => $value) {
			$std_class_room_ID=$value['std_class_room_ID'];
			$std_ID=$value['std_ID'];
			$name_title_data=$value['name_title'];
			$fname=$value['fname'];
			$lname=$value['lname'];
			$class_level_data=$value['class_level'];
			$room=$value['room'];
			$status=$value['status'];
			$status_text=$this->get_status_text($status);
			$name_title=$this->get_name_title($name_title_data);
			$class_level=$this->get_class_level($class_level_data);
			if($status==2){
				$data_response['std_list'].='
			 					<tr>
			                      <td style="text-align: center;">
			                      	<input checked="checked" disabled="disabled" class="checkbox_data" type="checkbox" value="'.$std_class_room_ID.'" name="checkbox_add[]" id="checkbox'.$std_class_room_ID.'">  
			                      </td>
			                      <td style="text-align: left;width: 10%">'.$std_ID.'</td>
			                      <td style="width: 25%">'.$name_title.$fname.'</td>
			                      <td style="width: 25%">'.$lname.'</td>
			                      <td style="text-align: center;">'.$class_level.'</td>
			                      <td style="text-align: center;">'.$room.'</td>
			                      <td style="text-align: center;">
			                      	<span data-id="'.$std_class_room_ID.'" class="glyphicon glyphicon glyphicon-edit edit-icon-table btn_getdata_edit" aria-hidden="true" data-toggle="modal" data-target="#modalEdit"></span>
			                      </td>
			                      <td style="text-align: center;color:#999">
			                      	<img data-id-registered="699" style="width:20px;margin-top: -8px;margin-left: 5px;" src="assets/images/education.png">
			                      </td>
			                    </tr>
			 ';
			}else{
				$data_response['std_list'].='
			 					<tr>
			                      <td style="text-align: center;">
			                      	<input checked="checked" class="checkbox_data" type="checkbox" value="'.$std_class_room_ID.'" name="checkbox_add[]" id="checkbox'.$std_class_room_ID.'">  
			                      </td>
			                      <td style="text-align: left;width: 10%">'.$std_ID.'</td>
			                      <td style="width: 25%">'.$name_title.$fname.'</td>
			                      <td style="width: 25%">'.$lname.'</td>
			                      <td style="text-align: center;">'.$class_level.'</td>
			                      <td style="text-align: center;">'.$room.'</td>
			                      <td style="text-align: center;">
			                      	<span data-id="'.$std_class_room_ID.'" class="glyphicon glyphicon glyphicon-edit edit-icon-table btn_getdata_edit" aria-hidden="true" data-toggle="modal" data-target="#modalEdit"></span>
			                      </td>
			                      <td style="text-align: center;">'.$status_text.'</td>
			                    </tr>
			 ';
			}
			
		}
		if ($data_response['std_list']=='') {
			$data_response['std_list']='';
		}
		echo json_encode($data_response); 
	}
	public function get_class_level($class_level_data){
		if ($class_level_data=="p1") {
			$class_level="ป.1";
		}elseif($class_level_data=="p2"){
			$class_level="ป.2";	
		}elseif($class_level_data=="p3"){
			$class_level="ป.3";	
		}elseif($class_level_data=="p4"){
			$class_level="ป.4";	
		}elseif($class_level_data=="p5"){
			$class_level="ป.5";	
		}elseif($class_level_data=="p6"){
			$class_level="ป.6";	
		}elseif($class_level_data=="m1"){
			$class_level="ม.1";	
		}elseif($class_level_data=="m2"){
			$class_level="ม.2";	
		}elseif($class_level_data=="m3"){
			$class_level="ม.3";	
		}elseif($class_level_data=="m4"){
			$class_level="ม.4";	
		}elseif($class_level_data=="m5"){
			$class_level="ม.5";	
		}elseif($class_level_data=="m6"){
			$class_level="ม.6";	
		}
		return $class_level;
	}
	public function get_name_title($name_title_data){
		if ($name_title_data=="dekchai") {
			$name_title="เด็กชาย";
		}elseif($name_title_data=="dekying"){
			$name_title="เด็กหญิง";
		}elseif($name_title_data=="nai"){
			$name_title="นาย";
		}elseif($name_title_data=="nangsaw"){
			$name_title="นางสาว";
		}
		return $name_title;
	}

	public function getdata_edit($data_id){
		$data_response = array();	
		$this->sql ="SELECT  status
					FROM tbl_std_class_room
					WHERE DataID=$data_id
					
							";
		$this->select();
		$this->setRows();
		$data_response['status']=$this->rows[0]['status'];
		echo json_encode($data_response); 
	}
	public function get_year(){
		$data_response = array();	
		$this->sql ="SELECT  DISTINCT(year)
					FROM tbl_std_class_room
					WHERE class_level='p6'
					OR class_level='m3'
					OR class_level='m6'
					ORDER BY year DESC
							";
		$this->select();
		$this->setRows();
		foreach($this->rows as $key => $value) {
			$year=$value['year'];
			$data_response['year'].='
			 	<option "'.$year.'">'.$year.'</option>
			 ';
		}
		echo json_encode($data_response); 
	}

	
}
<file_sep>/assets/js/custom.js
function addTopMenu() {
	$('#leftMenu').css("animationName","menuSlide");
	setTimeout(function(){ $('#leftMenu').css("top","0px");}, 1000);		
}
function closeTopMenu(){
	$('#leftMenu').css("animationName","menuSlideClose");
	setTimeout(function(){ $('#leftMenu').css("top","-250px");}, 1000);	
}<file_sep>/modules/mobile_api/host/test.php
<?php	
	@session_start();

	require_once('config.php');
	require_once('src/database.php');
	include('class_modules.php');
	$class_data = new ClassData();
	##CLASS_DB_CONNECT##
	
	
    echo "string";


 ?><file_sep>/src/filemanager.class.php
<?php

class Filemanager 
{
	public $SOURCE;
	public $DESTINATION;
	
	public $FILES;
	public $FILES_PATH;
	public $FILES_ERROR;
	public $EXTENSION;
	
	public function __construct(){
		$this->FILES = null;
		$this->FILES_PATH = null;
		$this->FILES_ERROR = null;
		$this->EXTENSION = array("jpg","jpeg","gif","png");

	}
	
	protected function scan_files()
	{
		// Check Dir
		if(is_dir($this->SOURCE)){
			$files = scandir($this->SOURCE); // dir
			$this->FILES = $files;
			return $this;
		}
		
		// Check File
		if( !file_exists($this->SOURCE) ) return null;
		$this->FILES = $this->SOURCE; // file
		return $this;
	}
	
	protected function prepare()
	{
		if(is_array( $this->FILES )){
			// Cycle through all source files
			foreach ($this->FILES as $file) {
				if (in_array($file, array(".",".."))) continue;
				
				$ex = @explode(".",$file);
				$end = @end($ex);
				if (!in_array($end, $this->EXTENSION)) continue;
				
				$this->FILES_PATH[] = $this->SOURCE.$file;
			}
		}
		else{
			$this->FILES_PATH = array();
			$this->FILES_PATH[] = $this->SOURCE.$this->FILES;
		}	
	}
	
	public function clear()
	{
		$this->FILES = null;
		$this->FILES_PATH = null;
	}

	public function data( $source, $destination=null, $data=null)
	{
		$this->SOURCE = $source;
		$this->DESTINATION = $destination;
		if($data) 
			$this->FILES = $data;
		else
			self::scan_files(); //scan
		
		// Prepare
		self::prepare();
		
		return $this;
	}
	
	public function move( $source, $destination=null, $data=null)
	{			
		self::data($source, $destination, $data);
	
		$check_error = false;
		$key_error = array();
		if( $this->FILES_PATH ){
			foreach( $this->FILES_PATH as $key => $source_path ){
				// Check Copy Error
				if (!@copy($source_path, $this->DESTINATION.basename($source_path))) {
					$key_error[] = $key;
					$check_error = true;
				} 
			}
			
			if( $check_error === true ){
				foreach( $key_error as $key ){
					unset($this->FILES_PATH[$key]);
				}
			}
		}
		return $this;
	}
	
	public function delete()
	{
		if($this->FILES_PATH){
			foreach($this->FILES_PATH as $file) {
				if ( !is_dir($file) && file_exists($file)) {
					@unlink($file);
				}
					
			}		
		
			return sizeof($this->FILES_PATH);
		}
		return 0;
	}	
	
}

// Identify directories
//$source = BASE_PATH."img/progressbar.gif";
/* 
$source = BASE_PATH."img/";
$destination = HOME_PATH."file_managers/";
 
$u = new Filemanager();
echo '<pre>';
print_r($u);
$test = array('loading.gif');//,'progressbar.gif'
print_r($u->data($source,$destination,$test)->delete());
 */



<file_sep>/modules/conclusion/form/learning_result.php
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="../../../assets/css/bootstrap.css" rel="stylesheet" type="text/css">
<link href="../../../assets/css/margin-padding.css" rel="stylesheet" type="text/css">
<link href="../../../assets/css/responsive.css" rel="stylesheet" type="text/css">
<link href="../../../assets/css/print_conclusion.css?<?php echo date('l jS \of F Y h:i:s A'); ?>" rel="stylesheet" type="text/css">

<script type="text/javascript" src="../../../assets/js/jquery.js"></script>
<style type="text/css">
<!--
 table {
    border-collapse: collapse;
}
td, th {
    border: 1px solid black;
    padding: 2px;
}
-->
</style>
<?php

 @session_start();
include ('../logo.php');
require_once('../../../init.php');
include('../class_modules.php');
$class_data = new ClassData();

$class_label=$_GET['class_label'];
$room=$_GET['room'];
$term=$_GET['term'];
$year=$_GET['year'];

?>
<div style="background-color: rgb(82, 86, 89);min-height: 100%">
  <div style="font-size:16px;background-color: white;min-height: 100%;padding-right: 30px; padding-left: 30px;margin-right: auto;margin-left: auto;width: 80%">    
    <div style="page-break-after:always;">
      <page >
        <div style="text-align: center;line-height: 0.6;font-weight: bold;padding-top: 20px;font-size:18px">
          <img class="logo-print-size" src="<?php echo $image_logo ?>">
          <p >แบบประกาศผลการเรียนแยกตามระดับชั้น</p>
          <p >โรงเรียนเทศบาลวัดสระทอง สังกัดเทศบาลเมืองร้อยเอ็ด อ.เมือง จ.ร้อยเอ็ด</p>
          <p>
            <span style="margin-right: 30px;">ระดับชั้น <span style="font-weight: normal;">ประถมศึกษาปีที่ 1</span></span> 
            <span style="margin-right: 20px;">กลางปี</span>  
            <span>ปีการศึกษา <span style="font-weight: normal;">2560</span> </span>
          </p>
          <p style="margin-top: 20px;">
            <span style="margin-right: 40px;">ครูประจำชั้น 
              <span style="font-weight: normal;">.........................................................................................</span>
            </span>
            <span>ครูประจำชั้น 
              <span style="font-weight: normal;">.........................................................................................</span>
            </span>

          </p>
        </div>
        <table cellspacing="0"  style=" text-align: center; font-size: 16px;width:100%;margin-top: 20px;">
          <thead>
            <tr class="text-middle">
              <th rowspan="2" class="rotate" style="width: 3%;height: 0px;text-align: center;">
                <div >เลขที่</div>
              </th>
              <th rowspan="2" class="rotate" style="width: 5%;height: 0px;text-align: center;">
                <div >รหัส</div>
              </th>
              <th rowspan="2" style="width: 30%;vertical-align: middle;text-align: center;">ชื่อ-สกุล</th>
               <th  style="height: 70px;line-height: 1;width: 1%;text-align: center;">
                <div style="transform: rotate(-90deg);white-space: nowrap;">
                  ภาษาไทย
                </div>
              </th>
              <th  style="height: 70px;line-height: 1;width: 1%;text-align: center;">
                <div style="transform: rotate(-90deg);white-space: nowrap;">
                  ภาษาไทย
                </div>
              </th>
               <th  style="height: 70px;line-height: 1;width: 1%;text-align: center;">
                <div style="transform: rotate(-90deg);white-space: nowrap;">
                  ภาษาไทย
                </div>
              </th>
              <th  style="height: 70px;line-height: 1;width: 1%;text-align: center;">
                <div style="transform: rotate(-90deg);white-space: nowrap;">
                  ภาษาไทย
                </div>
              </th>
             
              <th  style="height: 70px;line-height: 1;width: 1%;text-align: center;">
                <div style="transform: rotate(-90deg);white-space: nowrap;">
                  คะแนนรวม
                </div>
              </th>
              <th  style="height: 70px;line-height: 1;width: 1%;text-align: center;">
                <div style="transform: rotate(-90deg);white-space: nowrap;">
                  ร้อยละ
                </div>
              </th>
              <th  style="height: 70px;line-height: 1;width: 1%;text-align: center;">
                <div style="transform: rotate(-90deg);white-space: nowrap;">
                  ลำดับที่
                </div>
              </th>
             
            </tr> 
            <tr>
              <th style="text-align: center;">100</th>
              <th style="text-align: center;">100</th>
              <th style="text-align: center;">100</th>
              <th style="text-align: center;">100</th>
              <th></th>
              <th></th>
              <th></th>
            </tr>

          </thead>
          <tbody >
            <tr>
              <td>1</td>
              <td>09323</td>
              <td>chanut chumjan</td>
              <td>20</td>
              <td>20</td>
              <td>20</td>
              <td>20</td>
              <td>20</td>
              <td>20</td>
              <td>20</td>
            </tr>

          </tbody>
        </table>
      </page>
    </div>

  </div>
</div>
<script>
/* $(document).ready(function() {
    get_print();
    setTimeout(window.close, 0);
  });
  function get_print() {
    window.print();
  }*/
</script><file_sep>/modules/maneger_student/edit.js
var opPage = 'maneger_student';
$(document).ready(function() {
	get_data_form();
}); 
function isNumber(data){
    data = data +"e1";                      // Disallow eng. notation "10e2"+"e1" is NaN
    var clean = parseFloat(data,10) / data ; // 1 if parsed cleanly
    return (clean && (data/data) === 1.0);  // Checks for NaN
}
function send_data() {
		var formData = $( "#frm_data" ).serializeArray();
		formData.push({ "name": "acc_action", "value": "save_data" }); 
		formData.push({ "name": "data_id", "value": _get.id});
		$.post('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {
			// console.log(data);
			// return false;
			window.location = 'index.php?op=maneger_student-index';
			$(".modal").modal("hide");
			$("#modalEdited").modal("show");
			$("#std_ID").attr( "placeholder", "" );
			$("#card_ID").attr( "placeholder", ""  );
			form_reset("frm_data");
			get_data_form(std_ID);
		});
}
$(document).delegate('#btn__save', 'click', function(event) {

	$("#std_ID").addClass("form-set");
	$("#card_ID").addClass("form-set");
	var std_ID =$("#std_ID").val();
	var card_ID =$("#card_ID").val();
	if(std_ID!='' && card_ID!='') {
		var num_card_ID=card_ID.length;
		if (num_card_ID>13) {
			$(".modal").modal("hide");
			$("#card_ID").removeClass("form-set");
			$("#card_ID").addClass("form-set-null-data");
			$("#card_ID").attr( "placeholder", "รหัสบัตรประชาชนเกิน 13 หลัก"  );
			$("#card_ID").val("");
		}else if(num_card_ID<13){
			$(".modal").modal("hide");
			$("#card_ID").removeClass("form-set");
			$("#card_ID").addClass("form-set-null-data");
			$("#card_ID").attr( "placeholder", "รหัสบัตรประชาชนไม่ถึง 13 หลัก"  );
			$("#card_ID").val("");
		}else{
			var card_id_sck=isNumber(card_ID);
			if (card_id_sck==true) {
				send_data();				
			}else{
				$(".modal").modal("hide");
				$("#card_ID").removeClass("form-set");
				$("#card_ID").addClass("form-set-null-data");
				$("#card_ID").attr( "placeholder", "ใส่ข้อมูลเป็นตัวเลขเท่านั้น"  );
				$("#card_ID").val("");
			}
			
		}


	}else{
		$(".modal").modal("hide");
		if(std_ID==""){
			$("#std_ID").removeClass("form-set");
			$("#std_ID").addClass("form-set-null-data");
			$("#std_ID").attr( "placeholder", "กรุณาใส่ข้อมูล" );
		}
		if(card_ID==""){
			$("#card_ID").removeClass("form-set");
			$("#card_ID").addClass("form-set-null-data");
			$("#card_ID").attr( "placeholder", "กรุณาใส่ข้อมูล" );
		}
	}
	

});
function get_data_form(std_ID) {
	var formData = new Array();
	formData.push({ "name": "acc_action", "value": "get_data_form" }); 
	formData.push({ "name": "data_id", "value": _get.id}); 
	formData.push({ "name": "new_data_id", "value": std_ID}); 
	
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus) {
	// console.log(data);
		$("#std_ID").val(data.std_ID);
		$("#card_ID").val(data.card_ID);

		var class_level_data=data.class_level;
		$("#calss_"+class_level_data).attr("selected","selected"); 

		var room_data=data.room;
		$("#room_"+room_data).attr("selected","selected");

		var name_title_data=data.name_title;
		$("#name_title_"+name_title_data).attr("selected","selected");

		
		$("#fname").val(data.fname);
		$("#lname").val(data.lname);

		var blood_group_data=data.blood_group;
		$("#blood_group_"+blood_group_data).attr("selected","selected");

		$("#address").val(data.address);
	
		$("#status_alive").val(data.status_alive);

		var parent_name_title_data=data.parent_name_title;
		$("#parent_name_title_"+parent_name_title_data).attr("selected","selected");

		$("#parent_fname").val(data.parent_fname);
		$("#parent_lname").val(data.parent_lname);
		$("#tell").val(data.tell);
		$("#parent_address").val(data.parent_address);


	});
}
function years_set() {
	var formData = new Array();
	formData.push({ "name": "acc_action", "value": "get_years" }); 
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {
		$("#years_set").html(data.set_years);
	});
}
function get_day(mouth) {
	//var formData = $( "#frm_data" ).serializeArray();
	var formData = new Array();
	formData.push({ "name": "acc_action", "value": "get_day" }); 
	formData.push({ "name": "mouth", "value": mouth }); 
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {
		console.log(data.day_set)
		$("#day_set").html(data.day_set);
	});

}<file_sep>/modules/regis_course/process.php
<?php
@ob_start();
@session_start();

require_once('../../init.php');
include('../../src/class.pagination.php');
include('../../src/class.inputfilter.php');
$InputFilter = new InputFilter();

##CLASS_DB_CONNECT##
include('class_modules.php');
$class_data = new ClassData();
##CLASS_DB_CONNECT##

if(isset($_GET['acc_action']) and $_GET['acc_action'] == "set_term_year"){	
	$term_set=$_GET['term_set'];
	$year_set=$_GET['year_set'];
	echo $class_data->set_term_year($term_set,$year_set);
}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_term_year_now"){	
	echo $class_data->get_term_year_now();
}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_data_year_search"){	
		echo $class_data->get_data_year_search();

}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_data_registered"){
		$data_term_search=$_GET['data_term_search'];
		$data_year_search=$_GET['data_year_search'];
		$chk_edit_after=$_GET['chk_edit_after'];
		$chk_teacher_icon=$_GET['chk_teacher_icon'];	
		$show_delete=$_GET['show_delete'];	
		echo $class_data->get_data_registered($data_term_search,$data_year_search,$chk_edit_after);

}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_data_registered_edit"){
		$data_term_search=$_GET['data_term_search_3'];
		$data_year_search=$_GET['data_year_search_3'];
		$chk_edit_after=$_GET['chk_edit_after'];
		$chk_teacher_icon=$_GET['chk_teacher_icon'];	
		$show_delete=$_GET['show_delete'];	
		echo $class_data->get_data_registered_edit($data_term_search,$data_year_search,$chk_edit_after);

}

if(isset($_GET['acc_action']) and $_GET['acc_action'] == "chk_regiseted_course"){	
		$data_val = $_GET['data_val'];
		$term = $_GET['term'];
		$year = $_GET['year'];
		echo $class_data->chk_regiseted_course($data_val,$term,$year);
}
if(isset($_POST['acc_action']) and $_POST['acc_action'] == "save_regis_course"){
		$data_val = $_POST['data_val'];
		//$term=$_POST['term'];
		//$year=$_POST['year'];
		$cdate="now()";	
		$class_data->insert_data_regis_course($data_val,$cdate);

}
if(isset($_POST['acc_action']) and $_POST['acc_action'] == "save_data"){
		$user_add=$_SESSION['ss_user_id'];
		$data_id_course=$_POST['data_id_course'];
		$arr_sql[]="courseID='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['courseID'])))."'";
		$arr_sql[]="user_add='".chkhtmlspecialchars($InputFilter->clean_script(trim($user_add)))."'";
		$arr_sql[]="name='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['name'])))."'";
		$arr_sql[]="class_level='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['class_level'])))."'";
		$arr_sql[]="unit='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['unit'])))."'";
		$arr_sql[]="department='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['department'])))."'";
		$arr_sql[]="hr_learn='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['hr_learn'])))."'";
		$arr_sql[]="status='".chkhtmlspecialchars($InputFilter->clean_script(trim($_POST['course_status'])))."'";
		
		$class_data->update_data($arr_sql,$data_id_course);
}

if(isset($_GET['acc_action']) and $_GET['acc_action'] == "remove_registed"){	
	$data_id = $_GET['data_id'];
	$data_term = $_GET['data_term'];
	$data_year = $_GET['data_year'];
	echo $class_data->remove_registed($data_id,$data_term,$data_year);

}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_teacher_to_course_registed"){	
	$registered_id = $_GET['registered_id'];
	echo $class_data->get_teacher_to_course_registed($registered_id);

}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "set_room_teacher"){	
	$course_teacher_id = $_GET['course_teacher_id'];
	$room_val = $_GET['room_val'];
	echo $class_data->set_room_teacher($course_teacher_id,$room_val);

}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_room_detail"){	
	$data_id_registered_room = $_GET['data_id_registered_room'];
	echo $class_data->get_room_detail($data_id_registered_room);

}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "insert_teacher_to_course"){	
	$teacher_id = $_GET['teacher_id'];
	$registered_id = $_GET['registered_id'];
	echo $class_data->insert_teacher_to_course($teacher_id,$registered_id);

}

if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_teacher_list"){	
	$data_id_registered = $_GET['data_id_registered'];
	$teacher_search_data = $_GET['teacher_search_data'];
	
	echo $class_data->get_teacher_list($data_id_registered,$teacher_search_data);

}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "getdata_edit"){	
	$data_id = $_GET['data_id'];
	echo $class_data->getdata_edit($data_id);

}
if(isset($_GET['acc_action']) and $_GET['acc_action'] == "get_data"){	
	$arr_search_val['courseID_search'] = $_GET['courseID_search'];
	$arr_search_val['department_search'] = $_GET['department_search'];
	$arr_search_val['class_level_search'] = $_GET['class_level_search'];
	$arr_search_val['status'] = $_GET['status'];
	
	echo $class_data->get_data($arr_search_val);
}<file_sep>/modules/profile/upload_one.php
<?php
@ob_start();
@session_start();

require_once('../../init.php');
include('../../src/class.pagination.php');
include('../../src/class.inputfilter.php');
$InputFilter = new InputFilter();

##CLASS_DB_CONNECT##
include('class_modules.php');
$class_data = new ClassData();
##CLASS_DB_CONNECT##

$file_path="../../file_managers/profile/";
		$user_id=$_SESSION['ss_user_id'];
		$ext=pathinfo(basename($_FILES['file_up']['name']),PATHINFO_EXTENSION);
		$new_file='file_'.uniqid().".".$ext;
		$up_path=$file_path.$new_file;
		$oldFileName=$_FILES['file_up']['name'];
		$upload=move_uploaded_file($_FILES['file_up']['tmp_name'], $up_path);
		if ($upload==false) {
			echo "no";
			exit();
		}
		$class_data->sql="SELECT * FROM tbl_regis_teacher_gallery WHERE regis_teacher_id=$user_id";
	    $class_data->select();  
	    $class_data->setRows(); 
	    $FileName=$class_data->rows[0]['FileName'];
		@unlink($file_path.$FileName);	

		$class_data->sql="DELETE FROM tbl_regis_teacher_gallery WHERE regis_teacher_id = $user_id";
		$class_data->query();

	 	$class_data->sql="INSERT INTO tbl_regis_teacher_gallery (regis_teacher_id,FileName) VALUES($user_id,'$new_file')";
	    $class_data->query();

	    echo json_encode("ok");  



?><file_sep>/modules/save_score/index.php
<?php session_start(); ?>

<div class="container set-content-pad-20" >
  <div class="bg-whte" style="position: relative;padding-bottom: 60px">
    <div class="circle-bg-violet">
      <img class="head-img-circle" src="assets/images/8.png">
    </div>
    <div class="text-head-title">
      <p>บันทึกคะแนน</p>
    </div>
    <div class="text-head-desc">
      <p>ใช้สำหรับการบันทึกคะแนนของนักเรียนในแต่ละรายวิชา</p>
    </div>
    <div class="row pd-40 pt-80 stage-set" >    
      <?php if($_SESSION['ss_status']==2){ ?>
      <div class="col-sm-12 col-xs-12 mt-30">                        
        <div class="set-line">
          <form id="frm_data_room_admin">        
               <p class="text-bold text-inline fs-16">เลือกภาคเรียน</p>
              <select id="term_data" name="term_data" class="form-control search-drop-sub-class mr-20">
                 <option value="1">1</option>
                            <option value="2">2</option>
                            <option selected="selected" value="1,2">1,2</option>
                </select>  
               <p class="text-inline fs-14">ปีการศึกษา</p>
              <select id="year_data" name="year_data" class="form-control search-drop-sub-years mr-20">

              </select>   
              <div id="btn_search_course_detail_admin" class="btn-search-save-score">
                <div class="btn-search">
                  <span class="glyphicon glyphicon-arrow-right" aria-hidden="true"></span>
                </div>  
              </div>
            </form>
          </div>
        </div>     
      <?php } ?>          
      <div class="col-sm-12 col-xs-12">                        
        <div class="set-line">
          <form id="frm_data_room">
            <p class="text-bold text-inline fs-16">เลือกรายวิชา</p>
            <select onchange="get_class_level()" id="coures_id_list" name="coures_id_list" class="form-control search-drop-sub-id mr-20">

            </select>
            <p class="text-inline fs-14">ชั้น</p>
            <p id="place_class_level" class="text-inline mr-20"></p>
            <span class="slash-class" style="display: none;">/</span>
              <select id="room_search" style="display: none;" name="room_search" class="form-control search-drop-sub-class mr-20">

              </select>  
              <div id="btn_search_course_detail" class="btn-search-save-score">
                <div class="btn-search">
                  <span class="glyphicon glyphicon-arrow-right" aria-hidden="true"></span>
                </div>  
              </div>

            </form>
          </div>
        </div>                     
      </div>
      <div class="row">
        <div class="hr-co-text-depart mt-nega-30"></div> 
      </div>
      <div id="course_detal_box" style="display: none;" class="ml-50 mr-50 mt-nega-10" >
        <div class="row">
          <div class="box-search-depart">
            <div class="set-line">
              <div id="rate_score_box" class="col-sm-12 col-xs-12" style="display: block;">  
                <div class="row">
                  <table>
                    <tbody style="border: none;">
                      <tr >
                        <td >
                          <p class="text-before-box3 text-bold" style="float: right;">รหัสวิชา</p>
                          
                        </td>
                        <td>
                          <p id="place_detail_courseID" class=" text-before-box2 " ></p> 
                        </td>

                        <td >
                          <p class="text-before-box3 text-bold">รายวิชา</p>
                          
                        </td>
                        <td width="300px">
                          <p id="place_detail_name" class=" text-before-box2 "></p> 
                        </td>

                        <td >
                          <p class="text-before-box3 text-bold">นก./น.น.</p>
                          
                        </td>
                        <td width="40px">
                          <p id="place_detail_unit" class=" text-before-box2 "></p> 
                        </td>

                        <td >
                          <p class="text-before-box3 text-bold">ชม./สัปดาห์</p>
                          
                        </td>
                        <td >
                          <p id="place_detail_hr_learn" class=" text-before-box2 "></p> 
                        </td>
                      </tr>
                      <tr >
                        <td class="text-before-box3 text-bold" style="float: right;">
                          ชั้น
                        </td>
                        <td>
                          <p id="place_detail_class_level" class=" text-before-box2 ">

                          </p> 
                        </td>

                      </tr>
                      <tr >
                        <td class="text-before-box3 text-bold" style="float: right;">
                          ช่วงคะแนน
                        </td> 
                        <td width="200px">
                          <form id="frm_data_legth_score">
                            <select id="legth_score" name="legth_score" class="form-control search-drop-ob-length mt-5">
                                                                 
                            </select> 
                          </form>

                        </td>
                        <td style="padding-left: 20px;">
                          <div class="btn-search-save-score ">
                            <div id="btn_get_config" class="btn-search">
                              <span class="glyphicon glyphicon-arrow-right" aria-hidden="true"></span>

                            </div>                                                                           
                          </div>    
                        </td>
                      </tr>
                    </tbody>                                         
                  </table>
                </div>                               
              </div>  
            </div>                              
          </div>
        </div>
      </div>
      <input id="data_registed_courseID" type="text" hidden="hidden" name="">
      <input id="data_objectiveID_of_title" type="text" hidden="hidden" name="">
      <input id="std_id_all" type="text" hidden="hidden" name="">
      <div id="place_config">

      </div>


    </div>   

  </div><file_sep>/modules/regis_course/class_modules.php
<?php 

class ClassData extends Databases {
	public function get_term_year_now(){
		$data_response = array();	
		$this->sql ="SELECT  *
					FROM tbl_set_term_year 				
							";
		$this->select();
		$this->setRows();
		$data_response['term']=$this->rows[0]['term'];
		$data_response['year']=$this->rows[0]['year'];
		$data_response['year_now']=date("Y")+543;
		$data_response['status_rang']=$_SESSION['ss_status_rang'];
		echo json_encode($data_response); 
	}
	public function set_term_year($term_set,$year_set){
		if($_SESSION['ss_status_rang']==1 || $_SESSION['ss_status_rang']==2){
			$this->sql ="UPDATE tbl_set_term_year SET year='$year_set' WHERE DataID=1" ;
			$this->query();
		}else{
			$this->sql ="UPDATE tbl_set_term_year SET term='$term_set',year='$year_set' WHERE DataID=1" ;
			$this->query();
		}
		return 1;
	}
	public function get_data_year_search(){
		$this->sql ="SELECT distinct(year)  
					FROM tbl_registed_course 
						";
		$this->select();
		$this->setRows();
		$data_response['year_list']='
							<option value="">ทั้งหมด</option>
		';
		foreach($this->rows as $key => $value) {
			$year=  $value['year'];	
			$data_response['year_list'].='
							<option value="'.$year.'">'.$year.'</option>
                           
			';
		}
		return json_encode($data_response);
	}
	public function get_term($unit_data,$status_data,$term){
		if ($unit_data==0) {
			if ($status_data==1) {
				$term="1,2";
			}else{
				$term=$term;
			}
			
		}else{
			$term=$term;
		}
		return $term;
	}
	public function get_name_course($courseID_send,$term,$year,$cdate,$chk_edit_after,$registed_courseID){
		$this->sql ="SELECT * FROM tbl_add_delete_course WHERE DataID=$courseID_send";
			$this->select();
			$this->setRows();
			$name= $this->rows[0]['name'];	
			$courseID=$this->rows[0]['courseID'];	
			$name=$this->rows[0]['name'];	
			$class_level_data=$this->rows[0]['class_level'];	
			$class_level= $this->get_class_level($class_level_data);
			$unit_data=$this->rows[0]['unit'];	
			$unit=$this->get_unit_data($unit_data);
			$department=$this->rows[0]['department'];	
			$hr_learn=$this->rows[0]['hr_learn'];	
			$status_data=$this->rows[0]['status'];	
			$status_form=$this->rows[0]['status_form'];	
			$status_form_text=$this->get_status_form($status_form);
			$term_new=$this->get_term($unit_data,$status_data,$term);
			$data_response='
								<tr>
                                 
                                  <td style="padding-left: 30px;">'.$courseID.'</td>
                                  <td>'.$name.'</td>
                                  <td>'.$status_form_text.'</td>
                                  <td style="text-align: center;">'.$unit.'</td>
                                  <td style="text-align: center;">'.$hr_learn.'</td>
                                  <td style="text-align: center;">'.$class_level.'</td>
                                 
                                 	'.$data_teacher_icon.'
                                  <td class="chk_delete_btn" style="display:block;text-align:center;">
                                  	<div class="btn_remove_registed" data-term="'.$term_new.'" data-year="'.$year.'" data-id="'.$registed_courseID.'"  aria-hidden="true" data-toggle="modal" data-target="#modalCancelRegister">
                                      <span class="glyphicon glyphicon-trash edit-icon-table"></span>
                                    </div>
                                  </td>
                                  
                                </tr>
			';
			return $data_response;

	}
	public function get_name_course_edit($courseID_send,$term,$year,$cdate,$chk_edit_after,$registed_courseID){
		$this->sql ="SELECT * FROM tbl_add_delete_course WHERE DataID=$courseID_send";
			$this->select();
			$this->setRows();
			$name= $this->rows[0]['name'];	
			$courseID=$this->rows[0]['courseID'];	
			$name=$this->rows[0]['name'];	
			$class_level_data=$this->rows[0]['class_level'];	
			$class_level= $this->get_class_level($class_level_data);
			$unit_data=$this->rows[0]['unit'];	
			$unit=$this->get_unit_data($unit_data);
			$department=$this->rows[0]['department'];	
			$hr_learn=$this->rows[0]['hr_learn'];	
			$status_data=$this->rows[0]['status'];	
			$status_form=$this->rows[0]['status_form'];
			$status_form_text=$this->get_status_form($status_form);
			$term_new=$this->get_term($unit_data,$status_data,$term);
			

				$sql = "SELECT COUNT(*) as num_row
						FROM tbl_regis_teacher  
						WHERE DataID in(
							SELECT teacher_id
							FROM tbl_course_teacher
							WHERE regis_course_id=$registed_courseID
						)
						";
				$this->sql = $sql;
				$this->select();
				$this->setRows();
				$num_row=$this->rows[0]['num_row'];
				if($num_row>0){
					$data_teacher_icon='
						 <td style="text-align: center;">
							 <img data-id-registered="'.$registed_courseID.'" style="width:20px;margin-top: -8px;margin-left: 5px;" class="edit-icon-table btn_teacher_list" aria-hidden="true" data-toggle="modal" data-target="#modalMenageTeacher" src="assets/images/check_person.png">
							 </td>
				';
				$sql = "SELECT COUNT(*) as num_row_room
						FROM tbl_room_teacher  
						WHERE course_teacherID in(
							SELECT DataID
							FROM tbl_course_teacher
							WHERE regis_course_id=$registed_courseID
						)
						";
				$this->sql = $sql;
				$this->select();
				$this->setRows();
				$num_row_room=$this->rows[0]['num_row_room'];
				if ($num_row_room>0) {
					$data_room_icon='
						 <td style="text-align: center;">
                                  	<img data-id-registered-room="'.$registed_courseID.'" style="width:26px;margin-top: -8px;margin-left: 5px;" class="edit-icon-table btn_room_detail" aria-hidden="true" data-toggle="modal" data-target="#modalMenageRoom" src="assets/images/glyphicons-200-ban-circle.png">
                                  </td>
				';
				}else{
					$data_room_icon='
						 <td style="text-align: center;">
                                  	<img data-id-registered-room="'.$registed_courseID.'" style="width:20px;margin-top: -8px;" class="edit-icon-table btn_room_detail" aria-hidden="true" data-toggle="modal" data-target="#modalMenageRoom" src="assets/images/glyphicons-44-group.png">
                                  </td>
				';
				}
				
				}else{
					$data_teacher_icon='
							 <td  style="text-align: center;">
							 	<span data-id-registered="'.$registed_courseID.'" class="glyphicon glyphicon glyphicon-user edit-icon-table btn_teacher_list" aria-hidden="true" data-toggle="modal" data-target="#modalMenageTeacher"></span>
							 </td>
				';
				$data_room_icon='
						 <td style="text-align: center;">
                                  	<img  style="width:20px;margin-top: -8px;" src="assets/images/glyphicons-44-group.png">
                                  </td>
				';
				}

			$data_response='
								<tr>
                                 
                                  <td style="padding-left: 30px;">'.$courseID.'</td>
                                  <td>'.$name.'</td>
                                  <td>'.$status_form_text.'</td>
                                  
                                  <td style="text-align: center;">'.$unit.'</td>
                                  <td style="text-align: center;">'.$hr_learn.'</td>
                                  <td style="text-align: center;">'.$class_level.'</td>
                                 	'.$data_teacher_icon.'
                                  	'.$data_room_icon.'
                                </tr>
			';
			return $data_response;

	}
	public function get_data_registered($data_term_search,$data_year_search,$chk_edit_after,$chk_teacher_icon,$show_delete){
		$this->sql ="SELECT  *
					FROM tbl_set_term_year 				
							";
		$this->select();
		$this->setRows();
		$term=$this->rows[0]['term'];
		$year=$this->rows[0]['year'];
		$this->sql ="SELECT * 
					FROM tbl_registed_course 
					WHERE term='$term'
					AND year='$year'
					OR term='1,2'
					AND year='$year'

					";
		$this->select();
		$this->setRows();
		foreach($this->rows as $key => $value) {
			$registed_courseID=  $value['DataID'];	
			$courseID=  $value['courseID'];	
			$term=  $value['term'];
			$year=  $value['year'];
			$cdate=  $value['cdate'];
			$data_response['course'].=$this->get_name_course($courseID,$term,$year,$cdate,$chk_edit_after,$registed_courseID,$chk_teacher_icon,$show_delete);
		}	
		if ($data_response['course']=='') {
			$data_response['course']='';
		}
		echo json_encode($data_response);
	}
	
	public function get_data_registered_edit($data_term_search,$data_year_search,$chk_edit_after,$chk_teacher_icon,$show_delete){
		
		$this->sql ="SELECT  *
					FROM tbl_set_term_year 				
							";
		$this->select();
		$this->setRows();
		$term=$this->rows[0]['term'];
		$year=$this->rows[0]['year'];
		$this->sql ="SELECT * 
				FROM tbl_registed_course 
				WHERE term='$term'
				AND year='$year'
				OR term='1,2'
				AND year='$year'
				";
		$this->select();
		$this->setRows();
		foreach($this->rows as $key => $value) {
			$registed_courseID=  $value['DataID'];	
			$courseID=  $value['courseID'];	
			$term=  $value['term'];
			$year=  $value['year'];
			$cdate=  $value['cdate'];
			$data_response['course'].=$this->get_name_course_edit($courseID,$term,$year,$cdate,$chk_edit_after,$registed_courseID,$chk_teacher_icon,$show_delete);
		}	
		if ($data_response['course']=='') {
			$data_response['course']='';
		}
			echo json_encode($data_response);

	}
	public function get_course_name($courseID){
		$this->sql ="SELECT * FROM tbl_add_delete_course WHERE DataID=$courseID";
			$this->select();
			$this->setRows();
			$name= $this->rows[0]['name'];	
			$courseID=$this->rows[0]['courseID'];	
			$data_response.='<p>'.$courseID.' : '.$name.'</p>';
			return $data_response;

	}
	public function chk_regiseted_course($data_val){
		$this->sql ="SELECT * FROM tbl_set_term_year";
		$this->select();
		$this->setRows();		
		$term= $this->rows[0]['term'];	
		$year= $this->rows[0]['year'];

		$course_name="";
		$arr_id = explode(",", $data_val);
		for ($i=0; $i < count($arr_id) ; $i++) { 
			$this->sql ="SELECT * FROM tbl_add_delete_course WHERE DataID={$arr_id[$i]} ";
			$this->select();
			$this->setRows();	
			$class_level=$this->rows[0]['class_level'];	
			if ($class_level=='p1' || $class_level=='p2' || $class_level=='p3' || $class_level=='p4' || $class_level=='p5' || $class_level=='p6') {
				$term="1,2";
			}

			$this->sql ="SELECT * FROM tbl_registed_course WHERE courseID={$arr_id[$i]} AND term='$term' AND year='$year'";
			$this->select();
			$this->setRows();	
			$courseID=$this->rows[0]['courseID'];		
			if ($courseID!="") {
				$course_name.=$this->get_course_name($courseID);
			}
			
		}
			echo json_encode($course_name);
	}
	public function insert_data_regis_course($data_val,$cdate){
		
		$this->sql ="SELECT * FROM tbl_set_term_year";
		$this->select();
		$this->setRows();		
		$term= $this->rows[0]['term'];	
		$year= $this->rows[0]['year'];	

		$arr_id = explode(",", $data_val);
		$num=0;
		for ($i=0; $i < count($arr_id) ; $i++) { 
			$this->sql ="SELECT * FROM tbl_add_delete_course WHERE DataID={$arr_id[$i]}";
			$this->select();
			$this->setRows();
			$class_level= $this->rows[0]['class_level'];	
			$status= $this->rows[0]['status'];
			if ($class_level=='p1' || $class_level=='p2' || $class_level=='p3' || $class_level=='p4' || $class_level=='p5' || $class_level=='p6') {
				$term="1,2";
			}
			$this->sql ="INSERT INTO tbl_registed_course(courseID,term,year,cdate) VALUES({$arr_id[$i]},'$term','$year',$cdate)";
	        $this->query();
	        $new_id = $this->insertID();

	        $this->sql ="INSERT INTO tbl_set_count_adttend_class(registed_courseID,week_name) VALUES($new_id,20)";
	        $this->query();
            $num=$num+$i;
		}
		return $num;
	}
	public function update_data($update,$data_id_course){

		$this->sql = "UPDATE tbl_add_delete_course 
					SET ".implode(",",$update)." 
					WHERE DataID='".$data_id_course."'";
		$this->query();
	}
	public function get_department($department_data){	
		if ($department_data=="1") {
			$department='dep_1';		
		}elseif($department_data=="2"){
			$department='dep_2';			
		}elseif($department_data=="3"){
			$department='dep_3';			
		}elseif($department_data=="4"){
			$department='dep_4';			
		}elseif($department_data=="5"){
			$department='dep_5';			
		}elseif($department_data=="6"){
			$department='dep_6';			
		}elseif($department_data=="7"){
			$department='dep_7';			
		}elseif($department_data=="8"){
			$department='dep_8';			
		}
		return $department;
	}
	public function remove_registed($data_id,$data_term,$data_year){	
		$data_response = array();
		$sql = "DELETE 
				FROM tbl_registed_course
				WHERE DataID=$data_id
				";
		$this->sql = $sql;
		$this->query();

		return 0;

	}
	public function get_unit($unit_data){	
		if ($unit_data=="0.5") {
			$unit='05';
		}elseif($unit_data=="1.0"){
			$unit='10';
		}elseif($unit_data=="1.5"){
			$unit='15';
		}elseif($unit_data=="2.0"){
			$unit='20';
		}elseif($unit_data=="2.5"){
			$unit='25';
		}elseif($unit_data=="3.0"){
			$unit='30';
		}
		return $unit;
	}
	
	public function set_room_teacher($course_teacher_id,$room_val){
		$sql = "SELECT COUNT(*) AS num_row
				 	FROM tbl_room_teacher 
				    WHERE course_teacherID=$course_teacher_id
				    AND room=$room_val
				";
			$this->sql = $sql;
			$this->select();
			$this->setRows();
		$num_row=$this->rows[0]['num_row'];
		if ($num_row>0) {
			$this->sql ="
						DELETE 
						FROM tbl_room_teacher
						WHERE course_teacherID=$course_teacher_id
						AND room=$room_val 
				";
	        $this->query();
	        $new_id = $this->insertID();
		}else{
			$this->sql ="INSERT INTO tbl_room_teacher(course_teacherID,room)
					 VALUES($course_teacher_id,$room_val)";
	        $this->query();
	        $new_id = $this->insertID();
		}
		
	        return $new_id;
	}
	public function get_room_detail($registered_id){	

		$sql = "SELECT tbl_add_delete_course.courseID,tbl_add_delete_course.name ,tbl_add_delete_course.class_level,tbl_registed_course.term,tbl_registed_course.year
				FROM  tbl_add_delete_course,tbl_registed_course
				WHERE tbl_add_delete_course.DataID=tbl_registed_course.courseID
				AND tbl_registed_course.DataID=$registered_id
				";
		$this->sql = $sql;
		$this->select();
		$this->setRows();
		
		$courseID=$this->rows[0]['courseID'];	
		$name=$this->rows[0]['name'];
		$term=$this->rows[0]['term'];
		$year=$this->rows[0]['year'];
		$class_level_data=$this->rows[0]['class_level'];
		$class_level=$this->get_class_level($class_level_data);
		$data_response['course_detail_header']='
					<p style="color: black;text-align: left;">
		              <span class="ml-20">รหัสวิชา : </span><span>'.$courseID.'</span> 
		              <span class="ml-20">รายวิชา : </span><span>'.$name.'</span>
		              <span class="ml-20">ระดับชั้น : </span><span>'.$class_level.'</span> 
		             
		            </p>
		            <p style="color: black;text-align: left;">
		              <span class="ml-20">ภาคเรียนที่ : </span><span>'.$term.'</span>
		              <span class="ml-20">ปีการศึกษา : </span><span>'.$year.'</span>
		            </p>
		';		
		$sql = "SELECT * FROM tbl_course_teacher 
				WHERE regis_course_id=$registered_id
				";
		$this->sql = $sql;
		$this->select();
		$this->setRows();
		foreach($this->rows as $key => $value) {
			$DataID=$value['DataID'];	
			$teacher_id=$value['teacher_id'];
			$teacher_detail=$this->get_teacher_detail($teacher_id);
			$room_list=$this->get_room_list($DataID);
			$data_response['teacher_list_box'].='
					<div class="panel panel-violet">
			          <div class="panel-heading">
			             <h3 class="panel-title text-left">'.$teacher_detail.' : รับผิดชอบสอนห้อง</h3>
			          </div>
			          <div class="panel-body">
			            <form>
			              <div style="text-align: left;padding-left: 12%;">
			                '.$room_list.'
			              </div>
			               
			            </form>
			          </div>
			        </div>
			';
		}
		echo json_encode($data_response);
	}
	public function get_room_list($course_teacherID){	
		$data_response.='<p >';
		for ($i=1; $i <=5 ; $i++) { 
			$sql = "SELECT COUNT(*) AS num_row
				 	FROM tbl_room_teacher 
				    WHERE course_teacherID=$course_teacherID
				    AND room=$i
				";
			$this->sql = $sql;
			$this->select();
			$this->setRows();
			$num_row=$this->rows[0]['num_row'];
			if ($num_row>0) {
				$chk_status='checked';	
			}else{
				$chk_status='';
			}
			$data_response.='
		                 <label class="checkbox-inline mr-30">
		                  <input '.$chk_status.' class="room_btn_chk" type="checkbox" course-teacher-id="'.$course_teacherID.'" 
		                  	value="'.$i.'"> '.$i.'
		                  </label>        
			';
		}
		$data_response.='</p>';
		$data_response.='<p>';
		for ($i=6; $i <=10 ; $i++) { 
			$sql = "SELECT COUNT(*) AS num_row
				 	FROM tbl_room_teacher 
				    WHERE course_teacherID=$course_teacherID
				    AND room=$i
				";
			$this->sql = $sql;
			$this->select();
			$this->setRows();
			$num_row=$this->rows[0]['num_row'];
			if ($num_row>0) {
				$chk_status='checked';	
			}else{
				$chk_status='';
			}
			$data_response.='

		                 <label class="checkbox-inline mr-30">
		                  <input '.$chk_status.' class="room_btn_chk" type="checkbox" course-teacher-id="'.$course_teacherID.'" 
		                  	value="'.$i.'"> '.$i.'
		                  </label>

			';
		}
		$data_response.='</p>';
		return $data_response;
	}
	public function get_teacher_detail($teacher_id){	
		$sql = "SELECT * FROM tbl_regis_teacher 
				WHERE DataID=$teacher_id
				";
		$this->sql = $sql;
		$this->select();
		$this->setRows();
		$fname_th=$this->rows[0]['fname_th'];
		$lname_th=$this->rows[0]['lname_th'];
		return $fname_th.' '.$lname_th;
	}
	public function get_teacher_to_course_registed($registered_id){	
		$sql = "SELECT COUNT(*) as num_row
				FROM tbl_regis_teacher  
				WHERE DataID in(
					SELECT teacher_id
					FROM tbl_course_teacher
					WHERE regis_course_id=$registered_id
				)
				";
		$this->sql = $sql;
		$this->select();
		$this->setRows();
		$num_row=$this->rows[0]['num_row'];
		
		if ($num_row>0) {
			$number=1;
			$sql = "SELECT * FROM tbl_regis_teacher 
				WHERE DataID in(
					SELECT teacher_id
					FROM tbl_course_teacher
					WHERE regis_course_id=$registered_id
				)
				";
			$this->sql = $sql;
			$this->select();
			$this->setRows();
			foreach($this->rows as $key => $value) {
				$DataID=$value['DataID'];	
				$fname_th= $value['fname_th'];	
				$lname_th= $value['lname_th'];	
				$data_response['teacher_listed'].='<p style="text-align:left;">'.$number.'. '.$fname_th.' '.$lname_th.'</p>';		
				if ($num_row==$number) {
					$data_response['teacher_id'].=$DataID;
				}else{
					$data_response['teacher_id'].=$DataID.'-';
				}
				$number++;
			}
		}else{
			$data_response['teacher_listed'].='<p style="text-align:left;">ยังไม่เลือกครูผู้สอน</p>';
		}
		$data_response['num']=$num_row;
		echo json_encode($data_response);
	}
	public function insert_teacher_to_course($teacher_id,$registered_id){	
		$sql = "SELECT COUNT(*) as num_row
				FROM tbl_course_teacher
				WHERE regis_course_id=$registered_id
				";
		$this->sql = $sql;
		$this->select();
		$this->setRows();
		$num_row=$this->rows[0]['num_row'];

		$cdate=date("Y-m-d");
		if ($num_row>0) {
			$sql = "SELECT COUNT(*) as num_row_teacher
				FROM tbl_course_teacher
				WHERE regis_course_id=$registered_id
				AND teacher_id=$teacher_id
				";
			$this->sql = $sql;
			$this->select();
			$this->setRows();
			$num_row_teacher=$this->rows[0]['num_row_teacher'];
			if ($num_row_teacher>0) {
				$this->sql = "DELETE FROM tbl_course_teacher WHERE teacher_id=$teacher_id AND regis_course_id=$registered_id";
				$this->query();

				$sql = "SELECT COUNT(*) as num_row
				FROM tbl_course_teacher
				WHERE regis_course_id=$registered_id
				";
				$this->sql = $sql;
				$this->select();
				$this->setRows();
				$num_row=$this->rows[0]['num_row'];
				if($num_row==0) {
					$this->sql = "DELETE FROM tbl_registed_course_teaching WHERE registed_courseID=$registered_id" ;
					$this->query();
				}

			}else{
				$this->sql = "INSERT INTO tbl_course_teacher(teacher_id,regis_course_id) VALUES($teacher_id,$registered_id)";
				$this->query();
			}
		}else{
			$this->sql = "INSERT INTO tbl_course_teacher(teacher_id,regis_course_id) VALUES($teacher_id,$registered_id)";
				$this->query();
			$this->sql = "INSERT INTO tbl_registed_course_teaching(registed_courseID,cdate) VALUES($registered_id,'$cdate')";
			$this->query();
		}	
		return '1';
	}
	public function get_teacher_list($data_id_registered,$teacher_search_data){	
		$data_response = array();
		if ($teacher_search_data!='') {
			$sql_condition="AND fname_th LIKE '%$teacher_search_data%' OR lname_th LIKE '%$teacher_search_data%'";
		}else{
			$sql_condition="";
		}
		$sql = "SELECT * 
				FROM tbl_regis_teacher
				WHERE status_alive=1
				AND status=1
				$sql_condition
				";
		$this->sql = $sql;
		$this->select();
		$this->setRows();
		foreach($this->rows as $key => $value) {
			$DataID= $value['DataID'];	
			$fname_th= $value['fname_th'];	
			$lname_th= $value['lname_th'];	

			$data_list.='
						<tr>
	                        <td><input class="checkbox_data_teacher_'.$DataID.'" onclick="insert_teacher_to_course('.$DataID.','.$data_id_registered.')" type="checkbox" value="'.$DataID.'" name="checkbox_regis_teacher_to_course[]" id="checkbox'.$DataID.'"></td>
	                        <td style="text-align:left;padding-left: 30px;">'.$fname_th.'</td>
	                        <td style="text-align:left;padding-left: 30px;">'.$lname_th.'</td>
	                      </tr>
			';
		}
		if ($data_list=='') {
			$data_list='';
		}
		return json_encode($data_list);

	}
	public function getdata_edit($data_id){	
		$data_response = array();
		$sql = "SELECT * 
				FROM tbl_add_delete_course
				WHERE DataID=$data_id
				";
		$this->sql = $sql;
		$this->select();
		$this->setRows();
		$data_response['data_id_course']=$this->rows[0]['DataID'];
		$data_response['courseID']=$this->rows[0]['courseID'];
		$data_response['name']=$this->rows[0]['name'];
		$data_response['class_level']=$this->rows[0]['class_level'];
		$unit_data=$this->rows[0]['unit'];
		$data_response['unit']=$this->get_unit($unit_data);
		$department_data=$this->rows[0]['department'];
		$data_response['department']=$this->get_department($department_data);
		$data_response['hr_learn']=$this->rows[0]['hr_learn'];
		$data_response['status']=$this->rows[0]['status'];
		return json_encode($data_response);

	}
	public function get_class_level($class_level_data){
		if ($class_level_data=="p1") {
			$class_level="ป.1";
		}elseif($class_level_data=="p2"){
			$class_level="ป.2";	
		}elseif($class_level_data=="p3"){
			$class_level="ป.3";	
		}elseif($class_level_data=="p4"){
			$class_level="ป.4";	
		}elseif($class_level_data=="p5"){
			$class_level="ป.5";	
		}elseif($class_level_data=="p6"){
			$class_level="ป.6";	
		}elseif($class_level_data=="m1"){
			$class_level="ม.1";	
		}elseif($class_level_data=="m2"){
			$class_level="ม.2";	
		}elseif($class_level_data=="m3"){
			$class_level="ม.3";	
		}elseif($class_level_data=="m4"){
			$class_level="ม.4";	
		}elseif($class_level_data=="m5"){
			$class_level="ม.5";	
		}elseif($class_level_data=="m6"){
			$class_level="ม.6";	
		}
		return $class_level;
	}
	 function get_unit_data($unit_data){
		if ($unit_data==0.0 || $unit_data==9.9) {
			$unit="-";
		}else{
			$unit=$unit_data;
		}
		return $unit;
	}
	public function get_data($arr_search_val){
		$data_response = array();
		$sql_condition = " DataID > 0 ";
		$status = $arr_search_val['status'];
		$courseID_search = $arr_search_val['courseID_search'];
		$department_search = $arr_search_val['department_search'];
		$class_level_search = $arr_search_val['class_level_search'];

		if ($status!=1) {
			if (isset($courseID_search) && $courseID_search != "") {
				$sql_condition .= " AND ( courseID LIKE '%{$courseID_search}%')  ";
			}
			if (isset($department_search) && $department_search != "") {
				if ($department_search=="dev_mode") {
					$sql_condition .= " AND ( status=2 ) ";
				}else{
					$sql_condition .= " AND ( department = '$department_search')  ";
				}
			}
			if (isset($class_level_search) && $class_level_search != "") {
				$sql_condition .= " AND ( class_level = '$class_level_search')  ";
			}
		}else{
			if (isset($courseID_search) && $courseID_search != "") {
				$sql_condition .= " AND ( courseID LIKE '%{$courseID_search}%')  ";
			}
		}
		
		$sql = "SELECT count(*) as num_row_count
				FROM tbl_add_delete_course
				WHERE $sql_condition
				ORDER BY DataID DESC
				";
		$this->sql = $sql;
		$this->select();
		$this->setRows();		
		$num_row_count=$this->rows[0]['num_row_count'];

		$sql = "SELECT * 
				FROM tbl_add_delete_course
				WHERE $sql_condition
				ORDER BY DataID DESC
				";
		$this->sql = $sql;
		$this->select();
		$this->setRows();
		if ($num_row_count!=0) {
		foreach($this->rows as $key => $value) {
			$DataID= $value['DataID'];	
			$courseID= $value['courseID'];	
			$name= $value['name'];	
			$class_level_data= $value['class_level'];
			$class_level=$this->get_class_level($class_level_data);
			$unit_data= $value['unit'];	
			$status_form= $value['status_form'];	
			$status_form_text=$this->get_status_form($status_form);
			$unit=$this->get_unit_data($unit_data);
			
			$hr_learn= $value['hr_learn'];		
			$data_response['table_list'].='
							<tr>
                                  <td>      
                                    <input class="checkbox_data" type="checkbox" value="'.$DataID.'" name="checkbox_regis_course[]" id="checkbox'.$DataID.'">             
                                  </td>
                                  <td>'.$courseID.'</td>
                                  <td>'.$name.'</td>
                                  <td>'.$status_form_text.'</td>
                                  <td style="text-align: center;">'.$unit.'</td>
                                  <td style="text-align: center;">'.$hr_learn.'</td>
                                  <td style="text-align: center;">'.$class_level.'</td>
                                  
                                </tr>
			';
			}
		}else{
			$data_response['table_list'].='';
		}
		return json_encode($data_response);
	}
	
	public function get_status_form($status_form){
		switch ($status_form) {
			case '11':
				$data_response='พื้นฐาน';
				break;
			case '12':
				$data_response='เพิ่มเติม';
				break;
			case '21':
				$data_response='กิจกรรมพัฒนาผู้เรียน';
				break;
			case '22':
				$data_response='กิจกรรมพัฒนาผู้เรียน';
				break;
			case '23':
				$data_response='กิจกรรมพัฒนาผู้เรียน';
				break;
			case '24':
				$data_response='กิจกรรมพัฒนาผู้เรียน';
				break;
			case '25':
				$data_response='กิจกรรมพัฒนาผู้เรียน';
				break;
			case '26':
				$data_response='กิจกรรมพัฒนาผู้เรียน';
				break;
			case '27':
				$data_response='กิจกรรมพัฒนาผู้เรียน';
				break;
			default:
				$data_response='';
				break;
		}
		return $data_response;
	}
}<file_sep>/modules/report_std_personal/report_form_p.php
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="../../assets/css/bootstrap.css" rel="stylesheet" type="text/css">
<link href="../../assets/css/margin-padding.css" rel="stylesheet" type="text/css">
<link href="../../assets/css/responsive.css" rel="stylesheet" type="text/css">
<link href="../../assets/css/print_std_personal.css?<?php echo date('l jS \of F Y h:i:s A'); ?>" rel="stylesheet" type="text/css">

<script type="text/javascript" src="../../assets/js/jquery.js"></script>
<style type="text/css">
<!--
 table {
    border-collapse: collapse;
}
td, th {
    border: 1px solid black;
    padding: 2px;
}
-->
</style>
<?php

 @session_start();

require_once('../../init.php');
include('class_modules.php');
$class_data = new ClassData();

$std_ID=$_GET['std_ID'];

$term=$_GET['term'];
$year=$_GET['year'];

?>
<div style="background-color: rgb(82, 86, 89);min-height: 100%">
<div class="container" style="font-size: 10%;background-color: white;min-height: 100%">

<?php
  $arr_id = explode(",", $std_ID);
    for ($i=0; $i < count($arr_id) ; $i++) { 
    $pw6_p=$class_data->get_pw6_p($arr_id[$i],$term,$year);
?>
<div style="page-break-after:always;">
 <page> 
  <p style="position: absolute;right: 30px;top: 30px;font-size: 20px;">ปพ.6</p>
  <div class="col-sm-12 " style="font-size: 18px;margin-top: 52px;line-height: 0.9;">
      <p class="text-bold text-center" style="margin-top: -8px;">รายงานการพัฒนาคุณภาพผู้เรียนเป็นรายบุคคล</p>
      <p class="text-bold text-center" style="line-height: 0.3">โรงเรียนเทศบาลวัดสระทอง สังกัดเทศบาลเมืองร้อยเอ็ด อำเภอเมือง จังหวัดร้อยเอ็ด</p>
      <p style="margin-left: 40px;">
        <span class="text-bold">ขื่อ-สกุล</span> <?php echo $pw6_p['std_name']; ?> 
        <span style="position: absolute;left: 42%"><span class="text-bold" >เลขที่</span> 1 </span>
        <span style="position: absolute;left: 53.2%"><span class="text-bold" style="margin-left:80px;">เลขประจำตัวนักเรียน</span> <?php echo $pw6_p['std_ID']; ?></span>
      </p>
     <p style="line-height: 0.5;margin-left: 40px;">
      <span class="text-bold">ประถมศึกษาปีที่</span> <?php echo $pw6_p['class_level_room']; ?> 
      <span class="text-bold" style="margin-left:165px;">ปีการศึกษา</span> <?php echo $pw6_p['year']; ?> 
      <span class="text-bold" style="margin-left:80px;">เลขประจำตัวประชาชน</span> <?php echo $pw6_p['card_ID']; ?>
    </p>
      

    </div>
    <div>
      <table style="width: 94%;margin-left: 20px;margin-top: 20px;font-size: 16px;">
        <thead style="font-weight: bold;text-align: center;background-color: #ddddddb3;">
          <tr>
            <th colspan="11" style="text-align: center;">การพัฒนาคุณภาพผู้เรียน</th>
          </tr>
          <tr>
            <th  rowspan="2" style="width: 5%;text-align: center;">ที่</th>
            <th  rowspan="2" style="text-align: center;">กลุ่มสาระการเรียนรู้</th>
            <th  rowspan="2" style="width: 10%;text-align: center;">รหัสวิชา</th>
            <th  rowspan="2" style="width: 5%;padding: 0;text-align: center;">
              <div style="transform: rotate(-90deg);white-space: nowrap;">
                น้ำหนัก
              </div>
            </th>
            <th  style="height: 70px;line-height: 1;width: 1%;text-align: center;">
              <div style="transform: rotate(-90deg);white-space: nowrap;">
                คะแนน<br>ภาคเรียนที่ 1
              </div>
            </th>
            <th  style="line-height: 1;width: 1%;text-align: center;">
              <div style="transform: rotate(-90deg);white-space: nowrap;">
                คะแนน<br>ภาคเรียนที่ 2
              </div>
            </th>
            <th  style="width: 1%;text-align: center;">
              <div style="transform: rotate(-90deg);white-space: nowrap;">
                คะแนนรวม
              </div>
            </th>
            <th  rowspan="2" style="width: 14%;text-align: center;">ระดับ<br>ผลการเรียนเฉลี่ย<br>(GPA)</th>
            <th  rowspan="2" style="width: 5%;padding: 0;text-align: center;">
              <div style="transform: rotate(-90deg);white-space: nowrap;margin-left: -10px;margin-right: -10px;">
               คุณลักษณะฯ
             </div>
            </th>
            <th  rowspan="2" style="width: 5%;padding: 0;text-align: center;">
              <div style="transform: rotate(-90deg);white-space: nowrap;margin-left: -10px;margin-right: -10px;">
                อ่าน เขียนฯ
              </div>
            </th>
            <th  rowspan="2" style="width: 5%;padding: 0;text-align: center;">
              <div style="transform: rotate(-90deg);white-space: nowrap;margin-left: -10px;margin-right: -10px;">
                หมายเหตุ
              </div>
            </th>
          </tr>
         
          <tr>
            <th style="text-align: center;">50</th>
            <th style="text-align: center;">50</th>
            <th style="text-align: center;">100</th>
          </tr>
           
        </thead>
        <tbody style="text-align: center;">
         <tr >
            <td colspan="3" style="text-align: left;font-weight: bold;">รายวิชาพื้นฐาน</td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
          </tr>
          <?php 
            if ($pw6_p['sub_main_list']=='') {?>
        
            <tr style="height: 34px;">
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
          </tr>
          <?php }else{ ?>
         <?php echo $pw6_p['sub_main_list']; ?>
         <?php } ?>
          <tr>
            <td colspan="3" style="text-align: left;font-weight: bold;">รายวิชาเพิ่มเติม</td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
          </tr>
          <?php 
            if ($pw6_p['sub_add_list']=='') {?>
       
          <tr style="height: 34px;">
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
          </tr>
          <?php }else{ ?>
           <?php echo $pw6_p['sub_add_list']; ?>
         <?php } ?>
           <?php echo $pw6_p['sub_sum_list']; ?>
          <tr style="background-color: #ddddddb3;" >
            <th colspan="2">กิจกรรมพัฒนาผู้เรียน</th>
            <th style=";text-align: center;"></th>
            <th></th>          
            <th></th>         
            <th></th>
            <th></th>
            <th style=";text-align: center;">ผลการประเมิน</th>
            <th></th>
            <th></th>
            <th></th>
          </tr>
          <?php 
            if ($pw6_p['sub_dev_list']=='') {?>
            <tr style="height: 34px;">
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
          </tr>
            <?php }else{ ?>
          <?php echo $pw6_p['sub_dev_list']; ?>
          <?php } ?>
        </tbody>
      </table>
    </div>
    <div style="margin-top: 30px;">
      <table style="width: 40%;margin-left: 20px;margin-top: 20px;font-size: 16px;">
        <?php echo $pw6_p['sub_conclution_list']; ?>
      </table>
    </div>
    <div class="printOnly" style=" margin-top: -240px;font-size:16px;margin-left: 450px;line-height: 0.7;">
      <div>
        <p>......................................................... ครูประจำชั้น</p>
        <p><span style="margin-right: 145px;">(</span><span>)</span></p>
        <p style="margin-left: 16px;">................./.............../...............</p>
      </div>
      <div style="margin-top: 40px;">
        <p>......................................................... ผู้อำนวยการสถานศึกษา</p>
        <p><span style="margin-right: 145px;">(</span><span>)</span></p>
        <p style="margin-left: 16px;">................./.............../...............</p>
      </div>
      <div style="margin-top: 40px;">
        <p>......................................................... ผู้ปกครอง</p>
        <p><span style="margin-right: 145px;">(</span><span>)</span></p>
        <p style="margin-left: 16px;">................./.............../...............</p>
      </div>
     
    </div>
    <table id="footer" class="printOnly" width="100%" style="border: none;"> 
      <tbody style="border: none;">
        <tr > 
        <td width="100%" style="border: none;"> 
         <div style="line-height: 0.5;margin-left: 50px;">
          <p>หมายเหตุ : การประเมินผลคุณลักษณะอันพึงประสงค์ 3 หมายถึง ดีเยี่ยม, 2 หมายถึง ดี, 1 หมายถึง ผ่าน</p>
          <p style="margin-left:50px; ">การประเมินผลการอ่าน เขียน คิด วิเคราะห์ 3 หมายถึง ดีเยี่ยม, 2 หมายถึง ดี, 1 หมายถึง ผ่าน</p>
        </div>
        </td>
      </tr>
      </tbody>
      
    </table>
   
  </page>
</div>
<?php } ?>
</div>
</div>
<script>
 $(document).ready(function() {
    get_print();
    setTimeout(window.close, 0);
  });
  function get_print() {
    window.print();
  }
</script><file_sep>/src/class_role.php
<?php 

class ClassRole extends Databases {

/*************************************** PROCESS DB ****************************************/

	public function ath_chk_role($user_id){
		$this->sql = "SELECT * FROM tbl_regis_teacher WHERE DataID={$user_id}";
		$this->select();
		$this->setRows();
		return $this->rows[0]['status'];	
	}
/*************************************** PROCESS DB ****************************************/
}

?><file_sep>/modules/news/edit.js
var opPage = 'news';
$(document).ready(function() {
	get_news_detail();
	$('#data_id').val(_get.id);
}); 

function get_news_detail() {
  var news_id=_get.id;
  var formData = new Array();
  formData.push({ "name": "acc_action", "value": "get_news_detail" });  
  formData.push({ "name": "news_id", "value": news_id });    
  $.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {
    $('#title').val(data.title);
    $('#detail_box').val(data.detail);
    $('#img_list').html(data.img_list);
    
  })
}

 $(document).delegate('.delete_img_set', 'click', function(event) {
	var data_id = $(this).attr('data-id');
	var set_type = $(this).attr('set-type');

	$(document).delegate('#btn_delete_img', 'click', function(event) {
		var formData = new Array();
		formData.push({ "name": "acc_action", "value": "delete_img_file" }); 
		formData.push({ "name": "data_id", "value": data_id });
		formData.push({ "name": "set_type", "value": set_type });
		$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {
			get_news_detail();
			$('.modal').modal('hide');	
		});
	});
 });
 $(document).delegate('#btn_edit_news', 'click', function(event) {
	$("#btn_submit").click();
 });
function loadFile1() {
    var reader = new FileReader();
    reader.onload = function(){
      var output = document.getElementById('output1');
      output.src = reader.result;
    };
    reader.readAsDataURL(event.target.files[0]);
 };
 function loadFile2() {
    var reader = new FileReader();
    reader.onload = function(){
      var output = document.getElementById('output2');
      output.src = reader.result;
    };
    reader.readAsDataURL(event.target.files[0]);
 };

function loadFile3() {
    var reader = new FileReader();
    reader.onload = function(){
      var output = document.getElementById('output3');
      output.src = reader.result;
    };
    reader.readAsDataURL(event.target.files[0]);
 };

function loadFile4() {
    var reader = new FileReader();
    reader.onload = function(){
      var output = document.getElementById('output4');
      output.src = reader.result;
    };
    reader.readAsDataURL(event.target.files[0]);
 };

function loadFile5() {
    var reader = new FileReader();
    reader.onload = function(){
      var output = document.getElementById('output5');
      output.src = reader.result;
    };
    reader.readAsDataURL(event.target.files[0]);
 };
<file_sep>/modules/attend_class/backup/index.js
var opPage = 'attend_class';
$(document).ready(function() {
	get_coures_id_list();
	//$(".course_detal_box").hide();
}); 
function remove_selected_count_adttend_class() {
	for (var i = 1; i <= 20; i++) {
		$("#set_count_adttend_class_"+i).removeAttr('selected');
	}
}
function get_count_adttend_class_val() {
	var coures_id_list_val =$("#coures_id_list").val();
	var formData = new Array();
	formData.push({ "name": "acc_action", "value": "get_count_adttend_class_val" }); 
	formData.push({ "name": "coures_id_list_val", "value": coures_id_list_val }); 
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {
		remove_selected_count_adttend_class();
		$("#set_count_adttend_class_"+data).attr('selected','selected');
	})
}
$(document).delegate('#btn_save_attend_score_std', 'click', function(event) {
    var inputs = document.getElementsByClassName( 'select-table-form ' ),
    value_attend_week  = [].map.call(inputs, function( input ) {
        return input.value;
    }).join( ',' );
    var std_id_all=$("#std_id_all").val();
    var all_attendID= $("#all_attendID").val();
	var length_list_val= $("#length_list_val").val();

	//var set_count_adttend_class_val= $("#set_count_adttend_class_val").val();
	var coures_id_list_val =$("#coures_id_list").val();

    var formData = new Array();
	formData.push({ "name": "acc_action", "value": "save_attend_score_std" }); 
	formData.push({ "name": "value_attend_week", "value": value_attend_week }); 
	formData.push({ "name": "std_id_all", "value": std_id_all });
	formData.push({ "name": "all_attendID", "value": all_attendID });
	formData.push({ "name": "length_list_val", "value": length_list_val });

	formData.push({ "name": "coures_id_list_val", "value": coures_id_list_val });
	//formData.push({ "name": "set_count_adttend_class_val", "value": set_count_adttend_class_val });

	$.post('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {
		get_week_list();
		get_count_adttend_class_val();
		$(".modal").modal('hide');
	})
})
$(document).delegate('#btn_set_data_seem', 'click', function(event) {
	var legth_week=$("#legth_week").val();
	var attend_seem_value_main=$("#attend_seem_value_main").val();
	$(".class_col_"+legth_week).val(attend_seem_value_main);

})
function open_edit_attend() {
	$(".class_col_set_new").attr('disabled','disabled');
	var legth_week=$("#legth_week").val();
	$(".class_col_"+legth_week).removeAttr('disabled');
}
function get_week_list_data() {
	
	var room_search=$("#room_search").val();
	var length_list_val=$("#length_list_val").val();
	var coures_id_list_val =$("#coures_id_list").val();
	var formData = new Array();
	formData.push({ "name": "acc_action", "value": "get_week_list_data" }); 
	
	formData.push({ "name": "room_search", "value": room_search}); 
	formData.push({ "name": "length_list_val", "value": length_list_val}); 
	formData.push({ "name": "coures_id_list_val", "value": coures_id_list_val}); 

	
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {	

		/*$("#objective_list").html(data.objective_list);
		$("#ob_title_table_col").html(data.ob_title_table_col);
		$("#detail_std").html(data.detail_std);
		$("#data_objectiveID_of_title").val(data.data_objectiveID_of_title);
		$("#std_id_all").val(data.std_id_all);
		set_col_header(length_list_val);
		open_edit_score();*/
		$("#all_attendID").val(data.all_attendID);
		$("#std_id_all").val(data.std_id_all);
		$("#detail_std").html(data.detail_std);
		open_edit_attend();
		
	})
}

function get_week_between() {
	var coures_id_list_val =$("#coures_id_list").val();
	var formData = new Array();
	formData.push({ "name": "acc_action", "value": "get_week_between" }); 
	formData.push({ "name": "coures_id_list_val", "value": coures_id_list_val}); 


	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {	
		$("#length_list_val").html(data);
		
	})

}
function get_week_list() {
	var length_list_val=$("#length_list_val").val();
	var formData = new Array();
	formData.push({ "name": "acc_action", "value": "get_week_list" }); 
	formData.push({ "name": "length_list_val", "value": length_list_val}); 
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {	
		//alert(data)
		
		$("#legth_week").html(data.week_list);
		$("#week_header").html(data.week_header);
		get_week_list_data();
	})
}
$(document).delegate('#btn_search_course_detail', 'click', function(event) {
	var formData = $( "#frm_data_room" ).serializeArray();
	formData.push({ "name": "acc_action", "value": "search_course_detail" }); 
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {	
		$("#place_detail_courseID").html(data.courseID);
		$("#place_detail_name").html(data.name);
		$("#place_detail_unit").html(data.unit);
		$("#place_detail_hr_learn").html(data.hr_learn);
		$("#place_detail_class_level").html(data.class_level_co);
		$("#hr-co-text-depart_course").show();
		$(".course_detal_box").show();
		get_week_between();
		get_week_list();
		get_count_adttend_class_val();
		//get_config();	
	})
})
function get_class_level() {
	var coures_id_list_val =$("#coures_id_list").val();

	var formData = new Array();
	formData.push({ "name": "acc_action", "value": "get_class_level" });
	formData.push({ "name": "coures_id_list_val", "value": coures_id_list_val });
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {
		$("#place_class_level").html(data.class_level);
		$("#room_search").html(data.room);
	})
}
function get_coures_id_list() {
	var formData = new Array();
	formData.push({ "name": "acc_action", "value": "get_coures_id_list" });
	$.getJSON('modules/' + opPage + '/process.php', formData, function(data, textStatus, xhr) {
		$("#coures_id_list").html(data.coures_id_list);
		get_class_level();

	})
}