Viewing file: AddConFaculty.php (10.48 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
session_start();
/** Define Validate Access */
define( '_VALID_ACCESS', 1 );
/** 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 Faculty_code='$Faculty_code'";
$result1= mysql_query($sql) or die(" Error").mysql_error();
$num = $dbObj->_numrows;
$row = mysql_fetch_array($result1);
/** 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*/
if(isset($_REQUEST['action'])){
switch($_REQUEST['action']){
case "saveAdd" :
$sql = "INSERT INTO facultycon_tb(Faculty_code, Group_name, Group_nameE) VALUES ('".$_REQUEST['Faculty_code']."', '".$_REQUEST['Group_name']."', '".$_REQUEST['Group_nameE']."')";
mysql_query($sql);
$message = "<font color=\"green\">เพิ่มข้อมูลกลุ่มงานเรียบร้อยแล้ว</font>";
break;
case "saveEdit" :
$sql = "UPDATE facultycon_tb SET Faculty_code = '".$_REQUEST['Faculty_code']."', Group_name = '".$_REQUEST['Group_name']."', Group_nameE = '".$_REQUEST['Group_nameE']."' WHERE conId = '".$_REQUEST['conId']."'";
mysql_query($sql);
$message = "<font color=\"green\">แก้ไขข้อมูลกลุ่มงานเรียบร้อยแล้ว</font>";
break;
case "delete" :
$sql = "DELETE FROM facultycon_tb WHERE conId = '".$_REQUEST["conId"]."'";
mysql_query($sql);
$message = "<font color=\"red\">ลบข้อมูลกลุ่มงานเรียบร้อยแล้ว</font>";
break;
}
}
} # 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><?=$_Config_sitename;?></title>
<link href="../css/default.css" rel="stylesheet" type="text/css" />
<script language="javascript" src="../js/ajaxScript.js"></script>
</head>
<br />
<table width="454" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="440" height="135">
<fieldset>
<legend>ข้อมูลกลุ่มงานใน หน่วยงาน/ฝ่าย <?=$rss["Faculty_name"];?></legend>
<form id="form1" name="form1" method="post" action="" onSubmit="return validateAddConFacultyForm();">
<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" align="center" bgcolor="#FFFFFF">
<input name="Faculty_code" type="hidden" id="Faculty_code" value="<? echo $rss[Faculty_code]?>" />
<font color="#003366" size="2" face="Tahoma"><?=(isset($message))?$message:"";?></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="<?=$bgColor;?>">
<td height="0%" align="center"> </td>
<td width="15%" align="right">
<font color="#003366" size="2" face="Tahoma">กลุ่มงาน : </font>
</td>
<td width="75%" align="left">
<?php
if(isset($_REQUEST["action"]) && $_REQUEST["action"] == "edit" && $_REQUEST["conId"] == $row['conId']){
?>
<font color="#003366" size="2" face="Tahoma">ไทย:</font>
<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="14" />
<font color="#003366" size="2" face="Tahoma">อังกฤษ:</font>
<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="14" />
<?php
}
else{
echo "<font color=\"#003366\" size=\"2\" face=\"Tahoma\">".$row['Group_name'].((!empty($row['Group_nameE'])&&$row['Group_nameE']!="-")?" (".$row['Group_nameE'].")":"")."</font>";
}
?>
</td>
<td width="5%" align="center">
<?php
if(isset($_REQUEST["action"]) && $_REQUEST["action"] == "edit" && $_REQUEST["conId"] == $row['conId']){
?>
<input type="image" value="save" src="../picture/save.gif" alt="บันทึก" title="บันทึกแก้ไขข้อมูลกลุ่มงาน <?=$row['Group_name'];?>"/>
<input name="action" type="hidden" id="action" value="saveEdit" />
<input name="conId" type="hidden" value="<?=$_REQUEST["conId"];?>" />
<?php
}
else{
?>
<a href="AddConFaculty.php?action=edit&Faculty_code=<?=$row['Faculty_code'];?>&conId=<?=$row['conId'];?>">
<img src="../images/icons/icon-edit.gif" width="16" height="16" border="0" title="แก้ไขข้อมูลกลุ่มงาน <?=$row['Group_name'];?>"/>
</a>
<?php
}
?>
</td>
<td width="5%" align="center">
<?php
if(!isset($_REQUEST["action"]) || $_REQUEST["action"] != "edit" || $_REQUEST["conId"] != $row['conId']){
?>
<a href="AddConFaculty.php?action=delete&Faculty_code=<?=$row['Faculty_code'];?>&conId=<?=$row['conId'];?>">
<img src="../images/icons/cross.png" width="16" height="16" border="0" onclick="return confirm('ลบข้อมูลกลุ่มงาน <?=$row['Group_name'];?> ใช่หรือไม่?')" title="ลบข้อมูลกลุ่มงาน <?=$row['Group_name'];?>"/>
</a>
<?php
}
?>
</td>
</tr>
<?php
$no++;
} # while
$bgColor = ( $bgColor == "#FFFFFF" ) ? "#F9FBFB" : "#FFFFFF";
if(isset($_REQUEST["action"]) && $_REQUEST["action"] == "add"){
?>
<tr bgcolor="<?=$bgColor;?>">
<td height="0%" align="center"> </td>
<td width="15%" bordercolor="#FFFFCC" align="right">
<font color="#003366" size="2" face="Tahoma">กลุ่มงาน : </font>
</td>
<td width="75%" bordercolor="#FFFFCC" align="left">
<font color="#003366" size="2" face="Tahoma">ไทย:</font>
<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="14" />
<font color="#003366" size="2" face="Tahoma">อังกฤษ:</font>
<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="14" />
</td>
<td width="5%" align="center" bordercolor="#FFFFCC">
<input type="image" value="save" src="../picture/save.gif" alt="บันทึก" title="บันทึกแก้ไขข้อมูลกลุ่มงาน <?=$row['Group_name'];?>"/>
<input name="action" type="hidden" id="action" value="saveAdd" />
</td>
<td width="5%" align="center" bordercolor="#FFFFCC"> </td>
</tr>
<?php
}
else{
?>
<tr bgcolor="<?=$bgColor;?>">
<td height="0%" align="center" bordercolor="#CCCCCC"> </td>
<td width="15%" bordercolor="#FFFFCC" align="right"> </td>
<td width="75%" bordercolor="#FFFFCC" align="left"> </td>
<td width="5%" align="center" bordercolor="#FFFFCC">
<a href="AddConFaculty.php?action=add&Faculty_code=<?=$_REQUEST['Faculty_code'];?>">
<img src="../images/icons/disk-plus.png" width="16" height="16" border="0" title="เพิ่มข้อมูลกลุ่มงาน"/>
</a>
</td>
<td width="5%" align="center" bordercolor="#FFFFCC"> </td>
</tr>
<?php
}
?>
<?php
$dbObj->freeresult($result1);
?>
<tr bgcolor="#F3F3F3">
<td align="center" bordercolor="#CCCCCC" bgcolor="#FFFFFF"> </td>
<td bordercolor="#FFFFCC" bgcolor="#FFFFFF"> </td>
<td bordercolor="#FFFFCC" bgcolor="#FFFFFF"> </td>
<td bordercolor="#FFFFCC" bgcolor="#FFFFFF"> </td>
<td bordercolor="#FFFFCC" bgcolor="#FFFFFF"> </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);
?>
|