<?php
include_once("../../class/clsConnection.php");
include_once(
"../../class/clsDB.php");
include_once 
"../global.php";
include_once 
"../link/function.php";
include_once 
"../class/clsTable.php";
include_once 
"../class/clsDepartment.php";
include_once 
"../class/clsPerson.php";
include_once 
"../link/function.php";
include_once 
"../class/clsdepttype.php";
$oC = new clsConnection($GLOBALS['DBHOST'], $GLOBALS['DBNAME_EPERSON'], $GLOBALS['DBUSER_EPERSON'], $GLOBALS['DBPASS_EPERSON']);

$oDpT = new Department($oC);
$oDp = new Department($oC);
$oDP3 = new Department($oC);
$oDP2 = new Department($oC);
$oPS = new Person($oC);
$maxdate $oDP3->MaxDate();
?>
<html>
<head>
<title>โครงสร้างเพื่อการส่งหนังสือในระบบสารบรรณ</title>
<meta http-equiv="Content-Type" content="text/html; charset=tis-620">
<link href="../source/style.css" rel="stylesheet" type="text/css">
<table width="100%" border="0" cellspacing="0" cellpadding="1" align="center" bgcolor="#F9FCFF">
    <tr>
        <td align="left" colspan="4"  height="22" valign="top">&nbsp;<a href="#" onClick="window.close()"><font size="2" face="Microsoft Sans Serif">[ปิดหน้าต่าง]</font></a></td>
    </tr>
</table>
<table width="100%" height="100%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#F9FCFF">
    <tr>
        <td valign="top"><br>
<label><div align="center">
<font size="2" color="<?php echo $GLOBALS['COLOR_FONT_4'];?>"><b>โครงสร้างเพื่อการส่งหนังสือในระบบสารบรรณ&nbsp;<?  if($deptDate==$maxdate && $maxdate !='0000-00-00'){   echo "<br>วันที่ยืนยันการใช้งาน&nbsp;".abbreDate(splitDateDb2($deptDate ,'/'))." (โครงสร้างปัจจุบัน)"; }else if($deptDate=='0000-00-00'){   echo "<br>(ยังไม่ยืนยันการใช้งานโครงสร้างนี้)"; }else{ echo "<br>วันที่ยืนยันการใช้งาน&nbsp;".abbreDate(splitDateDb2($deptDate ,'/'));   } ?></b></font>
    <?
    $oT 
= new clsTable(array("ส่วนราชการภายใน","ประเภทของ<br>ส่วนราชการภายใน","รายละเอียด"));
    
$oT->bgColor="#CCCCCC";
    
$oT->align="center";
    
$oDpT->searchdeptDate2($deptDate);
    
    
$rw=0;
    
    while (
$oDpT->GetRecord()){
        
ShowDeptM($oDpT->deptId,$deptDate);        
    }
    
    
$oT->rowStart("","#ffffff");
    
$oT->addCell("");
    
$oT->rowEnd();
    
    echo 
"<form name=ps method=post>";
    echo 
"<input type=hidden name=method value=''>";
    echo 
"<input type=hidden name=startyear value=''>";
    echo 
$oT->output();
    echo 
"</form>";
    
//////////////////////////////////////////
    
    
function ShowDeptM($deptId,$deptDate){
        global 
$oC;
        global 
$oT;
        global 
$Str;
        global 
$rw;
    
        
$oDp  = new Department($oC);
        
$oDpt= new Departmenttype($oC);
        
$oDp->SearchByKey($deptId);
        
$oDp->GetRecord();
        
/////////////////////////////////////////////
        
if ($oDp->deptLevel%2==0){                            
            
$bs="<b>";    
            
$be="</b>";    
        }
        
$lv =  $oDp->deptLevel+1;
        
$oDpt->SearchByKey($oDp->depttypeId);
        
$oDpt->GetRecord();
        
$dt $oDpt->depttypeName;
        
$det $oDp->deptDesc;
        
$oT->addRow(array(str_repeat("<img src=../picture/blank.gif><img src=../picture/blank.gif><img src=../picture/blank.gif><img src=../picture/blank.gif><img src=../picture/blank.gif><img src=../picture/blank.gif>"$oDp->deptLevel*2). $bs ."   ".$oDp->deptName."  "$be,$dt,$det));
        
$oDp->RSmenuByDeptParentdeptDate($deptId,$deptDate);
        while (
$oDp->GetRecord()){
            
ShowDeptM($oDp->deptId,$deptDate);
        }
    }
    
?>
</div></td>
    </tr>
</table>
</body>
</html>
<?php
showFooter
();
?>