<?php

    session_start
();
    
    
/**  Define Validate Access  */
    
define'_VALID_ACCESS');

    
/**  Check Session User Login  */
    
if( !session_is_registered("valid_user") && !session_is_registered("Priority") ) {
        echo 
"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=windows-874\" />";
        echo 
"<p style=padding-top:115px><p align=center><br /><font color=red><strong>กรุณาทำการ Login ก่อน</strong></font></p></p>";
        echo 
"<meta http-equiv=\"refresh\" content=\"1; URL=../login.php\" />";
        exit();
    } 
    else {
        
/**  Configuration  */
        
require_once( "../configuration.php" );
        require_once( 
$_Config_absolute_path "/includes/framework.php" );
        require_once( 
"../includes/Function.php" );
        require_once( 
"../includes/FunctionDB.php" );
        
/**  Create Database Object  */
        
$dbObj = new DBConn;

        
/**  Config Table for This Page  */
        
        
$myTable "tech_outcom";        
        
$myTablePK "outNo";
        
$myOrderBy "Nocode";
        
        
//===  projectstdplan_tb //
        
$query " SELECT *  FROM $myTable   where  AcademicYear='$AcademicYear'    ";
        
$result $dbObj->execQuery($query);
        
$rs01 $dbObj->fetchArray($result);
        
$num $dbObj->_numrows;


        
/**  Paging */
        
$page $_GET['page'];
        if( 
$page == "" ) { $page 1; }
        
        
/**  จำนวนข้อมูล ต่อ 1 หน้า  */
        
$perpage $_REQUEST['perpage'];
        if( 
$perpage == "" ) { $perpage 50; }
        
          
/**  Botton Name Action */
        
$action $_REQUEST['action'];
        
$id $_REQUEST['id'];
    
        if( isset(
$action) && !empty($action) ) {
            switch(
$action) {
                case 
"Update" :
                    
$num count($id);
                    for( 
$i=0$i<$num$i++ ) {
                        
                        
                        
$query6 " SELECT *  FROM      tech_methodcom_tb     WHERE     cosId  ='$id[$i]' ";
                        
$result6mysql_query($query6);
                                              
                        
InsertOucomTeach $id[$i], $ttpId $Teacher_code$programId$AcademicYear) ;                    
                    }
                    echo 
"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=windows-874\" />";
                    echo 
"<script>alert('บันทึกข้อมูลเรียบร้อยแล้ว');</script>";
                    echo 
"<script>window.opener.document.all.myForm; window.opener.location.reload(); window.close();</script>";
                     exit();
                break;  
            } 
# switch
        
# if
        
        /**  Parameters  */
        
$params "programId=$programId";
        
        
    } 
# else
 
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874" />
<link href="../css/default.css" rel="stylesheet" type="text/css" />
<script language="javascript" src="../js/utilities.js"></script>
<title>ตัวชี้วัดประกันคุณภาพการศึกษา </title>
</head>

<body topmargin="0" rightmargin="0" bottommargin="0" leftmargin="0">

<table width="797" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="797" align="center" valign="top" style="padding:10px 0px 5px 10px">
      <?php
        
/**  Config Paging  */
        
if( $perpage == "" ) { $limit $_Config_limit; }
        else { 
$limit $perpage; }
        
        
$scroll $_Config_scroll
        
        
        
/**  ตั้งค่า Default สำหรับการทำ Order By  */
        
if( $OrderBy == "" ) { $OrderBy $myTablePK ; }
                        
        if( !isset(
$_GET['ASCDESC']) ) { $ASCDESC "ASC"; }
                        
        if( 
$_GET['ASCDESC'] == "DESC" ) { $ASCDESC "ASC"; }
        elseif( 
$_GET['ASCDESC'] == "ASC" ) { $ASCDESC "DESC"; } 
        
        
/**  Query เพื่อหา Numrows ก่อน  */
        
$query " SELECT *  FROM $myTable   where  AcademicYear='$AcademicYear'     ";
        
$result $dbObj->execQuery($query);
        
$numrows $dbObj->_numrows;
        
        
/**  Paging  */
        
$display = ( !isset ($_GET['page']) ) ? $_GET['page'];
        
$start = ( ($display $limit) - $limit );
        
/**  Paging  */
        
        
if( isset($_GET['OrderBy']) ) {
            
$query " SELECT *  FROM $myTable  where  AcademicYear='$AcademicYear'   ORDER BY $OrderBy $ASCDESC ";
        } 
        elseif( !isset(
$_GET['OrderBy']) ) {
            
$query " SELECT *  FROM $myTable  where  AcademicYear='$AcademicYear'  ORDER BY $myTablePK ASC ";
        }
        
        
$query .= " LIMIT $start, $limit ";
        
$result $dbObj->execQuery($query);
    
