Viewing file: Edit_Family.php (13.31 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
//print_r($_REQUEST);
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( "../include/Function.php" );
require_once( "../include/FunctionDB.php" );
/** Create Database Object */
$dbObj = new DBConn;
/** Config Table for This Page */
$myTable = "personal_tb";
$Username = $valid_user;
$query1 = " SELECT * FROM prefix RIGHT JOIN people_tb ON prefix.prefixId=people_tb.prefixId WHERE people_tb.Teacher_code = '$Teacher_code' AND people_tb.People_Id = '$People_Id' AND people_tb.Status = '$Status' ";
$result1= mysql_query($query1);
$rs1 = mysql_fetch_array($result1);
$sql = " SELECT * FROM $myTable WHERE Teacher_code='$Teacher_code' ";
$res = mysql_query($sql);
$rs= mysql_fetch_array($res);
$sql2 = " SELECT * FROM prefix";
$res2 = mysql_query($sql2);
list($d,$m,$y) = split('/',$_REQUEST["Birth_date"]);
$Date = ($y+543)."-".$m."-".$d;
$People_idcard = str_replace("-","",$_REQUEST["People_idcard"]);
//*** Update Condition ***//
if($_POST["hdnCmd"] == "Update")
{
$strSQL = "UPDATE people_tb SET prefixId = '".$_POST["Prefix"]."' ,People_name = '".$_POST["People_name"]."' ,People_surname = '".$_POST["People_surname"]."' ,People_birth = '".$Date."' ,People_idcard = '".$People_idcard."' ,People_rank = '".$_POST["Rank"]."' ,Status = '".$_POST["Status"]."' ,People_legal = '".$_POST["People_legal"]."' ,People_incom = '".$_POST["People_incom"]."' WHERE People_Id = '".$People_Id."' ";
$objQuery = mysql_query($strSQL);
echo "<script type='text/javascript'>alert('บันทึกข้อมูลเรียบร้อย');history.back();</script>";
if(!$objQuery)
{
echo "Error Update [".mysql_error()."]";
}
}
$strSQL = "SELECT * FROM people_tb";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
} # 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>
<script type="text/javascript" src="../js/calendarDateInput2.js"></script>
<script language="javascript" src="../js/ajaxScript.js"></script>
<title>ศูนย์พัฒนาบุคลากร - เพิ่มข้อมูลบุคลากร</title>
<script type="text/javascript">
function CheckDoSubmit(){
var field1 = document.getElementById('Status');
var field2 = document.getElementById('Prefix');
var field3 = document.getElementById('People_name');
var field4 = document.getElementById('People_idcard');
var field5 = document.getElementById('Rank');
if(field1.value == ""){
alert('กรุณาเลือกสถานะบุคคล');
return false;
}
else if(field2.value == ""){
alert('กรุณาเลือกคำนำหน้าชื่อ');
return false;
}
else if(field3.value == ""){
alert('กรุณากรอกชื่อและนามสกุล');
return false;
}
else if(field4.value == ""){
alert('กรุณากรอกเลขประจำตัวบัตรประชาชน');
return false;
}
else if(field1.value == "บุตร" && field5.value == ""){
alert('กรุณากรอกลำดับของบุตร');
return false;
}
else{
document.frmMain.submit();
return true;
}
}
function check_name()
{
var field = document.getElementById('People_name');
var RE_NAME = /^[a-zA-Zก-์\-]+$/;
if(field.value == ""){
return false;
}
else if(!RE_NAME.test(field.value))
{
alert("ชื่อต้องเป็นตัวอักษรเท่านั้น");
field.value = "";
return false;
}
else
{
return true;
}
}
function check_surname()
{
var field = document.getElementById('People_surname');
var RE_NAME = /^[a-zA-Zก-์\-]+$/;
if(field.value == ""){
return false;
}
else if(!RE_NAME.test(field.value))
{
alert("ชื่อต้องเป็นตัวอักษรเท่านั้น");
field.value = "";
return false;
}
else
{
return true;
}
}
function check_num()
{
var field = document.getElementById('People_idcard');
if(field.value.length<17)
{
alert('เลขประจำตัวบัตรประชาชนจะต้องมี 13 หลัก');
return false;
}
}
</script>
<style type="text/css">
<!--
.style1 {color: #FF0000}
-->
</style>
</head>
<body topmargin="0" rightmargin="0" bottommargin="0" leftmargin="0">
<?php
include("../templates/incHeader.php");
?>
<table width="1000" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="203" align="left" valign="top" style="padding:10px 0px 0px 5px"><?php include("./_incMainMenu.php");?></td>
<td width="800" align="center" valign="top" style="padding:10px 0px 5px 10px"><fieldset>
<table width="780" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="5"></td>
</tr>
<tr>
<td height="30" background="../images/background/bg-head-topic-w780.gif" class="PADDING-LEFT-10"><strong><span class="NOTE">แบบฟอร์มแก้ไขข้อมูลครอบครัว </span></strong>
» <strong><a href="Show_Family.php?Teacher_code=<?=$_REQUEST["Teacher_code"];?>">ข้อมูลประวัติครอบครัว</a></strong></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td height="370" align="center" valign="top">
<form name="frmMain" method="post" action="<?=$_SERVER["PHP_SELF"];?>" >
<input type="hidden" name="hdnCmd" value="Update">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" bordercolor="#CCCCCC" style="border:1px solid gray">
<tr >
<td height="40" align="right" nowrap="nowrap" bordercolor="#FFFFFF" bgcolor="#FFFFFF"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="3" bordercolor="#CCCCCC" style="border:0px solid gray">
<tr bgcolor="#B6D0F1" >
<td height="23" colspan="4" align="center" nowrap="nowrap" bordercolor="#CCCCCC" background="../Image/centerpix.gif" bgcolor="#FFFFFF" class="style14 style15"><font color="#003366"><strong><font face="Tahoma">ข้อมูลครอบครัว </font></strong></font></td>
</tr>
<tr bgcolor="#ECF5FF" >
<td align="right" nowrap="nowrap" bordercolor="#CCCCCC" bgcolor="#FFFFFF" class="style14"> </td>
<td bordercolor="#CCCCCC" bgcolor="#FFFFFF" class="style14 style15"> </td>
<td colspan="2" nowrap="nowrap" bordercolor="#CCCCCC" bgcolor="#FFFFFF" class="style14"> </td>
</tr>
<tr bgcolor="#ECF5FF" >
<td align="right" nowrap="nowrap" bordercolor="#CCCCCC" bgcolor="#FFFFFF" class="style14"><font color="#003366" face="Tahoma">สถานะบุคคล</font></td>
<td bordercolor="#CCCCCC" bgcolor="#FFFFFF" class="style14 style15"> </td>
<td colspan="2" nowrap="nowrap" bordercolor="#CCCCCC" bgcolor="#FFFFFF" class="style14">
<select name="Status" id="Status" style="text-align:left; width:90px">
<option value="บิดา" <?=($Status=="บิดา" )?"selected":"";?>>บิดา</option>
<option value="มารดา" <?=($Status=="มารดา" )?"selected":"";?>>มารดา</option>
<option value="คู่สมรส" <?=($Status=="คู่สมรส" )?"selected":"";?>>คู่สมรส</option>
<option value="บุตร" <?=($Status=="บุตร" )?"selected":"";?>>บุตร</option>
</select>
<span class="style1">*</span> </td>
</tr>
<tr bgcolor="#ECF5FF" >
<td width="146" align="right" nowrap="nowrap" bordercolor="#CCCCCC" bgcolor="#FFFFFF" class="style14"><font color="#003366" face="Tahoma">ชื่อ
- นามสกุล</font></td>
<td width="1" bordercolor="#CCCCCC" bgcolor="#FFFFFF" class="style14 style15"> </td>
<td colspan="2" nowrap="nowrap" bordercolor="#CCCCCC" bgcolor="#FFFFFF" class="style14"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="style15"><select name="Prefix" id="Prefix" style="text-align:left; width:90px">
<?php
$query6 = " SELECT * FROM prefix";
$result6 = $dbObj->execQuery($query6);
while($rs6 = mysql_fetch_array($result6)){
?>
<option value="<?=$rs6["prefixId"];?>" <?=($rs6["prefixId"]==$rs1["prefixId"] )?"selected":"";?>><?=$rs6["prefixName"];?></option>
<?
}
?>
</select>
ชื่อ
<input name="People_name" type="text" id="People_name" style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: black 1px dashed" size="29" onblur="check_name();" value="<?=$rs1["People_name"];?>"/>
<span class="style1">*</span>
นามสกุล
<input name="People_surname" type="text" id="People_surname" style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: black 1px dashed" size="29" onblur="check_surname();" value="<?=$rs1["People_surname"];?>"/>
<span class="style1">*</span>
</td>
</tr>
</table></td>
</tr>
<tr bgcolor="#ECF5FF" >
<td align="right" nowrap="nowrap" bordercolor="#CCCCCC" bgcolor="#FFFFFF" class="style14"><font color="#003366" face="Tahoma">เลขประจำตัวประชาชน</font></td>
<td bordercolor="#CCCCCC" bgcolor="#FFFFFF" class="style14 style15"> </td>
<td colspan="2" nowrap="nowrap" bordercolor="#CCCCCC" bgcolor="#FFFFFF" class="style14"><input name="People_idcard" type="text" id="People_idcard" value="<?=citizenID_format($rs1['People_idcard']);?>" size="25" maxlength="17" style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: black 1px dashed"onkeypress="return (NumOnly(event) && changeFormatPin(this,event));" onblur="check_num();"/>
<span class="style1">*</span> </td>
</tr>
<tr bgcolor="#ECF5FF">
<td align="right" nowrap="nowrap" bordercolor="#CCCCCC" bgcolor="#FFFFFF" class="style14"><font color="#003366" face="Tahoma">เกิดเมื่อ</font></td>
<td bordercolor="#CCCCCC" bgcolor="#FFFFFF" class="style14 style15"> </td>
<td width="172" align="left">
<script>DateInput('Birth_date', true,'DD/MM/YYYY','<?=(isset($rs1["People_birth"]))?ymdT2dmyE($rs1["People_birth"]):date("d/m/Y");?>');</script>
</td>
<td width="442" nowrap="nowrap" bordercolor="#CCCCCC" bgcolor="#FFFFFF" class="style14">
<?
if($Status == "บุตร") { ?>
<input type="checkbox" name="People_legal" id="People_legal" value="ไม่บรรลุนิตภาวะ" <?=(trim($rs1["People_legal"])=="ไม่บรรลุนิตภาวะ")?"checked":"";?>/>
ยังไม่บรรลุนิตภาวะ
<input type="checkbox" name="People_incom" id="People_incom" value="ไร้ความสามารถ" <?=(trim($rs1["People_incom"])=="ไร้ความสามารถ")?"checked":"";?>/>
เป็นบุตรไร้ความสามารถ หรือเสมือนไร้ความสามารถ </td>
</tr>
<tr bgcolor="#ECF5FF">
<td align="right" nowrap="nowrap" bordercolor="#CCCCCC" bgcolor="#FFFFFF" class="style14"><font color="#003366" face="Tahoma">บุตรลำดับที่</font></td>
<td bordercolor="#CCCCCC" bgcolor="#FFFFFF" class="style14 style15"> </td>
<td align="left">
<input name="Rank" type="text" id="Rank" style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: black 1px dashed" size="28" value="<?=$rs1["People_rank"];?>" /></td>
<td nowrap="nowrap" bordercolor="#CCCCCC" bgcolor="#FFFFFF" class="style14 style1">(กรอกเฉพาะ บุตร)</td>
</tr>
<? }
else echo "";?>
<tr bgcolor="#CFE0F5">
<td height="20" colspan="4" bgcolor="#FFFFFF"> </td>
</tr>
<tr bgcolor="#CFE0F5">
<td height="20" colspan="4" bgcolor="#FFFFFF"><div align="center">
<input name="btnAdd" type="button" id="btnUpdate" value="บันทึกข้อมูล" OnClick="frmMain.hdnCmd.value='Update';frmMain.submit();">
<input type="hidden" name="Teacher_code" value="<?=$Teacher_code ?>"><input type="hidden" name="People_Id" value="<?=$People_Id ?>">
<input type="reset" name="Reset" value=" เคลียร์ข้อมูล" />
</div></td>
</tr>
</table>
</td>
</tr>
</table>
</form></td>
</tr>
<tr>
<td align="center" valign="top"> </td>
</tr>
</table>
</fieldset></td>
</tr>
</table>
<?php include("../templates/incFooter.php"); ?>
</body>
</html>
<?php
/** Free Resource */
$dbObj->freeresult($result);
/** Close the Database */
$dbObj->disconn();
/** Unset Class */
unset($dbObj);
?>
|