<?
include_once("pagebody.php");
pageHeader();
$pageTitle="เพิ่มผู้ใช้งานระบบ";
?>
<table width=100% class="pageTitleBgColor" align="center">
<tr><td align=center><? echo $pageTitle?></td></tr>
</table>
<!--your code here-------------------------------------------------------------------------->
<?
include_once("clsUmQuestion.php");
include_once(
"clsUmUser.php");
include_once(
"clsUmGroup.php");
include_once(
"clsUmUserGroup.php");
include_once(
"clsUmWgroup.php");
$oC = new clsConnection($GLOBALS['HOST'], $GLOBALS['DB'], $GLOBALS['USER'], $GLOBALS['PASSWORD']);
$oUs = new umuser($oC);
$oGp = new umgroup($oC);
$oQ = new umquestion($oC);
//$oPv = new province($oC->c);
//$oOc = new occ($oC->c);
$oUg = new umusergroup($oC);
$oWg = new umwgroup($oC);
$oTbl = new clsTable();
$oTbl->align="center";
?>
<br>
<form name="form1" method=post action="processUmUser.php">
<input type="hidden"name="method" value="add">
<?

$oTbl
->addRow(array("","<input type=hidden name=UsID value=$UsID>"));
$oTbl->addRow(array("รหัสผู้ใช้","<input type=\"text\" name=\"UsPsCode\" value=\"$UsPsCode\" >*(รหัสบุคลากร/รหัสนักศึกษา)"));
$oTbl->addRow(array("ชื่อ-สกุล","<input type=\"text\" name=\"UsName\" value=\"$oUs->UsName\"  size=\"30\" maxlength=\"50\">"));
$oTbl->addRow(array("กลุ่มผู้ใช้",$oWg->selectHTML("UsWgID")."*"));
$oTbl->addRow(array("ชื่อผู้ใช้","<input type=\"text\" name=\"UsLogin\" value=\"$UsLogin\" size=\"30\" maxlength=\"20\">* ไม่เกิน 20 ตัวอักษร"));
$oTbl->addRow(array("รหัสผ่าน","<input type=\"password\" name=\"UsPassword\" value=\"$UsPassword\" size=\"30\" maxlength=\"20\">* ไม่เกิน 20 ตัวอักษร"));
$oTbl->addRow(array("ยืนยันรหัสผ่าน","<input type=\"password\" name=\"ConfirmPassword\" value=\"$ConfirmPassword\" size=\"30\" maxlength=\"20\">* ไม่เกิน 20 ตัวอักษร"));
$oTbl->addRow(array("เลือกคำถามส่วนตัว",$oQ->selectHTML("UsQsID",$GLOBALS['sysLang'])."*"));
$oTbl->addRow(array("คำตอบ","<input type=\"text\" name=\"UsAnswer\" value=\"$UsAnswer\" size=\"40\" maxlength=\"40\">*"));
$oTbl->addRow(array("e-mail","<input type=\"text\" name=\"UsEmail\" value=\"$UsEmail\" size=\"40\" maxlength=\"40\">*"));
$oTbl->addRow(array("หมายเหตุ","<textarea name=\"UsDesc\" rows=\"5\" cols=\"40\">$UsDesc</TextArea>"));
$oTbl->addRow(array("","<input type=checkbox name=UsActive>Active"));
$oTbl->addRow(array("","<input type=checkbox name=UsAdmin>Administrator"));
$oTbl->rowStart(1,"#efefef");
$oTbl->addCell("กลุ่มระบบงาน");
$oGp->RSumgroupOrderStID();
while (
$oGp->GetRecord()){
    
$s.="<input type=checkbox name=GpID[] value=".$oGp->GpID;
    
$oUg->SearchByKey($oGp->GpID,$oUs->UsID);
    if (
$oUg->GetRowSelected()>0
        
$s.=" checked";
    
$s.=">$oGp->GpNameT<br>\n";
}
$oTbl->addCell($s);
$oTbl->rowEnd();


$oTbl->addRow(array("","<input type=\"button\" value=\"บันทึก\" onclick=\"doSave(form1)\">"));
//$oTbl->addRow(array("",""));
echo $oTbl->output();
?>
</form>
<br>
<!--------------------------------------------------------------------->
<? 
pageFooter
(); 
?>
<!--------------------------------------------------------------------->
<!--put javascript here-->
<script language="javascript">
function doSave(f){    
    if (IsEmpty(f.UsPsCode, "กรุณาป้อนรหัสผู้ใช้")) return 0;    
    if (IsEmpty(f.UsWgID, "กรุณาเลืกกลุ่มผู้ใช้")) return 0;
    if (IsEmpty(f.UsLogin, "กรุณาป้อน ชื่อล๊อกอิน")) return 0;
    if (IsEmpty(f.UsPassword, "กรุณาป้อน รหัสผ่าน")) return 0;
    if (IsEmpty(f.ConfirmPassword, "กรุณาป้อน ยืนยันรหัสผ่าน")) return 0;
    if (f.UsPassword.value!=f.ConfirmPassword.value){
        alert('รหัสผ่านไม่เหมือนกัน');
        return 0;
    }
    if (IsEmpty(f.UsQsID, "กรุณาเลือกคำถาม")) return 0;
    if (IsEmpty(f.UsAnswer, "กรุณาป้อน คำตอบ")) return 0;
    if (IsEmpty(f.UsEmail, "กรุณาป้อน อีเมล์")) return 0;

    f.submit();
}
function selectDate(fld){
    return 1;
}
//document.form1.StNameT.focus();

</script>