?>
      <fieldset><table width="780" border="0" cellspacing="0" cellpadding="0">
        <form id="myForm" name="myForm" method="post" action="<?=$PHP_SELF;?>?page=<?=$page;?>&amp;<?=$params;?>">
          <tr>
            <td height="5"></td>
          </tr>
          <tr>
            <td height="139" align="center" valign="top">
              <?php if( $numrows ) { ?>
              <table width="759" border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td width="648" height="25" align="left" style="padding-bottom:5px;">จำนวน: <span class="TEXT-CLIMSON10"><strong><?=$numrows;?></strong></span> องค์ประกอบ</td>
                  <td width="117" align="right" style="padding-bottom:5px;"><span style="padding-bottom:5px">
                    <?php if( $numrows ) { ?>
                    <input type="submit" name="action" id="action" value="Update"  class="TEXT-CLIMSON10 CURSOR-HAND WIDTH60"  onclick="return confirmUpdate(this.form);" />
                    <?php #if ?>
                    </span>&nbsp;&nbsp;</td>
                  </tr>
                </table>
              <table width="759" border="0" align="center" cellpadding="1" cellspacing="1" bgcolor="#FFFFFF" style="background-color:#EEEEEE; border:0px solid gray" size="12">
                <tr>
                  <td height="20" colspan="11" align="center" class="PATRON11">ผลการเรียนรู้ (Learning Outcomes) แต่ละด้าน </td>
                  </tr>
                
                <?php
                  $no 
1+($display-1)*$limit;
                while( 
$rs $dbObj->fetchArray($result) ) { 
                    
$bgColor = ( $bgColor == "#FFFFFF" ) ? "#F9FBFB" "#FFFFFF";
              
?>
                <tr bgcolor="<?=$bgColor;?>" onmouseover="this.style.backgroundColor='#FFFFE0'" onmouseout="this.style.backgroundColor=''">
                  <td colspan="2" align="left" valign="top" class="PADDING-RIGHT-5"><span class="PADDING-LEFT-5"><strong>
                    <?=$rs['outNo'];?>
                    .
                    <?=htmlspecialchars_decodenl2br$rs['outcomName'] ) );?>
                    </strong></a></span></td>
                  <td colspan="9" align="center" valign="top" bgcolor="<?=$bgColor;?>" class="PADDING-LEFT-3">&nbsp;</td>
                  </tr>
                <?php 
                     $query2 
" SELECT *  FROM  tech_outcom_tb   WHERE  programId='$programId'   and   outId  = '".$rs['outId']."' Order  By  outNo   ";
                    
$result2 mysql_query($query2);
                    while(
$rss mysql_fetch_array($result2)){ ;
                    
$bgColor = ( $bgColor == "#FFFFFF" ) ? "#F9FBFB" "#FFFFFF";                        
                      
?>
                <tr bgcolor="<?=$bgColor;?>" onmouseover="this.style.backgroundColor='#FFFFE0'" onmouseout="this.style.backgroundColor=''">
                  <td width="18" align="center" valign="top" class="PADDING-RIGHT-5">&nbsp;</td>
                  <td width="663" align="left" valign="top" bgcolor="<?=$bgColor;?>" class="PADDING-LEFT-5"><?=$rss['outNo'];?>
                    <?=htmlspecialchars_decodenl2br$rss['outcomName'] ) );?>
                    </a></td>
                  <td width="68" colspan="9" align="center" valign="top" bgcolor="<?=$bgColor;?>" class="PADDING-LEFT-3">&nbsp;</td>
                  </tr>
                <?php 
                     $query 
" SELECT *  FROM  tech_coseoutcom    WHERE  comId  = '".$rss['comId']."' Order  By  cosId   ";
                    
$result3 mysql_query($query);
                    while(
$rs3 mysql_fetch_array($result3)){ ;
                    
$bgColor = ( $bgColor == "#FFFFFF" ) ? "#F9FBFB" "#FFFFFF";                        
                      
?>
                <tr bgcolor="<?=$bgColor;?>" onmouseover="this.style.backgroundColor='#FFFFE0'" onmouseout="this.style.backgroundColor=''">
                  <td align="center" valign="top" class="PADDING-RIGHT-5">&nbsp;</td>
                  <td align="left" valign="top"  class="PADDING-LEFT-15"><?=$rs3['outNo'];?>
                    <?=htmlspecialchars_decodenl2br$rs3['coseName'] ) );?>
                    </a></td>
                  <td colspan="9" align="center" valign="top" class="PADDING-LEFT-3"><input name="ttpId" type="hidden" id="ttpId" value="<?=$ttpId ;?>" /><input type="checkbox" name="id[]" value="<?=$rs3['cosId'];?>&amp;<?=$rs3['programId'];?>" onclick="highlightRow(this);" title="ลบข้อมูล(<?php echo $rs3['cosId']; ?>)"  />
                    <input name="programId" type="hidden" id="programId" value="<?=$rs3['programId'];?>" />
                    <input name="Teacher_code" type="hidden" id="Teacher_code" value="<?=$Teacher_code ;?>" /></td>
                  </tr>
                     <?php
                
# while
              
?>
                <?php
                
# while
              
?>
                <?php 
               $no
++;
            } 
# while 
            
          
?>
                </table>
              <?php #if ?></td>
          </tr>
          <tr>
            <td>&nbsp;</td>
          </tr></form>
        </table>
    </fieldset></td>
  </tr>
</table>

</body>
</html>
<?php
    
/**  Free Resource */
    //$dbObj->freeresult($result);
    
    /**  Close the Database  */
    
$dbObj->disconn();
    
    
/**  Unset Class  */
    
unset($dbObj);
?>