<?php
include_once "template.php";
include_once 
"../class/clsTable.php";
include_once 
"../class/clsDepartment.php";
include_once 
"../class/clsPerson.php";
include_once 
"../link/function.php";
include_once 
"../link/keyThai.php";
include_once 
"getPrefix.php";

$oC = new clsConnection($GLOBALS['DBHOST'], $GLOBALS['DBNAME_EOFFICE'], $GLOBALS['DBUSER_EOFFICE'], $GLOBALS['DBPASS_EOFFICE']);

$oDP = new Department($oC);
$oDP2 = new Department($oC);
$oDP3 = new Department($oC);
$oPS = new person($oC);
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=tis-620">
<link href="../source/style.css" rel="stylesheet" type="text/css">
</head>
<body>
<iframe id="changeDept" name="changeDept" src="" style="width:0px;height:0px;border:0"></iframe>
<br>
<table  width=703  align="center">
<tr><td height="150">
<fieldset>
      <legend><font size="2" color="<?php echo $GLOBALS["COLOR_FONT_3"]; ?>"><a href="?mm=1">จัดการข้อมูลบุคลากรและโครงสร้าง</a>
     <img src="../picture/ico3.gif" width="10" height="10" border="0" align="absmiddle">กำหนดผู้ใช้ทั่วไปในหน่วยงานรองรายบุคคล</font></legend><br>
     <form name="ff"  METHOD="POST" action="setPsDept.php">
     
  <table width="90%" border="0" align="center" cellpadding="0" cellspacing="0">
              <tr><td  height="30" align="center">
            <table border="0" width="100%">
            <tr><td align="right"><b>กำหนดหน่วยงานรองรายบุคคล</b> | <a href="setPsDeptGroup.php">กำหนดหน่วยงานรองแยกตามหน่วยงาน</a>&nbsp;</td></tr>
            <tr><td><strong><font size="2" color="<?php echo $GLOBALS["COLOR_FONT_2"];?>">&nbsp;&nbsp;
            <img src="../picture/search2.jpg" alt=""  border="0" >
            ค้นหารายชื่อบุคลากร</font></strong></td></tr>
            <tr>
            <td height="30" align="left"><font size="2" color="<?php echo $GLOBALS["COLOR_FONT_2"];?>">&nbsp;&nbsp;&nbsp;&nbsp;ชื่อ - นามสกุล ::</font>
            <input type="text" name="name" value="<? echo $name?>">&nbsp;<input type=submit value="ค้นหา" align=center>
              </td>
          </tr>
            </table>
            </td></tr>
              
            <tr>
            <td align="center"><br>
        <? if($name!=""){ ?>    
        <table width="80%" height="22" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#DADADA" style="border-collapse:collapse">
          <tr bgcolor="<?php echo $GLOBALS['COLOR_BG_TD_15'];?>"> 
            <td height="24" colspan="4"    align="center" ><strong><font size="2" color="<?php echo $GLOBALS["COLOR_FONT_2"];?>">&nbsp;&nbsp; 
              รายชื่อบุคลากร</font></strong></td>
          </tr>
          <tr bgcolor="<?php echo $GLOBALS['COLOR_BG_TD_4'];?>"> 
            <td height="26" width="82" align="center" ><font size="2" color="<?php echo $GLOBALS["COLOR_FONT_2"];?>"><strong>ลำดับที่</strong></font></td>
            <td width="927" align="center"><font size="2" color="<?php echo $GLOBALS["COLOR_FONT_2"];?>"><strong>ชื่อ-นามสกุล</strong></font></td>
          </tr>
          <?php 

                  $oPS
->SearchByName($name);
                while(
$oPS->GetRecord()){
                                if((
$i%2) == 0)
                                          echo 
"<tr>";
                                    else
                                          echo 
"<tr bgcolor=\"".$GLOBALS['COLOR_BG_TABLE_8']."\">";
?>
          
            <td width="82" align="center"><font size="2" color="<?php echo $GLOBALS["COLOR_FONT_4"];?>"><? echo ($i+1);?>
              </font></td>
            <td align="left" height="22"><font size="2" color="<?php echo $GLOBALS["COLOR_FONT_4"];?>">&nbsp;&nbsp;
            <a href="addSetPsDept.php?ps=<? echo $oPS->personId?>&name=<? echo $name?>"><? echo GetPrefix($oPS->prefixId).$oPS->fName."&nbsp;".$oPS->lName?></a>            
              </font></td>
          </tr>
          <? $i++;  }
          if(
$i==0){
           
?>
           <tr><td colspan="2" align="center" height="22"><font color="<?php echo $GLOBALS["COLOR_FONT_3"]; ?>" size="2">** ไม่มีข้อมูลบุคลากร **</font></td></tr>
           <? ?>
       </table><? ?></td></tr>
       <tr><td align="right"><a href="printSetPsDept.php">[&nbsp;<img src="../picture/search.gif" alt="ค้นหา"  border="0" style="cursor:pointer;">&nbsp;<strong>สรุปข้อมูลบุคลากรในหน่วยงานรองทั้งหมด</strong>]</a></td></tr>
       </table> </form>
</fieldset>
         <table width="704" border="0" align="center">
        <tr> 
          <td width="76"><font color="<?php echo $GLOBALS["COLOR_FONT_3"]; ?>" size="2">&nbsp;<strong>หมายเหตุ 
            : </strong>&nbsp;</font></td>
          <td width="618"><font color="<?php echo $GLOBALS["COLOR_FONT_3"]; ?>" size="2">คลิกที่ชื่อบุคลากรเมื่อต้องการกำหนดผู้ใช้ทั่วไปในหน่วยงานรอง</font></td>
        </tr>
      </table> <br><br> <br><br> <br><br>
</td>
</tr>
</table>
</body>
</html>
<script language="javascript">
function checkFormat2(){
        window.alert("หมายเหตุ :: การปรับโครงสร้างเพื่อการส่งหนังสือในระบบสารบรรณจะเปลี่ยนแปลง\nข้อมูลหน่วยงาน และข้อมูลบุคลากร ผู้รับผิดชอบระบบ\nต้องตั้งค่าการใช้งานระบบใหม่");
        var agree=confirm("คุณต้องการปรับโครงสร้างเพื่อการส่งหนังสือในระบบสารบรรณใช่หรือไม่ ?");
        if (agree){
                    return true ;
        }else{
                    return false ;
        }    
}
</script>