Viewing file: AddFamily.php (12.77 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" );
/** Create Database Object */
$dbObj = new DBConn;
/** Config Table for This Page */
$myTable = "personal_tb";
$Username = $valid_user;
$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"]);
//*** Add Condition ***//
if($_POST["hdnCmd"] == "Add")
{
$sql = " SELECT * FROM people_tb WHERE Status='บุตร' AND People_rank = '".$_POST["Rank"]."' ";
$result = mysql_query($sql);
$Num_Rows=mysql_num_rows($result);
if($Num_Rows==0){
$strSQL = "INSERT INTO people_tb (People_Id,prefixId,People_name,People_surname,People_birth,People_idcard,People_rank,Status,People_legal,People_incom,Teacher_code) VALUES (' ','".$_POST["Prefix"]."' ,'".$_POST["People_name"]."' ,'".$_POST["People_surname"]."' ,'".$Date."','".$People_idcard."' ,'".$_POST["Rank"]."','".$_POST["Status"]."' ,'".$_POST["People_legal"]."','".$_POST["People_incom"]."','".$Teacher_code."') ";
$objQuery = mysql_query($strSQL);
echo "<script type='text/javascript'>alert('บันทึกข้อมูลเรียบร้อย')</script>";
}
else{
echo "<script type='text/javascript'>alert('มีบุตรลำดับที่ ".$_POST["Rank"]." ในระบบแล้ว')</script>";
}
}
$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 language="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_surname');
var field5 = document.getElementById('People_idcard');
var field6 = 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(field5.value == ""){
alert('กรุณากรอกเลขประจำตัวบัตรประชาชน');
return false;
}
else if(field1.value == "บุตร" && field6.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" height="440" align="left" valign="top" style="padding:10px 0px 5px 10px"><fieldset>
<legend><font size="2" color="<?php echo $GLOBALS["COLOR_FONT_3"]; ?>">แบบฟอร์มเพิ่มข้อมูลครอบครัว</font></font><img src="../picture/ico3.gif" width="10" height="10" align="absmiddle" border="0" /></font><span class="NOTE"><a href="Show_Family.php?Teacher_code=<?=$_REQUEST["Teacher_code"];?>">ข้อมูลประวัติครอบครัว</a></font></span></legend>
<table width="780" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="5"></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="Add">
<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="">เลือก</option>
<option value="บิดา">บิดา</option>
<option value="มารดา">มารดา</option>
<option value="คู่สมรส">คู่สมรส</option>
<option value="บุตร">บุตร</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">
<option value="">คำนำหน้าชื่อ</option>
<?php
$query6 = " SELECT * FROM prefix";
$result6 = $dbObj->execQuery($query6);
while($rs6 = mysql_fetch_object($result6)){
?>
<option style="text-align:left" value="<?=$rs6->prefixId;?>" >
<?=$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();"/>
<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();"/>
<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="" 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','<?=date("d/m/Y");?>');</script> </td>
<td width="442" nowrap="nowrap" bordercolor="#CCCCCC" bgcolor="#FFFFFF" class="style14">
<input type="checkbox" name="People_legal" id="People_legal" value="ไม่บรรลุนิตภาวะ"/>ยังไม่บรรลุนิตภาวะ
<input type="checkbox" name="People_incom" id="People_incom" value="ไร้ความสามารถ" />เป็นบุตรไร้ความสามารถ หรือเสมือนไร้ความสามารถ </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"/></td>
<td nowrap="nowrap" bordercolor="#CCCCCC" bgcolor="#FFFFFF" class="style14 style1">(กรอกเฉพาะ บุตร)</td>
</tr>
<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="btnAdd" value="บันทึกข้อมูล" onclick="CheckDoSubmit();">
<input type="hidden" name="Teacher_code" value="<?=$Teacher_code ?>">
<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);
?>
|