<?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;
        
    
/**  Chart  */
    
            
    /**  Config Table for This Page  */
    
$myTable "faculty_tb";
    
$myTable1 "facultycon_tb";
    
$myTableFK "conId";
    
    
    
$sql "Select * From $myTable   Where  Faculty_code='$Faculty_code'";
    
$result mysql_query($sql) or die(" Error").mysql_error();
     
$rss mysql_fetch_array($result);
/////////////////////////////////
$sql "Select * From $myTable1   Where  conId='$conId' and   Faculty_code='$Faculty_code'  ";
$result1mysql_query($sql) or die(" Error").mysql_error();
$num $dbObj->_numrows;
$row mysql_fetch_array($result1); 

    
$query5 " UPDATE  $myTable1  SET   Group_name='$Group_name', Group_nameE='$Group_nameE'    Where  conId='$conId' and   Faculty_code='$Faculty_code'  ";
        
$result5 $dbObj->runQuery($query5);
        
$dbObj->freeresult($result5);
        
    
/**  Botton Name Action */
        
$action $_REQUEST['action'];
        
$id $_REQUEST['id'];
    
        if( isset(
$action) && !empty($action) ) {
            switch(
$action) {
                case 
"Delete" :
                    
$num count($id);
                    for( 
$i=0$i<$num$i++ ) {
                        
//--- tech_plan_tb
                        
$qrySel " SELECT *  FROM  $myTable1  WHERE $myTableFK='$id[$i]' ";
                        
$resultSel $dbObj->execQuery($qrySel);
                        
$rsSel $dbObj->fetchObject($resultSel);
                            
$Faculty_code $rsSel->Faculty_code;
                        
                        
$qryDel " DELETE FROM  $myTable1  WHERE $myTableFK='$id[$i]' ";
                        
$resultDel $dbObj->runQuery($qryDel);
                        
$dbObj->freeresult($resultDel);
                    
                                    
                    }
                break;
            } 
# switch
        
# if
            
    
# 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" />
<title>Edit Password</title>
<link href="../css/default.css" rel="stylesheet" type="text/css" />

</head>

<table width="454" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
        <td width="440" height="135">
          <fieldset>
    
              <form id="form1" name="form1" method="post" action=" <?=$PHP_SELF;?>?Faculty_code=<?=$Faculty_code;?>&conId=<?=$conId;?>" >
            
            
                <table width="98%" border="0" align="center" cellpadding="0" cellspacing="0" style="background-color:#eeeeee; border:0px solid gray; font-family: Verdana, Geneva, sans-serif; font-size: 14px;"size="12">
                  <tr bgcolor="#F3D6F2">
                    <td colspan="5" bgcolor="#FFFFFF">&nbsp;</td>
                  </tr>
                  <tr bgcolor="#F3D6F2">
                    <td colspan="5" bgcolor="#FFFFFF"><font face="Tahoma">กลุ่ม /หน่วยงาน (Th)</font><font color="#0000FF" size="2" face="Tahoma">
                    <input name="Group_name" type="text" id="Group_name" style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: black 1px dashed" value="<? echo $row[Group_name];?>" size="30" />
                    </font></td>
                  </tr>
                  <tr bgcolor="#F3D6F2">
                    <td colspan="5" bgcolor="#FFFFFF"><font face="Tahoma">กลุ่ม /หน่วยงาน</font> (Eng)<font color="#0000FF" size="2" face="Tahoma">
                      <input name="Group_nameE" type="text" id="Group_nameE" style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: black 1px dashed" value="<? echo $row[Group_nameE];?>" size="30" />
                    </font></td>
                  </tr>
                  <tr bgcolor="#F3D6F2">
                    <td colspan="5" bgcolor="#FFFFFF">&nbsp;</td>
                  </tr>
                  <tr bgcolor="#F3D6F2">
                    <td colspan="5" align="center" bgcolor="#FFFFFF"><input name="conId" type="hidden" id="conId" value="<? echo $row[conId]?>&<? echo $row[Faculty_code];?>" />
                      <input type="submit" name="Submit" value="   บันทึก   " class="button" id="Submit" />
                      <input type="button" name="action" id="action" value="  ปิดหน้าต่าง" onclick="window.close();" /></td>
                  </tr>
                  <tr bgcolor="#F3D6F2">
                    <td colspan="5" bgcolor="#FFFFFF">&nbsp;</td>
                  </tr>
                  <tr bgcolor="#F3D6F2">
                    <td colspan="5" align="right" bgcolor="#FFFFFF"><div align="Right"><span style="padding-bottom:5px">
                      <input type="submit" name="action" id="action" value="Delete" class="TEXT-CLIMSON10" onclick="return confirmDelete(this.form);" />
                    </span></div></td>
                  </tr>
                  <tr bgcolor="#F3F3F3">
                    <td width="27%" bordercolor="#CCCCCC" bgcolor="#FFFFFF"><font face="Tahoma">หน่วยงาน/ภาค/ฝ่าย </font></td>
                    <td colspan="4" bordercolor="#FFFFCC" bgcolor="#FFFFFF"><font color="#003366" size="2" face="Tahoma"><?php echo $rss['Faculty_name']; ?></font><font color="#003366" size="2" face="Tahoma"></a>&nbsp;</font><font size="2" face="Tahoma">&nbsp; </font></td>
                  </tr>
                   <?php
              $query 
" SELECT *  FROM $myTable1   WHERE  Faculty_code='$Faculty_code'  ";
              
$result $dbObj->execQuery($query);
             
$numrows $dbObj->_numrows;  
                  
?>
                     <?php 
           $no 
1+($display-1)*$limit;
            while( 
$row $dbObj->fetchArray($result) ) { 
                
$bgColor = ( $bgColor == "#FFFFFF" ) ? "#F9FBFB" "#FFFFFF";
          
?>
                        <tr bgcolor="#F3F3F3">
                    <td height="20" align="center" bordercolor="#CCCCCC" bgcolor="#FFFFFF">&nbsp;</td>
                                       <td width="4%" bordercolor="#FFFFCC" bgcolor="#FFFFFF">&nbsp;</td>
                    <td width="61%" bordercolor="#FFFFCC" bgcolor="#FFFFFF"> <img src="../picture/linesub.gif" width="16" height="16" border="0" align="absmiddle" /><?php echo $row['Group_name']; ?> (<?php echo $row['Group_nameE']; ?>)</td>
                    <td width="2%" align="center" bordercolor="#FFFFCC" bgcolor="#FFFFFF"><a href="FrmEditFaculty.php?Faculty_code=<?=$row['Faculty_code'];?>"></a></td>
                    <td width="6%" align="center" bordercolor="#FFFFCC" bgcolor="#FFFFFF">
                      <input type="checkbox" name="id[]" value="<?=$row['conId'];?>&<?=$row['Faculty_code'];?>" onclick="highlightRow(this);" title=" ลบข้อมูล <?php echo $row['conId']; ?>=<?php echo $row['Faculty_code'];?> " />
                 </td>
                  </tr>
                     <?php 
               $no
++;
            } 
# while 
            
$dbObj->freeresult($result1);
          
?>
                  <tr bgcolor="#F3F3F3">
                    <td align="center" bordercolor="#CCCCCC" bgcolor="#FFFFFF">&nbsp;</td>
                    <td bordercolor="#FFFFCC" bgcolor="#FFFFFF">&nbsp;</td>
                    <td bordercolor="#FFFFCC" bgcolor="#FFFFFF">&nbsp;</td>
                    <td bordercolor="#FFFFCC" bgcolor="#FFFFFF">&nbsp;</td>
                    <td bordercolor="#FFFFCC" bgcolor="#FFFFFF">&nbsp;</td>
                  </tr>
                 
                          
                  
                    <td colspan="5" bgcolor="#FFFFFF"></a></a></td>
                  </tr>
                                         </table>
              </form>
          </fieldset></td>
    </tr>
</table>
<?php
    
/**  Close the Database  */
    
$dbObj->disconn();
    
    
/**  Unset Class  */
    
unset($dbObj);
?>