!c99Shell v. 1.0 pre-release build #16!

Software: Apache/2.2.3 (CentOS). PHP/5.1.6 

uname -a: Linux mx-ll-110-164-51-230.static.3bb.co.th 2.6.18-194.el5PAE #1 SMP Fri Apr 2 15:37:44
EDT 2010 i686
 

uid=48(apache) gid=48(apache) groups=48(apache) 

Safe-mode: OFF (not secure)

/var/www/html/mistk/eoffice/admin/   drwxr-xr-x
Free 52.23 GB of 127.8 GB (40.87%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Feedback    Self remove    Logout    


Viewing file:     functMobile.php (96.29 KB)      -rw-r--r--
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php  
extract 
($_REQUEST);
function 
ShowRunningDoc($RsID,$DtID,$deptId){   
include_once(
"../../class/clsConnection.php");
include_once(
"../../class/clsDB.php");
include_once 
"../global.php";
include_once 
"../class/clsDepartment.php";
include_once 
"../class/clsRunningDoc.php";
include_once 
"../class/clsDocType.php";
include_once 
"../link/keyThai.php";
include_once 
"getPrefix.php";
include_once 
"../class/clsSysConfig.php";

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

$oDP = new Department($oC);
$oDP2 = new Department($oC);
$oRd = new runningdoc($oC);
$oDt = new doctype($oC);
$oDt1 = new doctype($oC);
$oSys = new sysConfig($oC);

$maxgroup=$oDP->SearchMaxDocGroup();
$oSys->SearchByKey($free);
$oSys->GetRecord();

    if(
$RsID=="1"){ //receiveOut
            
if(($DtID=="1" || $DtID=="2" || $DtID=="3" || $DtID=="14" || $DtID=="15") && ($oSys->useDocTypeNoMix=='N')){
                
$oRd->SearchRunningBydocGroupDtIDfunctDeptdocNoMixN($maxgroup,$DtID,$deptId);
                
$oRd->GetRecord();        
            }else{
                
$oRd->SearchRunningBydocGroupDtIDfunctdocNoMixY($maxgroup,$DtID);
                
$oRd->GetRecord();        
            }
            
            if(
$oRd->confirm=="Y"){
                if(
$oRd->receiveNo=="0" && ($oRd->receiveNoStart!="0" && $oRd->receiveNoStart!="")){
                    
$runningDoc=$oRd->receiveNoStart;
                }else if(
$oRd->receiveNo!="0" && ($oRd->receiveNoStart!="0" && $oRd->receiveNoStart!="")){
                    
$rN=$oRd->receiveNo;
                    
$rN=$rN+1;
                    
$runningDoc=$rN;
                }else{
                    
$runningDoc="N";
                }
            }else{
                
$runningDoc="NoConfirm";
            }
            return 
$runningDoc;
    }else if(
$RsID=="2"){ //sendOut    
            
if(($DtID=="1" || $DtID=="2" || $DtID=="3" || $DtID=="14" || $DtID=="15") && ($oSys->useDocTypeNoMix=='N')){
                
$oRd->SearchRunningBydocGroupDtIDfunctDeptdocNoMixN($maxgroup,$DtID,$deptId);
                
$oRd->GetRecord();        
            }else{
                
$oRd->SearchRunningBydocGroupDtIDfunctdocNoMixY($maxgroup,$DtID);
                
$oRd->GetRecord();        
            }
            
            if(
$oRd->confirm=="Y"){
                if(
$oRd->sendNo=="0" && ($oRd->sendNoStart!="0" && $oRd->sendNoStart!="")){
                    
$runningDoc=$oRd->sendNoStart;
                }else if(
$oRd->sendNo!="0" && ($oRd->sendNoStart!="0" && $oRd->sendNoStart!="")){
                    
$sN=$oRd->sendNo;
                    
$sN=$sN+1;
                    
$runningDoc=$sN;
                }else{
                    
$runningDoc="N";
                }
            }else{
                
$runningDoc="NoConfirm";
            }
            return 
$runningDoc;    
    }else if(
$RsID=="3"){ //receiveIn
            
$oDt->SearchByKey($DtID);
            
$oDt->GetRecord();
            if(
$oDt->DtRunAll=="N"){
                    
$oRd->SearchRunningBydocGroupDtIDfunctDeptdocNoMixN($maxgroup,$DtID,$deptId);
                    
$oRd->GetRecord();
            }else{
                    
$oRd->SearchRunningBydocGroupDtIDfunct($maxgroup,$DtID);
                    
$oRd->GetRecord();
            }
                if(
$oRd->confirm=="Y"){
                    if(
$oRd->receiveNo=="0" && ($oRd->receiveNoStart!="0" && $oRd->receiveNoStart!="")){
                        
$runningDoc=$oRd->receiveNoStart;
                    }else if(
$oRd->receiveNo!="0" && ($oRd->receiveNoStart!="0" && $oRd->receiveNoStart!="")){
                        
$rN=$oRd->receiveNo;
                        
$rN=$rN+1;
                        
$runningDoc=$rN;
                    }else{
                        
$runningDoc="N";
                    }
                }else{
                    
$runningDoc="NoConfirm";
                }
            return 
$runningDoc;    
    }else if(
$RsID=="4"){ //sendIn
            
$oDt->SearchByKey($DtID);
            
$oDt->GetRecord();
            if(
$oDt->DtRunAll=="N"){
                    
$oRd->SearchRunningBydocGroupDtIDfunctDeptdocNoMixN($maxgroup,$DtID,$deptId);
                    
$oRd->GetRecord();
            }else{
                    
$oRd->SearchRunningBydocGroupDtIDfunct($maxgroup,$DtID);
                    
$oRd->GetRecord();
            }
                if(
$oRd->confirm=="Y"){
                    if(
$oRd->sendNo=="0" && ($oRd->sendNoStart!="0" && $oRd->sendNoStart!="")){
                        
$runningDoc=$oRd->sendNoStart;
                    }else if(
$oRd->sendNo!="0" && ($oRd->sendNoStart!="0" && $oRd->sendNoStart!="")){
                        
$sN=$oRd->sendNo;
                        
$sN=$sN+1;
                        
$runningDoc=$sN;
                    }else{
                        
$runningDoc="N";
                    }
                }else{
                    
$runningDoc="NoConfirm";
                }
            return 
$runningDoc;    
    }else if(
$RsID=="5"){ //for regidDoc
            
$oDt->SearchByKey($DtID);
            
$oDt->GetRecord();
            
            if(
$oSys->useDocTypeNoMix=='N'){
                
$oRd->SearchRunningBydocGroupDtIDfunctDeptdocNoMixN($maxgroup,$DtID,$deptId);
                
$oRd->GetRecord();        
            }else{
                
$oRd->SearchRunningBydocGroupDtIDfunctdocNoMixY($maxgroup,$DtID);
                
$oRd->GetRecord();        
            }            
/*
            if($oDt->DtRunAll=="N"){
                    $oRd->SearchRunningBydocGroupDtIDfunctDept($maxgroup,$DtID,$deptId);
                    $oRd->GetRecord();
            }else{
                    $oRd->SearchRunningBydocGroupDtIDfunct($maxgroup,$DtID);
                    $oRd->GetRecord();
            }
*/
                
if($oRd->confirm=="Y"){
                    if(
$oRd->regisNo=="0" && ($oRd->regisNoStart!="0" && $oRd->regisNoStart!="")){
                        
$runningDoc=$oRd->regisNoStart;
                    }else if(
$oRd->regisNo!="0" && ($oRd->regisNoStart!="0" && $oRd->regisNoStart!="")){
                        
$rN=$oRd->regisNo;
                        
$rN=$rN+1;
                        
$runningDoc=$rN;
                    }else{
                        
$runningDoc="N";
                    }
                }else{
                    
$runningDoc="NoConfirm";
                }
            return 
$runningDoc;
    }
}
function 
ShowDocNo($RsID,$DtID,$deptId,$DocfCir,$useMainDocNo){
include_once(
"../../class/clsConnection.php");
include_once(
"../../class/clsDB.php");
include_once 
"../global.php";
include_once 
"../class/clsDepartment.php";
include_once 
"../class/clsDocType.php";
include_once 
"../class/clsRunningDoc.php";
include_once 
"../class/clsSysConfig.php";
include_once 
"getPrefix.php";
include_once 
"../class/clsSysConfig.php";

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

$oDP = new Department($oC);
$oDP2 = new Department($oC);
$oDt = new doctype($oC);
$oRd = new runningdoc($oC);
$oSys = new sysConfig($oC);

$maxgroup=$oDP->SearchMaxDocGroup();
$oSys->SearchByKey($free);
$oSys->GetRecord();

    if(
$RsID=="2"){ //sendOut
        
if(($DtID=="1" || $DtID=="2" || $DtID=="3" || $DtID=="14" || $DtID=="15") && ($oSys->useDocTypeNoMix=='N')){
            
$oRd->SearchRunningBydocGroupDtIDfunctDeptdocNoMixN($maxgroup,$DtID,$deptId);
            
$oRd->GetRecord();        
        }else{
            
$oRd->SearchRunningBydocGroupDtIDfunctdocNoMixY($maxgroup,$DtID);
            
$oRd->GetRecord();        
        }

    
            if(
$oRd->sendNo=="0"){
                
$runningDoc_=$oRd->sendNoStart;
            }else{
                
$runningDoc_=($oRd->sendNo+1);
            }
            
$oSysDocNo=$oSys->SearchByKeyName('sysDocNo');
            
            
$oDt->SearchByKey($DtID);
            
$oDt->GetRecord();            
            
            
$oDP2->SearchByShowDocNo($deptId);
            
$oDP2->GetRecord();
            
            if(
$oDP2->deptLevel!=0){
                
$deptId=SearchdeptIdlevel0($oDP2->deptParentId);
            }
            
$oDP->SearchByKey($deptId);
            
$oDP->GetRecord();
            
            if(
$oDt->sendNoPrefix!=""){
                
$DocNo=$oDt->sendNoPrefix;
            }
            if(
$oDt->sendNoSuffix!=""){
                
$DocNo=$DocNo.$oDt->sendNoSuffix;
            }
            
            if(
$useMainDocNo=="Y"){  
                
$DocNo preg_replace("/%o.%d/""%o"$DocNo);
            }
                
$DocNo preg_replace("/%o/""$oSysDocNo"$DocNo);
                
$DocNo preg_replace("/%d/""$oDP->deptNo"$DocNo);
                
$DocNo preg_replace("/%r/""$runningDoc_"$DocNo);
            
$Y date('Y')+543;
            
$DocNo preg_replace("/%y/""$Y"$DocNo);
            if(
$DocfCir=="Y"){ $DocfCir_="ว."; }else{ $DocfCir_="";  }
            
$DocNo preg_replace("/%p/""$DocfCir_"$DocNo);
            return 
$DocNo;    
    }else if(
$RsID=="3"){ //receiveIn
            
if($DtID=="3"){
                    
$oRd->SearchRunningBydocGroupDtIDfunctDept($maxgroup,$DtID,$deptId);
                    
$oRd->GetRecord();
            }else{
                    
$oRd->SearchRunningBydocGroupDtIDfunct($maxgroup,$DtID);
                    
$oRd->GetRecord();
            }
                    if(
$oRd->receiveNo=="0"){
                        
$runningDoc_=$oRd->receiveNoStart;
                    }else{
                        
$runningDoc_=($oRd->receiveNo+1);
                    }
                    
$oSysDocNo=$oSys->SearchByKeyName('sysDocNo');
            
                    
$oDt->SearchByKey($DtID);
                    
$oDt->GetRecord();
                    
                    
                    
$oDP->SearchByKey($deptId);
                    
$oDP->GetRecord();
                    
                    
                    
                    if(
$oDt->sendNoPrefix!=""){
                        
$DocNo=$oDt->sendNoPrefix;
                    }
                    if(
$oDt->sendNoSuffix!=""){
                        
$DocNo=$DocNo.$oDt->sendNoSuffix;
                    }
                    
$DocNo preg_replace("/%o/""$oSysDocNo"$DocNo);
                    
$DocNo preg_replace("/%d/""$oDP->deptNo"$DocNo);
                    
$DocNo preg_replace("/%r/""$runningDoc_"$DocNo);
                    
$Y date('Y')+543;
                    
$DocNo preg_replace("/%y/""$Y"$DocNo);
                    if(
$DocfCir=="Y"){ $DocfCir_="ว."; }else{ $DocfCir_="";  }
                    
$DocNo preg_replace("/%p/""$DocfCir_"$DocNo);
                    return 
$DocNo;    
    }else if(
$RsID=="4"){ //sendIn
            
if($DtID=="3" || $DtID=="15"){
                    
$oRd->SearchRunningBydocGroupDtIDfunctDeptdocNoMixN($maxgroup,$DtID,$deptId);
                    
$oRd->GetRecord();
            }else{
                    
$oRd->SearchRunningBydocGroupDtIDfunct($maxgroup,$DtID);
                    
$oRd->GetRecord();
            }

                if(
$oRd->sendNo=="0"){
                    
$runningDoc_=$oRd->sendNoStart;
                }else{
                    
$runningDoc_=($oRd->sendNo+1);
                }
                
$oSysDocNo=$oSys->SearchByKeyName('sysDocNo');
        
                
$oDt->SearchByKey($DtID);
                
$oDt->GetRecord();
                
                
$oDP->SearchByKey($deptId);
                
$oDP->GetRecord();
                
                if(
$oDt->sendNoPrefix!=""){
                    
$DocNo=$oDt->sendNoPrefix;
                }
                if(
$oDt->sendNoSuffix!=""){
                    
$DocNo=$DocNo.$oDt->sendNoSuffix;
                }
                
$DocNo preg_replace("/%o/""$oSysDocNo"$DocNo);
                
$DocNo preg_replace("/%d/""$oDP->deptNo"$DocNo);
                
$DocNo preg_replace("/%r/""$runningDoc_"$DocNo);
                
$Y date('Y')+543;
                
$DocNo preg_replace("/%y/""$Y"$DocNo);
                if(
$DocfCir=="Y"){ $DocfCir_="ว."; }else{ $DocfCir_="";  }
                
$DocNo preg_replace("/%p/""$DocfCir_"$DocNo);
                return 
$DocNo;    
    }else if(
$RsID=="5"){ //for regisDoc
    /*
            if($DtID=="3"){
                    $oRd->SearchRunningBydocGroupDtIDfunctDept($maxgroup,$DtID,$deptId);
                    $oRd->GetRecord();
            }else{
                    $oRd->SearchRunningBydocGroupDtIDfunct($maxgroup,$DtID);
                    $oRd->GetRecord();
            }
    */        
            
if($oSys->useDocTypeNoMix=='N'){
                
$oRd->SearchRunningBydocGroupDtIDfunctDeptdocNoMixN($maxgroup,$DtID,$deptId);
                
$oRd->GetRecord();        
            }else{
                
$oRd->SearchRunningBydocGroupDtIDfunctdocNoMixY($maxgroup,$DtID);
                
$oRd->GetRecord();        
            }

                if(
$oRd->regisNo=="0"){
                    
$runningDoc_=$oRd->regisNoStart;
                }else{
                    
$runningDoc_=($oRd->regisNo+1);
                }
                
$oSysDocNo=$oSys->SearchByKeyName('sysDocNo');
        
                
$oDt->SearchByKey($DtID);
                
$oDt->GetRecord();

                
$oDP2->SearchByShowDocNo($deptId);
                
$oDP2->GetRecord();
                
                if(
$oDP2->deptLevel!=0){
                    
$deptId=SearchdeptIdlevel0($oDP2->deptParentId);
                }
                
$oDP->SearchByKey($deptId);
                
$oDP->GetRecord();

                
                if(
$oDt->sendNoPrefix!=""){
                    
$DocNo=$oDt->sendNoPrefix;
                }
                if(
$oDt->sendNoSuffix!=""){
                    
$DocNo=$DocNo.$oDt->sendNoSuffix;
                }
                
$DocNo preg_replace("/%o/""$oSysDocNo"$DocNo);
                
$DocNo preg_replace("/%d/""$oDP->deptNo"$DocNo);
                
$DocNo preg_replace("/%r/""$runningDoc_"$DocNo);
                
$Y date('Y')+543;
                
$DocNo preg_replace("/%y/""$Y"$DocNo);
                if(
$DocfCir=="Y"){ $DocfCir_="ว."; }else{$DocfCir_=""; }
                
$DocNo preg_replace("/%p/""$DocfCir_"$DocNo);
                return 
$DocNo;    
    }
}
function 
ShowEditDocNo($RsID,$DtID,$deptId,$P,$runningDoc,$useMainDocNo){
include_once(
"../../class/clsConnection.php");
include_once(
"../../class/clsDB.php");
include_once 
"../global.php";
include_once 
"../class/clsDepartment.php";
include_once 
"../class/clsDocType.php";
include_once 
"../class/clsRunningDoc.php";
include_once 
"../class/clsSysConfig.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);
$oDt = new doctype($oC);
$oRd = new runningdoc($oC);
$oSys = new sysConfig($oC);

$maxgroup=$oDP->SearchMaxDocGroup();

    if(
$RsID=="2" || $RsID=="4" || $RsID=="5"){ //sendOut

            
$oSys->RSsysConfig();
            
$oSys->GetRecord();
    
            
$oDt->SearchByKey($DtID);
            
$oDt->GetRecord();
            
            
$oDP2->SearchByKey($deptId);
            
$oDP2->GetRecord();
            
            if(
$RsID!='4'){
                if(
$oDP2->deptLevel!=0){
                    
$deptId=SearchdeptIdlevel0($oDP2->deptParentId);
                }
            }
            

            
$oDP->SearchByKey($deptId);
            
$oDP->GetRecord();
        
            if(
$oDt->sendNoPrefix!=""){
                
$DocNo=$oDt->sendNoPrefix;
            }
            if(
$oDt->sendNoSuffix!=""){
                
$DocNo=$DocNo.$oDt->sendNoSuffix;
            }
            if(
$useMainDocNo=="Y"){
                
$DocNo preg_replace("/%o.%d/""%o"$DocNo);
            }
            
$DocNo preg_replace("/%o/""$oSys->sysDocNo"$DocNo);
            
$DocNo preg_replace("/%d/""$oDP->deptNo"$DocNo);
            
$DocNo preg_replace("/%r/""$runningDoc"$DocNo);
            
$Y date('Y')+543;
            
$DocNo preg_replace("/%y/""$Y"$DocNo);
            if(
$P=="Y"){ $P="ว."; }else{ $P=""; }
            
$DocNo preg_replace("/%p/""$P"$DocNo);
            return 
$DocNo;    
    }
}
function 
GetNextPsToSign($DlcID,$deptId){
include_once(
"../../class/clsConnection.php");
include_once(
"../../class/clsDB.php");
include_once 
"../global.php";
include_once 
"../class/clsDepartment.php";
include_once 
"../class/clsPerson.php";
include_once 
"../class/clsDocLinePosition.php";
include_once 
"../class/clsDocLineConfig.php";
include_once 
"../class/clsReceiveSendType.php";
include_once 
"../class/clsDocType.php";
include_once 
"../class/clsDocuments.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);
$oUG = new umgroup($oCu);
$oDlc = new DocLineConfig($oC);
$oDlc2 = new DocLineConfig($oC);
$oDlc3 = new DocLineConfig($oC);
$oDlp = new docLinePosition($oC);
$oRSt = new receiveSendType($oC);
$oDt = new doctype($oC);
$oDoc = new Documents($oC);
$maxgroup=$oDP->SearchMaxDocGroup();

    
$oDlc->SearchByKey($DlcID); $oDlc->GetRecord(); 
    
$oDlp->SearchByKey($oDlc->DlpID); $oDlp->GetRecord();
    if(
$oDlp->DlpPID=="0"){
        
$nextSeq=($oDlc->DlcSeq+2);
        
$oDlc2->SearchByNextDlcID($nextSeq,$maxgroup,$oDlc->deptId); $oDlc2->GetRecord(); 

        if(
$oDlc2->DlcSign=="N"){
            
$oDlc3->SearchByNextDlcID(($nextSeq+1),$maxgroup,$oDlc->deptId); $oDlc3->GetRecord(); 
            if(
$oDlc3->DlcSign=="N"){
                
$nextDlcID="N";
            }else{
                
$nextDlcID=$oDlc3->DlcID;
            }
        }else{
            
$nextDlcID=$oDlc2->DlcID;
        }
        return 
$nextDlcID;
        
    }else{
        
$nextSeq=($oDlc->DlcSeq+1);
        
$oDlc2->SearchByNextDlcID($nextSeq,$maxgroup,$oDlc->deptId); $oDlc2->GetRecord(); 

        if(
$oDlc2->DlcSign=="N"){
            
$oDlc3->SearchByNextDlcID(($nextSeq+1),$maxgroup,$oDlc->deptId); $oDlc3->GetRecord(); 
            if(
$oDlc3->DlcSign=="N"){
                
$nextDlcID="N";
            }else{
                
$nextDlcID=$oDlc3->DlcID;
            }
        }else{
            
$nextDlcID=$oDlc2->DlcID;
        }
        return 
$nextDlcID;
    }
}
function 
GetNextPrePsToSign($DlcID,$deptId){
include_once(
"../../class/clsConnection.php");
include_once(
"../../class/clsDB.php");
include_once 
"../global.php";
include_once 
"../class/clsDepartment.php";
include_once 
"../class/clsPerson.php";
include_once 
"../class/clsDocLinePosition.php";
include_once 
"../class/clsDocLineConfig.php";
include_once 
"../class/clsReceiveSendType.php";
include_once 
"../class/clsDocType.php";
include_once 
"../class/clsDocuments.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);
$oUG = new umgroup($oCu);
$oDlc = new DocLineConfig($oC);
$oDlc2 = new DocLineConfig($oC);
$oDlc3 = new DocLineConfig($oC);
$oDlp = new docLinePosition($oC);
$oRSt = new receiveSendType($oC);
$oDt = new doctype($oC);
$oDoc = new Documents($oC);
$maxgroup=$oDP->SearchMaxDocGroup();

    
$oDlc->SearchByKey($DlcID); $oDlc->GetRecord(); 
    
$oDlp->SearchByKey($oDlc->DlpID); $oDlp->GetRecord();
    if(
$oDlp->DlpPID=="0"){
        
$nextSeq=($oDlc->DlcSeq+2);
        
$oDlc2->SearchByNextDlcID($nextSeq,$maxgroup,$oDlc->deptId); $oDlc2->GetRecord(); 
        
$nextDlcID=$oDlc2->DlcID;
        return 
$nextDlcID;
        
    }else{
        
$nextSeq=($oDlc->DlcSeq+1);
        
$oDlc2->SearchByNextDlcID($nextSeq,$maxgroup,$oDlc->deptId); $oDlc2->GetRecord(); 
        
$nextDlcID=$oDlc2->DlcID;
        return 
$nextDlcID;
    }
}
function 
GetNextPsToByPass($DlcID,$deptId){
include_once(
"../../class/clsConnection.php");
include_once(
"../../class/clsDB.php");
include_once 
"../global.php";
include_once 
"../class/clsDepartment.php";
include_once 
"../class/clsPerson.php";
include_once 
"../class/clsDocLinePosition.php";
include_once 
"../class/clsDocLineConfig.php";
include_once 
"../class/clsReceiveSendType.php";
include_once 
"../class/clsDocType.php";
include_once 
"../class/clsDocuments.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);
$oUG = new umgroup($oCu);
$oDlc = new DocLineConfig($oC);
$oDlc2 = new DocLineConfig($oC);
$oDlc3 = new DocLineConfig($oC);
$oDlp = new docLinePosition($oC);
$oRSt = new receiveSendType($oC);
$oDt = new doctype($oC);
$oDoc = new Documents($oC);
$maxgroup=$oDP->SearchMaxDocGroup();

    
$oDlc->SearchByKey($DlcID); $oDlc->GetRecord(); 
    
$oDlp->SearchByKey($oDlc->DlpID); $oDlp->GetRecord();
    if(
$oDlp->DlpPID=="0"){
        
$nextSeq=($oDlc->DlcSeq+2);
        
$oDlc2->SearchByNextDlcID($nextSeq,$maxgroup,$oDlc->deptId); $oDlc2->GetRecord(); 

        if(
$oDlc2->DlcByPass=="N"){
            
$oDlc3->SearchByNextDlcID(($nextSeq+1),$maxgroup,$oDlc->deptId); $oDlc3->GetRecord(); 
            if(
$oDlc3->DlcByPass=="N"){
                
$nextDlcID="N";
            }else{
                
$nextDlcID="Y";
            }
        }else{
            
$nextDlcID="Y";
        }
        return 
$nextDlcID;
        
    }else{
        
$nextSeq=($oDlc->DlcSeq+1);
        
$oDlc2->SearchByNextDlcID($nextSeq,$maxgroup,$oDlc->deptId); $oDlc2->GetRecord(); 

        if(
$oDlc2->DlcSign=="N"){
            
$oDlc3->SearchByNextDlcID(($nextSeq+1),$maxgroup,$oDlc->deptId); $oDlc3->GetRecord(); 
            if(
$oDlc3->DlcByPass=="N"){
                
$nextDlcID="N";
            }else{
                
$nextDlcID="Y";
            }
        }else{
            
$nextDlcID="Y";
        }
        return 
$nextDlcID;
    }
}

function 
GetLineDoc($DocID,$DocGroup,$DsID,$DrsID){
include_once(
"../../class/clsConnection.php");
include_once(
"../../class/clsDB.php");
include_once 
"../global.php";
include_once 
"../class/clsDocReceiveSend.php";
include_once 
"getPrefix.php";

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

$oRs = new DocReceiveSend($oC);

    
$oRs->SearchByKey($DrsID);
    
$oRs->GetRecord();
    if(
$oRs->DrsFromDrsID!="0"){
        
$line=ShowLineDoc($oRs->DrsFromDrsID,$s);    
    }else{
        
$line=$oRs->DrsID;                
    }
    return 
$line;
}
function 
GetLineDoc2($DocGroup,$DrsID){
include_once(
"../../class/clsConnection.php");
include_once(
"../../class/clsDB.php");
include_once 
"../global.php";
include_once 
"../class/clsDocReceiveSend.php";
include_once 
"getPrefix.php";

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

$oRs = new DocReceiveSend($oC);


    
$oRs->SearchByDrsIDDocGroup($DrsID,$DocGroup);
    
$oRs->GetRecord();

    if(
$oRs->DrsFromDrsID!="0"){
        
$line=ShowLineDoc($oRs->DrsFromDrsID,$s);    
    }else{
        
$line=$oRs->DrsID;                
    }
    return 
$line;
}
function 
ShowLineDoc($DrsFromDrsID,$s){
include_once(
"../../class/clsConnection.php");
include_once(
"../../class/clsDB.php");
include_once 
"../global.php";
include_once 
"../class/clsDocReceiveSend.php";
include_once 
"getPrefix.php";

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

$oRs = new DocReceiveSend($oC);


    
$oRs->SearchByKey($DrsFromDrsID);
    
$oRs->GetRecord();
    
$s=$oRs->DrsID.",".$s;
    if(
$oRs->DrsFromDrsID!="0"){
            
$s=ShowLineDoc($oRs->DrsFromDrsID,$s);
    }
    return 
$s;
}

function 
GetNextPsAfterSign($DlcID,$deptId){
include_once(
"../../class/clsConnection.php");
include_once(
"../../class/clsDB.php");
include_once 
"../global.php";
include_once 
"../class/clsDepartment.php";
include_once 
"../class/clsPerson.php";
include_once 
"../class/clsDocLinePosition.php";
include_once 
"../class/clsDocLineConfig.php";
include_once 
"../class/clsReceiveSendType.php";
include_once 
"../class/clsDocType.php";
include_once 
"../class/clsDocuments.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);
$oUG = new umgroup($oCu);
$oDlc = new DocLineConfig($oC);
$oDlc2 = new DocLineConfig($oC);
$oDlc3 = new DocLineConfig($oC);
$oDlp = new docLinePosition($oC);
$oRSt = new receiveSendType($oC);
$oDt = new doctype($oC);
$oDoc = new Documents($oC);
$maxgroup=$oDP->SearchMaxDocGroup();

    
$oDlc->SearchByKey($DlcID); $oDlc->GetRecord(); 
    
$oDlp->SearchByKey($oDlc->DlpID); $oDlp->GetRecord();
    if(
$oDlp->DlpPID=="0"){
        
$nextSeq=($oDlc->DlcSeq-2);
        
$oDlc2->SearchByNextDlcID($nextSeq,$maxgroup,$oDlc->deptId); $oDlc2->GetRecord(); 

        if(
$oDlc2->DlcSend=="N"){
            
$oDlc3->SearchByNextDlcID(($nextSeq+1),$maxgroup,$oDlc->deptId); $oDlc3->GetRecord(); 
            if(
$oDlc3->DlcSend=="N"){
                
$nextDlcID="N";
            }else{
                
$nextDlcID=$oDlc3->DlcID;
            }
        }else{
            
$nextDlcID=$oDlc2->DlcID;
        }
        return 
$nextDlcID;
        
    }else{
        
$nextSeq=($oDlc->DlcSeq-3);
        
$oDlc2->SearchByNextDlcID($nextSeq,$maxgroup,$oDlc->deptId); $oDlc2->GetRecord(); 

        if(
$oDlc2->DlcSend=="N"){
            
$oDlc3->SearchByNextDlcID(($nextSeq+1),$maxgroup,$oDlc->deptId); $oDlc3->GetRecord(); 
            if(
$oDlc3->DlcSend=="N"){
                
$nextDlcID="N";
            }else{
                
$nextDlcID=$oDlc3->DlcID;
            }
        }else{
            
$nextDlcID=$oDlc2->DlcID;
        }
        return 
$nextDlcID;
    }
}
function 
ShowSendtoPs($deptId){
include_once(
"../../class/clsConnection.php");
include_once(
"../../class/clsDB.php");
include_once 
"../global.php";
include_once 
"../class/clsDocLineConfig.php";
include_once 
"../class/clsDepartment.php";
include_once 
"getPrefix.php";

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

$oDlc = new DocLineConfig($oC);
$oDlc2 = new DocLineConfig($oC);
$oDlc3 = new DocLineConfig($oC);
$oDP = new Department($oC);
$maxgroup=$oDP->SearchMaxDocGroup();

    
$oDlc3->SearchDlcID11($maxgroup,$deptId);
    if(
$oDlc3->GetRecord()==1){
        
$dlc_search=11;
        
$nextdlc_search=12;
    }else{
        
$dlc_search=5;
        
$nextdlc_search=6;
    }
    
    
$oDlc->SearchByDocGroupDlcID2($maxgroup,$deptId,$dlc_search);
    if(
$oDlc->GetRecord()=="1"){
        if(
$oDlc->DlcActive=="Y"){
                
$pssend=$oDlc->DlcID;
                return 
$pssend;
        }else{
            
$oDlc2->SearchByDocGroupDlcID($maxgroup,$deptId,$nextdlc_search);
            if(
$oDlc2->GetRecord()=="1"){
                if(
$oDlc2->DlcActive=="Y"){
                        
$pssend=$oDlc2->DlcID;
                        return 
$pssend;
                }else{
                    return 
"N";
                }
            }else{
                return 
"N";
            }
        }
    }else{
        
$oDlc2->SearchByDocGroupDlcID($maxgroup,$deptId,$nextdlc_search);
        if(
$oDlc2->GetRecord()=="1"){
            if(
$oDlc2->DlcActive=="Y"){
                    
$pssend=$oDlc2->DlcID;
                    return 
$pssend;
            }else{
                return 
"N";
            }
        }else{
            return 
"N";
        }
    }

}
function 
ShowSendtoPs2($deptId){
include_once(
"../../class/clsConnection.php");
include_once(
"../../class/clsDB.php");
include_once 
"../global.php";
include_once 
"../class/clsDocLineConfig.php";
include_once 
"../class/clsDepartment.php";
include_once 
"getPrefix.php";

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

$oDlc = new DocLineConfig($oC);
$oDlc2 = new DocLineConfig($oC);
$oDlc3 = new DocLineConfig($oC);
$oDP = new Department($oC);
$maxgroup=$oDP->SearchMaxDocGroup();

    
$oDlc->SearchByDocGroupDlcID2confirmY($maxgroup,$deptId,$dlc_search);
    if(
$oDlc->GetRecord()=="1"){
                    
$pssend=$oDlc->DlcID;
                    return 
$pssend;
    }

}
function 
GetUpPsSend($DlcID,$deptId){
include_once(
"../../class/clsConnection.php");
include_once(
"../../class/clsDB.php");
include_once 
"../global.php";
include_once 
"../class/clsDepartment.php";
include_once 
"../class/clsPerson.php";
include_once 
"../class/clsDocLinePosition.php";
include_once 
"../class/clsDocLineConfig.php";
include_once 
"../class/clsReceiveSendType.php";
include_once 
"../class/clsDocType.php";
include_once 
"../class/clsDocuments.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);
$oUG = new umgroup($oCu);
$oDlc = new DocLineConfig($oC);
$oDlc2 = new DocLineConfig($oC);
$oDlc3 = new DocLineConfig($oC);
$oDlp = new docLinePosition($oC);
$oRSt = new receiveSendType($oC);
$oDt = new doctype($oC);
$oDoc = new Documents($oC);
$maxgroup=$oDP->SearchMaxDocGroup();

    
$oDlc->SearchByKey($DlcID); $oDlc->GetRecord(); 
    
$oDlp->SearchByKey($oDlc->DlpID); $oDlp->GetRecord();
    if(
$oDlp->DlpPID=="0"){
        
$nextSeq=($oDlc->DlcSeq-2);
        
$oDlc2->SearchByNextDlcID($nextSeq,$maxgroup,$oDlc->deptId); $oDlc2->GetRecord(); 

        if(
$oDlc2->DlcSend=="N"){
            
$oDlc3->SearchByNextDlcID(($nextSeq+1),$maxgroup,$oDlc->deptId); $oDlc3->GetRecord(); 
            if(
$oDlc3->DlcSend=="N"){
                
$nextDlcID="N";
            }else{
                
$nextDlcID=$oDlc3->DlcID;
            }
        }else{
            
$nextDlcID=$oDlc2->DlcID;
        }
        return 
$nextDlcID;
        
    }else{
        
$nextSeq=($oDlc->DlcSeq-3);
        
$oDlc2->SearchByNextDlcID($nextSeq,$maxgroup,$oDlc->deptId); $oDlc2->GetRecord(); 

        if(
$oDlc2->DlcSend=="N"){
            
$oDlc3->SearchByNextDlcID(($nextSeq+1),$maxgroup,$oDlc->deptId); $oDlc3->GetRecord(); 
            if(
$oDlc3->DlcSend=="N"){
                
$nextDlcID="N";
            }else{
                
$nextDlcID=$oDlc3->DlcID;
            }
        }else{
            
$nextDlcID=$oDlc2->DlcID;
        }
        return 
$nextDlcID;
    }
}
function 
GetUpPrePsSend($DlcID,$deptId){
include_once(
"../../class/clsConnection.php");
include_once(
"../../class/clsDB.php");
include_once 
"../global.php";
include_once 
"../class/clsDepartment.php";
include_once 
"../class/clsPerson.php";
include_once 
"../class/clsDocLinePosition.php";
include_once 
"../class/clsDocLineConfig.php";
include_once 
"../class/clsReceiveSendType.php";
include_once 
"../class/clsDocType.php";
include_once 
"../class/clsDocuments.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);
//$oUG = new umgroup($oCu);
$oDlc = new DocLineConfig($oC);
$oDlc2 = new DocLineConfig($oC);
$oDlc3 = new DocLineConfig($oC);
$oDlp = new docLinePosition($oC);
$oRSt = new receiveSendType($oC);
$oDt = new doctype($oC);
$oDoc = new Documents($oC);
$maxgroup=$oDP->SearchMaxDocGroup();

    
$oDlc->SearchByKey($DlcID); $oDlc->GetRecord(); 
    
$oDlp->SearchByKey($oDlc->DlpID); $oDlp->GetRecord();
    if(
$oDlp->DlpPID=="0"){
        
$nextSeq=($oDlc->DlcSeq-2);
        
$oDlc2->SearchByNextDlcID($nextSeq,$maxgroup,$oDlc->deptId); $oDlc2->GetRecord(); 
        
$nextDlcID=$oDlc2->DlcID;
        return 
$nextDlcID;
        
    }else{
        
$nextSeq=($oDlc->DlcSeq-3);
        
$oDlc2->SearchByNextDlcID($nextSeq,$maxgroup,$oDlc->deptId); $oDlc2->GetRecord(); 
        
$nextDlcID=$oDlc2->DlcID;
        return 
$nextDlcID;
    }
}
function 
GetParentDoc($DocID){
    include_once(
"../../class/clsConnection.php");
    include_once(
"../../class/clsDB.php");
    include_once 
"../global.php";
    include_once 
"../class/clsDocuments.php";
    include_once 
"getPrefix.php";
    
    
$oC = new clsConnection($GLOBALS['DBHOST'], $GLOBALS['DBNAME_EOFFICE'], $GLOBALS['DBUSER_EOFFICE'], $GLOBALS['DBPASS_EOFFICE']);
    
    
$oDoc = new Documents($oC);
    
    
$oDoc->SearchByKey($DocID);
    
$oDoc->GetRecord();
    if(
$oDoc->DocPID!=0){
        
$a=GetParentDoc($oDoc->DocPID);
    }else{
        
$a=$oDoc->DocID;
        return 
$a;
    }
    return 
$oDoc->DocPID;
}
function 
UpdatereadDoc($DrsID,$DocID,$mobile_fn=""){
include_once(
"../../class/clsConnection.php");
include_once(
"../../class/clsDB.php");
include_once 
"../global.php";
include_once 
"../class/clsDocReceiveSend.php";
include_once 
"getPrefix.php";


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

$oRs = new DocReceiveSend($oC);
$oRs1 = new DocReceiveSend($oC);
$oRs2 = new DocReceiveSend($oC);

                    
$oRs->SearchByKey($DrsID);
                    
$oRs->GetRecord();
                    
$oRs->Edit();
                    
$oRs->DrsID=$oRs->DrsID;
                    
$oRs->DocID=$oRs->DocID;
                    
$oRs->DlcID=$oRs->DlcID;
                    
$oRs->DsID=4;
                    
$oRs->personId=$oRs->personId;
                    
$oRs->PtID=$oRs->PtID;
                    
$oRs->DrsDocTypeNo=$oRs->DrsDocTypeNo;
                    
$oRs->DrsReceiveDate=$oRs->DrsReceiveDate;
                    
$oRs->DrsReceivePersonId=$oRs->DrsReceivePersonId;
                    
$oRs->DrsSendDate=$oRs->DrsSendDate;
                    
$oRs->DrsSendPersonId=$oRs->DrsSendPersonId;
                    
$oRs->DrsSendDlcID=$oRs->DrsSendDlcID;
                    
$oRs->DrsDocDueDate=$oRs->DrsDocDueDate;
                    
$oRs->DrsDlcIDCreate=$oRs->DrsDlcIDCreate;
                    
$oRs->DrsPsIDCreate=$oRs->DrsPsIDCreate;
                    
$oRs->DrsPropose=$oRs->DrsPropose;
                    
$oRs->DrsSign=$oRs->DrsSign;
                    
$oRs->DrsFromDrsID=$oRs->DrsFromDrsID;
                    
$oRs->DocGroup=$oRs->DocGroup;
                    
$oRs->DrsflagRead=$oRs->DrsflagRead;
                    
$oRs->DrsByPass=$oRs->DrsByPass;
                    
$oRs->DrsSend=$oRs->DrsSend;
                    
$oRs->DrsSendToPs=$oRs->DrsSendToPs;
                    
$oRs->DrsDelete=$oRs->DrsDelete;
                    
$oRs->DrsMainPs=$oRs->DrsMainPs;
                    
$oRs->AnID=$oRs->AnID;
                    
$oRs->DrsDocReceiveDate=$oRs->DrsDocReceiveDate;
                    
$oRs->DocRefAnsDate=$oRs->DocRefAnsDate;
                    
$oRs->DrsSendDocNew=$oRs->DrsSendDocNew;
                    
$oRs->DrsInboxID=$oRs->DrsInboxID;
                    
$oRs->DrsstartDatePost=$oRs->DrsstartDatePost;
                    
$oRs->DrsendDatePost=$oRs->DrsendDatePost;
                    
$oRs->DrsSendBack=$oRs->DrsSendBack;             
                    
$oRs->DrsSendBackDlcID=$oRs->DrsSendBackDlcID;     
                    
$oRs->DrsfSendBack=$oRs->DrsfSendBack;     
                    
$oRs->Save();
                    if(
$mobile_fn!="Y"){ //เป็นฟังก์ชันจาก mobile
                    
?>
                        <script>
                        window.opener.location.href="showEntryDoc.php?DocID=<? echo $DocID?>&DrsID=<? echo $DrsID?>";
                        </script>
                    <?
                    
}
}
function 
searchDocSendToPs($DocID,$RsID){
include_once(
"../../class/clsConnection.php");
include_once(
"../../class/clsDB.php");
include_once 
"../global.php";
include_once 
"../class/clsDocReceiveSend.php";
include_once 
"../class/clsDocLinePosition.php";
include_once 
"../class/clsDocLineConfig.php";
include_once 
"../class/clsPerson.php";
include_once 
"../class/clsDepartment.php";
include_once 
"getPrefix.php";
include_once 
"../class/clsSendReceive.php";
include_once 
"../class/clsCollegeDetail.php";

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

$oRs = new DocReceiveSend($oC);
$oRs1 = new DocReceiveSend($oC);
$oRs2 = new DocReceiveSend($oC);
$oDlc = new DocLineConfig($oC);
$oDlp = new docLinePosition($oC);
$oPS = new person($oC);
$oDP = new Department($oC);
$oTsr = new sendreceive($oC);
$oCd = new collegedetail($oC);


    
$oRs->SearchByDocIDStatus3($DocID);
    if(
$oRs->GetRecord()==1){
        
//---send dept
        
$oRs1->SearchByDrsFromDrsID($oRs->DrsID);
        
$x=0;
        while(
$oRs1->GetRecord()){
            
$oDlc->SearchByKey($oRs1->DlcID); $oDlc->GetRecord();  
            
$oDP->SearchByKey($oDlc->deptId); $oDP->GetRecord();  
            
$oPS->SearchByKey($oRs1->DrsReceivePersonId); $oPS->GetRecord(); 
            if(
$x==0){ echo "<br><b>ผู้รับ ::</b><br>"; }
            if(
$oRs1->DrsReceivePersonId!='0'){
                echo 
"-&nbsp;".GetPrefix($oPS->prefixId).$oPS->fName."&nbsp;".$oPS->lName;
            }else{
                echo 
"สารบรรณย่อย";
            }
            if(
$oRs1->DrsSendToPs=="Y"){
                echo 
"&nbsp;[ส่งด่วน]";
            }
            echo 
"<br>"
            if(
$oRs1->personId==0){
                
//echo "&nbsp;&nbsp;".$oDlp->DlpName."<br>";
                
echo "&nbsp;&nbsp;".$oDP->deptName."<br>";
            }
        
$x++; }

        if(
$RsID=="2"){
            
//---send college
             
$y=0;
              
$oTsr->SearchDocSend($GLOBALS["COLLEGEID"],$DocID);   
              while(
$oTsr->GetRecord()){
                
$oCd->SearchByKey($oTsr->tsr_to_node);
                
$oCd->GetRecord();
                if(
$y==0){ echo "<br><b>ส่งถึงหน่วยงาน ::</b><br>"; }
                    echo 
"-&nbsp;".$oCd->collegeAbbr."<br>";
                
$y++;  }
         }

    }
}
function 
checkCountDoc($DocID){
    include_once(
"../../class/clsConnection.php");
    include_once(
"../../class/clsDB.php");
    include_once 
"../global.php";
    include_once 
"../class/clsDocattatches.php";
    include_once 
"getPrefix.php";
    
    
$oC = new clsConnection($GLOBALS['DBHOST'], $GLOBALS['DBNAME_EOFFICE'], $GLOBALS['DBUSER_EOFFICE'], $GLOBALS['DBPASS_EOFFICE']);
    
    
$oDatt = new Docattatches($oC);
    
$count=0;
    
$oDatt->SearchByDocID($DocID);
    while(
$oDatt->GetRecord()){
        
$count++;
    }

    return 
$count;
}

function 
searchDeptDlcID($DlcID){
    include_once(
"../../class/clsConnection.php");
    include_once(
"../../class/clsDB.php");
    include_once 
"../global.php";
    include_once 
"../class/clsDocLineConfig.php";
    include_once 
"getPrefix.php";
    
    
$oC = new clsConnection($GLOBALS['DBHOST'], $GLOBALS['DBNAME_EOFFICE'], $GLOBALS['DBUSER_EOFFICE'], $GLOBALS['DBPASS_EOFFICE']);
    
$oDP = new Department($oC);
    
$oDlc = new docLineConfig($oC);

    return 
$oDP->SearchDeptName($oDlc->SearchByKeyName($DlcID,'deptId'));
}
function 
updateAnIDdocumentDocPID0($DocID,$AnID){
include_once(
"../../class/clsConnection.php");
include_once(
"../../class/clsDB.php");
include_once 
"../global.php";
include_once 
"../class/clsDocuments.php";
include_once 
"../class/clsDocReceiveSend.php";
include_once 
"getPrefix.php";

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

$oDoc = new Documents($oC);
$oRs = new DocReceiveSend($oC);

                
$oDoc->SearchByKey($DocID);
                
$oDoc->GetRecord();
                
$oDoc->Edit();
                
$oDoc->AnID=$AnID;
                
$oDoc->Save();
                
                    
$oRs->SearchByDocID($DocID);
                    while(
$oRs->GetRecord()){
                        
$oRs->Edit();
                        
$oRs->AnID=$AnID;
                        
$oRs->Save();
                    }
}
function 
updateAnIDdocumentDocPID($DocID,$AnID){
include_once(
"../../class/clsConnection.php");
include_once(
"../../class/clsDB.php");
include_once 
"../global.php";
include_once 
"../class/clsDocuments.php";
include_once 
"../class/clsDocReceiveSend.php";
include_once 
"getPrefix.php";

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

$oDoc = new Documents($oC);
$oRs = new DocReceiveSend($oC);

    
$oDoc->SearchByDocPID($DocID);
    while(
$oDoc->GetRecord()){
        
//echo '----'.$oDoc->DocID.'<br>';
                
$oDoc->Edit();
                
$oDoc->AnID=$AnID;
                
$oDoc->Save();
                
                    
$oRs->SearchByDocID($oDoc->DocID);
                    while(
$oRs->GetRecord()){
                        
$oRs->Edit();
                        
$oRs->AnID=$AnID;
                        
$oRs->Save();
                    }
    }
}
function 
updateDocGetPostdocumentDocPID0($DocID,$DocGetPost){
include_once(
"../../class/clsConnection.php");
include_once(
"../../class/clsDB.php");
include_once 
"../global.php";
include_once 
"../class/clsDocuments.php";
include_once 
"../class/clsDocReceiveSend.php";
include_once 
"getPrefix.php";

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

$oDoc = new Documents($oC);

                
$oDoc->SearchByKey($DocID);
                
$oDoc->GetRecord();
                
$oDoc->Edit();
                
$oDoc->DocGetPost=$DocGetPost;
                
$oDoc->Save();
}
function 
updateDocDateGetPostdocumentDocPID0($DocID,$DocDateGetPost){
include_once(
"../../class/clsConnection.php");
include_once(
"../../class/clsDB.php");
include_once 
"../global.php";
include_once 
"../class/clsDocuments.php";
include_once 
"../class/clsDocReceiveSend.php";
include_once 
"getPrefix.php";

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

$oDoc = new Documents($oC);

                
$oDoc->SearchByKey($DocID);
                
$oDoc->GetRecord();
                
$oDoc->Edit();
                
$oDoc->DocDateGetPost=$DocDateGetPost;
                
$oDoc->Save();
}
function 
updateDocShowInOutdocumentDocPID0($DocID,$DocShowInOut){
include_once(
"../../class/clsConnection.php");
include_once(
"../../class/clsDB.php");
include_once 
"../global.php";
include_once 
"../class/clsDocuments.php";
include_once 
"../class/clsDocReceiveSend.php";
include_once 
"getPrefix.php";

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

$oDoc = new Documents($oC);

                
$oDoc->SearchByKey($DocID);
                
$oDoc->GetRecord();
                
$oDoc->Edit();
                
$oDoc->DocShowInOut=$DocShowInOut;
                
$oDoc->Save();
}
function 
updateDocShowInOutdocumentDocPID($DocID,$DocShowInOut){
include_once(
"../../class/clsConnection.php");
include_once(
"../../class/clsDB.php");
include_once 
"../global.php";
include_once 
"../class/clsDocuments.php";
include_once 
"../class/clsDocReceiveSend.php";
include_once 
"getPrefix.php";

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

$oDoc = new Documents($oC);
$oRs = new DocReceiveSend($oC);

    
$oDoc->SearchByDocPID($DocID);
    while(
$oDoc->GetRecord()){
                
$oDoc->Edit();
                
$oDoc->DocShowInOut=$DocShowInOut;
                
$oDoc->Save();
    }
}
function 
abbreDate2forCheck($date) {
    include_once 
"../link/keyThai.php";
    list(
$yy$mm$dd) = preg_split('[-]',$date);
    
    if(
$dd=='01') { $dd='1'; }
    else if(
$dd=='02') { $dd='2'; }
    else if(
$dd=='03') { $dd='3'; }
    else if(
$dd=='04') { $dd='4'; }
    else if(
$dd=='05') { $dd='5'; }
    else if(
$dd=='06') { $dd='6'; }
    else if(
$dd=='07') { $dd='7'; }
    else if(
$dd=='08') { $dd='8'; }
    else if(
$dd=='09') { $dd='9'; }
    
    if(
$mm=='01') { $mm='ม.ค.'; }
    else if(
$mm=='02') { $mm='ก.พ.'; }
    else if(
$mm=='03') { $mm='มี.ค.'; }
    else if(
$mm=='04') { $mm='เม.ย.'; }
    else if(
$mm=='05') { $mm='พ.ค.'; }
    else if(
$mm=='06') { $mm='มิ.ย.'; }
    else if(
$mm=='07') { $mm='ก.ค.'; }
    else if(
$mm=='08') { $mm='ส.ค.'; }
    else if(
$mm=='09') { $mm='ก.ย.'; }
    else if(
$mm=='10') { $mm='ต.ค.'; }
    else if(
$mm=='11') { $mm='พ.ย.'; }
    else if(
$mm=='12') { $mm='ธ.ค.'; }
    
    return 
a2th($dd)." ".$mm." ".a2th($yy);
}
function 
showsteplinedoc($searchDoc,$tab){
include_once(
"../../class/clsConnection.php");
include_once(
"../../class/clsDB.php");
include_once 
"../global.php";
include_once 
"../class/clsDocuments.php";
include_once 
"../class/clsDocReceiveSend.php";
include_once 
"../class/clsDocLineConfig.php";
include_once 
"../class/clsDocLinePosition.php";
include_once 
"../class/clsPerson.php";
include_once 
"../class/clsDepartment.php";
//include_once "../link/function.php";
include_once "getPrefix.php";

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

$oDoc = new Documents($oC);
$oRs = new DocReceiveSend($oC);
$oRs1 = new DocReceiveSend($oC);
$oRs2 = new DocReceiveSend($oC);
$oRs3 = new DocReceiveSend($oC);
$oRs4 = new DocReceiveSend($oC);
$oRs5 = new DocReceiveSend($oC);
$oDlc = new DocLineConfig($oC);
$oDlp = new docLinePosition($oC);
$oPS = new person($oC);
$oPS2 = new person($oC);
$oDlc1 = new DocLineConfig($oC);
$oDlp1 = new docLinePosition($oC);
$oPS1 = new person($oC);
$oPS2 = new person($oC);
$oDP = new Department($oC);
$oDP1 = new Department($oC);

echo 
"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=tis-620\">";
if(
$tab!=""){
$tab="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".$tab;
}else{
$tab="&nbsp;&nbsp;";
}
?>
<table border="0" align="center" width="98%" >
<?
$oRs
->SearchByDocIDDsID3($searchDoc);
if(
$oRs->GetRecord()=="1"){
$oDlc->SearchByKey($oRs->DlcID);  
$oDlc->GetRecord();    
$oDlp->SearchByKey($oDlc->DlpID);  
$oDlp->GetRecord();
$oPS->SearchByKey($oRs->DrsReceivePersonId); 
$oPS->GetRecord();  

$oRs5->SearchByDocIDDsID0($searchDoc);
$oRs5->GetRecord();

echo 
"<tr><td>";
if(
$tab=="&nbsp;&nbsp;"){                            
echo 
"<img src=\"../picture/reg.png\" title=\"\"  border=\"0\" >"//$oRs->DocID;
echo "&nbsp;<strong>".$oDlp->DlpName."&nbsp;".$oDP->SearchDeptName($oDlc->deptId)."&nbsp;</strong>&nbsp;<font color=\"#000099\">".GetPrefix($oPS->prefixId).$oPS->fName."&nbsp;".$oPS->lName."</font>&nbsp;";
list(
$DocD,$DocT) = preg_split('[ ]',$oRs->DrsSendDate); 
if(
$oRs->DrsSendDate!="0000-00-00 00:00:00"){  if($oRs->DrsSendEndDoc=="Y"){  echo "[วันที่ยุติหนังสือ"; }else{ echo "[วันที่ส่ง"; } echo "::&nbsp;".abbreDate2forCheck($DocD,'/')."&nbsp;".a2th($DocT)."]"; }  echo "<br>";
}
    
$oRs2->SearchByDrsFromDrsIDcaseps($oRs->DrsID);
    while(
$oRs2->GetRecord()){
            
$oPS2->SearchByKey($oRs2->personId);    
            
$oPS2->GetRecord();
            
            echo 
$tab."<img src=\"../picture/linesub.gif\" title=\"\"  border=\"0\" ><font color=\"#000099\">";  //$oRs2->personId;
            
echo "&nbsp;".GetPrefix($oPS2->prefixId).$oPS2->fName."&nbsp;".$oPS2->lName."</font>&nbsp;";
            if(
$oRs2->DrsMainPs=='Y'){
                echo 
"[ผู้รับผิดชอบหลัก]";
            }            
            if(
$oRs2->DrsSendToPs=='Y'){
                
$oDP->SearchByKey($oPS2->deptId);
                
$oDP->GetRecord();
                echo 
"<font color=\"#FF0000\">(".$oDP->deptName." : ส่งด่วน)</font>";
            }
            if(
$oRs2->DrsSendDocNew!="0000-00-00 00:00:00"){
                list(
$DocD2,$DocT2) = preg_split('[ ]',$oRs2->DrsSendDocNew); 
                echo 
"[ส่งเพิ่มเติม ".abbreDate2forCheck($DocD2,'/')."&nbsp;".a2th($DocT2)."]";
            }
            if(
$oRs2->DsID=="4" && $oRs2->DrsDocReceiveDate=="0000-00-00 00:00:00"){
                echo 
"[เปิดหนังสือ]";
            }else if(
$oRs2->DsID=="5" && $oRs2->DrsDocReceiveDate=="0000-00-00 00:00:00"){
                echo 
"[เปิดแฟ้มหนังสือ]";
            }else if(
$oRs2->DsID=="5" && $oRs2->DrsDocReceiveDate!="0000-00-00 00:00:00"){
                list(
$DocD2,$DocT2) = preg_split('[ ]',$oRs2->DrsDocReceiveDate); 
                echo 
"[วันที่รับทราบ::&nbsp;".abbreDate2forCheck($DocD2,'/')."&nbsp;".a2th($DocT2)."]";
            }
            if(
$oRs2->DrsDelete=='Y'){  echo '[ลบหนังสือ]'; }
            if(
$oRs2->DrsDeleteAdmin=='Y'){  echo '[ลบหนังสือกรณีพิเศษ]'; }
            if(
$oRs2->DsID=="7" && $oRs2->DrsDocReceiveDate!="0000-00-00 00:00:00"){
                list(
$DocD2,$DocT2) = preg_split('[ ]',$oRs2->DrsDocReceiveDate); 
                echo 
"[วันที่แจ้งการส่งผิด::&nbsp;".abbreDate2forCheck($DocD2,'/')."&nbsp;".a2th($DocT2)." ส่งกลับ:: ".searchDlcIDPsDept($oRs2->DrsSendBackDlcID)."]";
            }
            
            if(
$oRs2->DrsMainPs=='Y'){
                    list(
$DocD3,$DocT3) = preg_split('[ ]',$oRs5->DrsDocDueDate); 
                    if(
$oRs2->DocRefAnsDate!="0000-00-00 00:00:00"){ 
                                list(
$DocD2,$DocT2) = preg_split('[ ]',$oRs2->DocRefAnsDate); 
                                if(
$DocD2>$oRs5->DrsDocDueDate){  
                                        
$resultshow='หลังเวลากำหนด '.abbreDate2forCheck($DocD2,'/');
                                }else if(
$DocD2==$oRs5->DrsDocDueDate){ 
                                        
$resultshow='ตามเวลากำหนด '.abbreDate2forCheck($DocD2,'/');
                                }else{  
                                        
$resultshow='ก่อนเวลากำหนด '.abbreDate2forCheck($DocD2,'/');
                                }
                    }else{    
                                
$resultshow="ยังไม่ดำเนินการ";
                    } 
                    echo 
"<br>".$tab."&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color=#330000><strong>ระยะเวลาดำเนินการ ::</strong></font>  ".abbreDate2forCheck($DocD3,'/')."&nbsp;".a2th($DocT3);
                    echo 
"<br>".$tab."&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color=#330000><strong>สถานะการดำเนินงาน ::</strong></font>  ".$resultshow;
            }
            echo 
"<br>";
    }
    
    
$oRs1->SearchByDrsFromDrsIDcasedept($oRs->DrsID);
    while(
$oRs1->GetRecord()){

            
$oDlc1->SearchByKey($oRs1->DlcID);  
            
$oDlc1->GetRecord();    
            
$oDlp1->SearchByKey($oDlc1->DlpID);  
            
$oDlp1->GetRecord();
            
$oPS1->SearchByKey($oRs1->DrsReceivePersonId);  
            
$oPS1->GetRecord();
            
            echo 
$tab."<img src=\"../picture/linesub.gif\" title=\"\"  border=\"0\" ><img src=\"../picture/reg.png\" title=\"\"  border=\"0\" ><strong>"//echo $oRs1->DocID;
            
echo "&nbsp;".$oDlp1->DlpName."&nbsp;".$oDP1->SearchDeptName($oDlc1->deptId)."</strong>";
            if(
$oRs1->DrsSendDocNew!="0000-00-00 00:00:00"){
                list(
$DocD2,$DocT2) = preg_split('[ ]',$oRs1->DrsSendDocNew); 
                echo 
"&nbsp;[ส่งเพิ่มเติม ".abbreDate2forCheck($DocD2,'/')."&nbsp;".a2th($DocT2)."]&nbsp;";
            }
            if(
$oRs1->DrsMainDept=='Y'){  echo ' [หน่วยงานรับผิดชอบหลัก]'; }
            if(
$oRs1->DrsReceivePersonId!='0'){
                
$psreceive=$oRs1->DrsReceivePersonId;
                echo 
"&nbsp;<strong>::</strong>&nbsp;<font color=\"#000099\">".GetPrefix($oPS1->prefixId).$oPS1->fName."&nbsp;".$oPS1->lName."</font>&nbsp;";
                
            }
            
$oRs3->SearchByDrsFromDrsID($oRs1->DrsID);
            
$oRs3->GetRecord();
            if(
$oRs3->DsID=="1" || $oRs3->DsID=="6" || $oRs3->DsID=="7"){
                list(
$DocD1,$DocT1) = preg_split('[ ]',$oRs3->DrsReceiveDate); 
                echo 
"["; if($oRs3->DsID=="1"){  echo "วันที่ลงรับ"; }else if($oRs3->DsID=="6"){  echo "วันที่ไม่ลงรับ";  }else if($oRs3->DsID=="7"){  echo "วันที่แจ้งการส่งผิด";  }  echo "::&nbsp;".abbreDate2forCheck($DocD1,'/')."&nbsp;".a2th($DocT1);
                if(
$oRs3->DsID=="7"){  echo " ส่งกลับ:: ".searchDlcIDPsDept($oRs3->DrsSendBackDlcID); }
                echo 
"]";
            }
            
$oRs4->SearchByDocIDDsID3($oRs1->DocID);
            if(
$oRs4->GetRecord()=="1"){
                if(
$oRs4->DrsSendDate!="0000-00-00 00:00:00"){
                    
$pstosend=$oRs4->DrsPsIDCreate;
                    if((
$pstosend!=$psreceive) && $pstosend!='' && $pstosend!='0'){
                        
                        
$oPS2->SearchByKey($pstosend);  
                        
$oPS2->GetRecord();
                        echo 
"&nbsp;<font color=\"#000099\">".GetPrefix($oPS2->prefixId).$oPS2->fName."&nbsp;".$oPS2->lName."</font>&nbsp;";
                    }
                    list(
$DocD3,$DocT3) = preg_split('[ ]',$oRs4->DrsSendDate); 
                    if(
$oRs4->DrsSendEndDoc=="Y"){  echo "[วันที่ยุติหนังสือ"; }else{ echo "[วันที่ส่ง"; } 
                    echo 
"::&nbsp;".abbreDate2forCheck($DocD3,'/')."&nbsp;".a2th($DocT3)."]";
                }
            }
            
            echo 
"<br>";
            
showsteplinedoc($oRs1->DocID,$tab);
    }
    
    
    
    
    
    
echo 
"</td></tr>";    
}
?>
</table>
<?
}
function 
searchDepRef($deptId){
include_once(
"../../class/clsConnection.php");
include_once(
"../../class/clsDB.php");
include_once 
"../global.php";
include_once 
"../class/clsDepartment.php";
include_once 
"../link/function.php";
include_once 
"getPrefix.php";
include_once 
"../class/clsdeptref.php";

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

$oDP = new Department($oC);
$oDP1 = new Department($oC);
$oDr= new deptref($oC);
$oDr2= new deptref($oC);


$oDP->SearchByKey($deptId);
$oDP->GetRecord();
    
    
$oDP1->searchMaxDate($oDP->deptDate);  $oDP1->GetRecord(); 
    echo 
$str="<option value=".$oDP->deptId.">".$oDP->deptName."&nbsp;&nbsp;[".abbreDate2($oDP->deptDate,'/')."&nbsp;-&nbsp;".abbreDate2($oDP1->deptDate,'/')."]</option>";
    
$checkcountdeptref=$oDr2->searchcountBydeptId($oDP->deptId);
                        
    if(
$checkcountdeptref!="0"){  
                                
$oDr->searchBydeptId($oDP->deptId);
                                while(
$oDr->GetRecord()){
                                        
searchDepRef($oDr->deptrefId);  
                                }
    }
}

function 
UpdateDocSign($DlcID){
include_once(
"../../class/clsConnection.php");
include_once(
"../../class/clsDB.php");
include_once 
"../global.php";
include_once 
"../class/clsDepartment.php";
include_once 
"../class/clsPerson.php";
include_once 
"../class/clsDocLinePosition.php";
include_once 
"../class/clsDocLineConfig.php";
include_once 
"../class/clsReceiveSendType.php";
include_once 
"../class/clsDocType.php";
include_once 
"../class/clsDocuments.php";
include_once 
"../class/clsDocReceiveSend.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);
$oUG = new umgroup($oCu);
$oDlc = new DocLineConfig($oC);
$oDlc2 = new DocLineConfig($oC);
$oDlc3 = new DocLineConfig($oC);
$oDlp = new docLinePosition($oC);
$oRSt = new receiveSendType($oC);
$oDt = new doctype($oC);
$oDoc = new Documents($oC);
$oRs = new DocReceiveSend($oC);
$oRs2 = new DocReceiveSend($oC);
$oRs1 = new DocReceiveSend($oC);
$maxgroup=$oDP->SearchMaxDocGroup();

    
$oDlc->SearchByKey($DlcID); $oDlc->GetRecord(); 
    
$oDlp->SearchByKey($oDlc->DlpID); $oDlp->GetRecord();
    if(
$oDlp->DlpPID=="0"){
        
$nextSeq=($oDlc->DlcSeq+1);
    }else{
        
$nextSeq=($oDlc->DlcSeq-1);
    }
    
    
$oDlc2->SearchByNextDlcID($nextSeq,$maxgroup,$oDlc->deptId); $oDlc2->GetRecord();
    
$DlcID2=$oDlc2->DlcID;

    
$numcount=0;
    if(
$oDlp->DlpPID=="0"){
        
$numcount=$oRs2->SearchCountPreDocSign($DlcID,$DlcID2,$maxgroup);
    }else{
        
$numcount=$oRs2->SearchCountPreDocSignforDlpID0($DlcID,$DlcID2,$maxgroup);
    }
    if(
$numcount>0){

            
$flagCommit true;
            
$checkflagCommittrue;
                
            if(
$oDlp->DlpPID=="0"){
                
$flagCommit $oRs->SearchPreDocSign_Update($DlcID,$DlcID2,$maxgroup,$oDlc->personId);
                              
$oRs1->SearchPreDocSign($DlcID,$DlcID2,$maxgroup);
                               while(
$oRs1->GetRecord()){
                                       
$checkflagCommit $oRs2->SearchPreDocSign_Update2($DlcID,$oDlc->personId,$oRs1->DrsFromDrsID);
                                       if(!
$checkflagCommit){ $flagCommit=$checkflagCommit;   }
                               }
            }else{
                
$flagCommit $oRs->SearchPreDocSignforDlpID0_Update($DlcID,$DlcID2,$maxgroup,$oDlc->personId);
                              
$oRs1->SearchPreDocSignforDlpID0($DlcID,$DlcID2,$maxgroup);
                               while(
$oRs1->GetRecord()){
                                       
$checkflagCommit $oRs2->SearchPreDocSignforDlpID0_Update2($DlcID,$oDlc->personId,$oRs1->DrsFromDrsID);
                                       if(!
$checkflagCommit){ $flagCommit=$checkflagCommit;   }
                               }
            }
            
                if(
$flagCommit)
                    
$oC->CommitTrans();
                else
                    
$oC->RollbackTrans();
        
    }
}
function 
UpdateDocSend($DlcID,$DlcActive){
    if(
$DlcActive=='Y'){
        include_once(
"../../class/clsConnection.php");
        include_once(
"../../class/clsDB.php");
        include_once 
"../global.php";
        include_once 
"../class/clsDepartment.php";
        include_once 
"../class/clsPerson.php";
        include_once 
"../class/clsDocLinePosition.php";
        include_once 
"../class/clsDocLineConfig.php";
        include_once 
"../class/clsReceiveSendType.php";
        include_once 
"../class/clsDocType.php";
        include_once 
"../class/clsDocuments.php";
        include_once 
"../class/clsDocReceiveSend.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);
        
$oDlc = new DocLineConfig($oC);
        
$oDlc2 = new DocLineConfig($oC);
        
$oDlc3 = new DocLineConfig($oC);
        
$oDlp = new docLinePosition($oC);
        
$oRSt = new receiveSendType($oC);
        
$oDt = new doctype($oC);
        
$oDoc = new Documents($oC);
        
$oDoc2 = new Documents($oC);
        
$oDoc3 = new Documents($oC);
        
$oRs = new DocReceiveSend($oC);
        
$oRs1 = new DocReceiveSend($oC);
        
$oRs2 = new DocReceiveSend($oC);
        
$oRs3 = new DocReceiveSend($oC);
        
$maxgroup=$oDP->SearchMaxDocGroup();
        
            
$oDlc->SearchByKey($DlcID); $oDlc->GetRecord();
            
$oDlp->SearchByKey($oDlc->DlpID); $oDlp->GetRecord();
            if(
$oDlp->DlpPID=="0"){
                
$nextSeq=($oDlc->DlcSeq+1);
            }else{
                
$nextSeq=($oDlc->DlcSeq-1);
            }
            
            
$oDlc->SearchByKey($DlcID); $oDlc->GetRecord(); 
            
$oDlp->SearchByKey($oDlc->DlpID); $oDlp->GetRecord();
            if(
$oDlp->DlpPID=="0"){
                
$nextSeq=($oDlc->DlcSeq+1);
            }else{
                
$nextSeq=($oDlc->DlcSeq-1);
            }            
            
            
$oDlc2->SearchByNextDlcID($nextSeq,$maxgroup,$oDlc->deptId); $oDlc2->GetRecord();
            
$DlcID2=$oDlc2->DlcID;
        
            
$numcount=0;
            
$numcount=$oRs3->SearchCountPreDocSend($DlcID,$DlcID2,$maxgroup);
            
            if(
$numcount>0){
                
$flagCommit true;
                
$checkflagCommittrue;
                
$flagCommit $oRs->SearchPreDocSend_Update($DlcID,$DlcID2,$maxgroup,$oDlc->personId);
                
                              
$oRs1->SearchPreDocSend($DlcID,$DlcID2,$maxgroup);
                              while(
$oRs1->GetRecord()){
                                       
$checkflagCommit $oRs2->SearchPreDocSend_Update2($DlcID,$oDlc->personId,$oRs1->DrsFromDrsID);
                                    if(!
$checkflagCommit){ $flagCommit=$checkflagCommit;   }
                              }
                              
                              
                if(
$flagCommit)
                    
$oC->CommitTrans();
                else
                    
$oC->RollbackTrans();
            }
            
            
    } 
//DlcActive=='Y'
}
function 
UpdateDocReceive($DlcID,$DlcActive){
    if(
$DlcActive=='Y'){
        include_once(
"../../class/clsConnection.php");
        include_once(
"../../class/clsDB.php");
        include_once 
"../global.php";
        include_once 
"../class/clsDepartment.php";
        include_once 
"../class/clsPerson.php";
        include_once 
"../class/clsDocLinePosition.php";
        include_once 
"../class/clsDocLineConfig.php";
        include_once 
"../class/clsReceiveSendType.php";
        include_once 
"../class/clsDocType.php";
        include_once 
"../class/clsDocuments.php";
        include_once 
"../class/clsDocReceiveSend.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);
        
$oDlc = new DocLineConfig($oC);
        
$oDlc2 = new DocLineConfig($oC);
        
$oDlc3 = new DocLineConfig($oC);
        
$oDlp = new docLinePosition($oC);
        
$oRSt = new receiveSendType($oC);
        
$oDt = new doctype($oC);
        
$oDoc = new Documents($oC);
        
$oDoc2 = new Documents($oC);
        
$oDoc3 = new Documents($oC);
        
$oRs = new DocReceiveSend($oC);
        
$oRs1 = new DocReceiveSend($oC);
        
$oRs2 = new DocReceiveSend($oC);
        
$maxgroup=$oDP->SearchMaxDocGroup();
        
            
$oDlc->SearchByKey($DlcID); $oDlc->GetRecord();
            
$oDlp->SearchByKey($oDlc->DlpID); $oDlp->GetRecord();
            if(
$oDlp->DlpPID=="0"){
                
$nextSeq=($oDlc->DlcSeq+1);
            }else{
                
$nextSeq=($oDlc->DlcSeq-1);
            }
            
            
$oDlc2->SearchByNextDlcID($nextSeq,$maxgroup,$oDlc->deptId); $oDlc2->GetRecord();
            
$DlcID2=$oDlc2->DlcID;
        
            
$numcount=0;
            
$numcount=$oDoc2->SearchCountDocReceive($DlcID,$DlcID2,$maxgroup);
            if(
$numcount>0){
                
$flagCommit true;
                
$checkflagCommittrue;
                
$flagCommit $oDoc->SearchByDlcIDDocGroupDlcID2DsID0DrsSendDate_Update($DlcID,$DlcID2,$maxgroup);
                              
$oDoc3->SearchByDlcIDDocGroupDlcID2DsID0DrsSendDateDocID($DlcID,$DlcID2,$maxgroup);
                              while(
$oDoc3->GetRecord()){        
                                    
$checkflagCommit $oRs2->SearchPreDocReceive_Update($DlcID,$DlcID2,$maxgroup,$oDoc3->DocID,$oDlc->personId);
                                    if(!
$checkflagCommit){ $flagCommit=$checkflagCommit;   }
                              }
                              
                if(
$flagCommit)
                    
$oC->CommitTrans();
                else
                    
$oC->RollbackTrans();
            }
            
    } 
//DlcActive=='Y'
}
function 
SearchdeptIdlevel0($deptId){
include_once(
"../../class/clsConnection.php");
include_once(
"../../class/clsDB.php");
include_once 
"../global.php";
include_once 
"../class/clsDepartment.php";
include_once 
"getPrefix.php";

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

$oDP3 = new Department($oC);

$oDP3->SearchByKey($deptId);
$oDP3->GetRecord();

if(
$oDP3->deptLevel!=0){
    return 
SearchdeptIdlevel0($oDP3->deptParentId);
}else{
    return 
$oDP3->deptId;
}
}
function 
GetDrsReadDoc($DocID){
include_once(
"../../class/clsConnection.php");
include_once(
"../../class/clsDB.php");
include_once 
"../global.php";
include_once 
"../class/clsDocuments.php";
include_once 
"../class/clsDocattatches.php";
include_once 
"getPrefix.php";

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

$oDoc3 = new Documents($oC);
$oDatt2 = new Docattatches($oC);

                    
$oDoc3->SearchByKey($DocID);
                    
$oDoc3->GetRecord();
                    
//---set DrsReadDoc
                    
if($oDoc3->DocPID=="0" || $oDoc3->DocPID==""){  $searchDocRead=$oDoc3->DocID; }else{ $searchDocRead=$oDoc3->DocPID; }
                    
$countdocread=$oDatt2->CountDocByDocID($searchDocRead);
                    
                    for(
$i=1;$i<=$countdocread;$i++){
                        
$writeReadDoc=$writeReadDoc.'0';
                    } 
return 
$writeReadDoc;
}
function 
GetDrsReadDocSet1($DocID){
include_once(
"../../class/clsConnection.php");
include_once(
"../../class/clsDB.php");
include_once 
"../global.php";
include_once 
"../class/clsDocuments.php";
include_once 
"../class/clsDocattatches.php";
include_once 
"getPrefix.php";

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

$oDoc3 = new Documents($oC);
$oDatt2 = new Docattatches($oC);

                    
$oDoc3->SearchByKey($DocID);
                    
$oDoc3->GetRecord();
                    
//---set DrsReadDoc
                    
if($oDoc3->DocPID=="0" || $oDoc3->DocPID==""){  $searchDocRead=$oDoc3->DocID; }else{ $searchDocRead=$oDoc3->DocPID; }
                    
$countdocread=$oDatt2->CountDocByDocID($searchDocRead);
                    
                    for(
$i=1;$i<=$countdocread;$i++){
                        
$writeReadDoc=$writeReadDoc.'1';
                    } 
return 
$writeReadDoc;
}
function 
GetStatusReadDoc($DrsReadDoc,$DaSeq){
include_once(
"../../class/clsConnection.php");
include_once(
"../../class/clsDB.php");
include_once 
"../global.php";
include_once 
"../class/clsDocuments.php";
include_once 
"../class/clsDocattatches.php";
include_once 
"getPrefix.php";

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

$oDoc3 = new Documents($oC);
$oDatt2 = new Docattatches($oC);

                    
$string $DrsReadDoc;
return 
$string{$DaSeq-1};

}
function 
showsteplinedoc2($searchDoc,$tab){
include_once(
"../../class/clsConnection.php");
include_once(
"../../class/clsDB.php");
include_once 
"../global.php";
include_once 
"../class/clsDocuments.php";
include_once 
"../class/clsDocReceiveSend.php";
include_once 
"../class/clsDocLineConfig.php";
include_once 
"../class/clsDocLinePosition.php";
include_once 
"../class/clsPerson.php";
include_once 
"../class/clsDepartment.php";
include_once 
"../link/function.php";
include_once 
"getPrefix.php";

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

$oDoc = new Documents($oC);
$oRs = new DocReceiveSend($oC);
$oRs1 = new DocReceiveSend($oC);
$oRs2 = new DocReceiveSend($oC);
$oRs3 = new DocReceiveSend($oC);
$oRs4 = new DocReceiveSend($oC);
$oRs5 = new DocReceiveSend($oC);
$oDlc = new DocLineConfig($oC);
$oDlp = new docLinePosition($oC);
$oPS = new person($oC);
$oDlc1 = new DocLineConfig($oC);
$oDlp1 = new docLinePosition($oC);
$oPS1 = new person($oC);
$oPS2 = new person($oC);
$oDP = new Department($oC);
$oDP1 = new Department($oC);
if(
$tab!=""){
        
$tab="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".$tab;
}else{
        
$tab="&nbsp;&nbsp;";
}
$oDoc->SearchByKey($searchDoc); $oDoc->GetRecord(); 

?>
<table border="0" align="center" width="98%" >
<?

echo '</td></tr>';
$oRs->SearchByDocIDDsID3($searchDoc);
if(
$oRs->GetRecord()=="1"){

    
$oDlc->SearchByKey($oRs->DlcID);  
    
$oDlc->GetRecord();    
    
$oDlp->SearchByKey($oDlc->DlpID);  
    
$oDlp->GetRecord();
    
$oPS->SearchByKey($oRs->DrsReceivePersonId); 
    
$oPS->GetRecord();  


        echo 
"<tr><td>";
        if(
$tab=="&nbsp;&nbsp;"){                            
                echo 
"<img src=\"../picture/reg.png\" title=\"\"  border=\"0\" >"
                echo 
"&nbsp;<strong>".$oDlp->DlpName."&nbsp;".$oDP->SearchDeptName($oDlc->deptId)."&nbsp;::</strong>&nbsp;<font color=\"#000099\">".GetPrefix($oPS->prefixId).$oPS->fName."&nbsp;".$oPS->lName."</font>&nbsp;";
                list(
$DocD,$DocT) = preg_split('[ ]',$oRs->DrsSendDate); 
                echo 
'<br>';
                
showSignSendDoc($oRs->DocID);
        }
        
$i=0;
        
$oRs2->SearchByDrsFromDrsIDcaseps($oRs->DrsID);
        
$countrowps=$oRs2->NumRow();
        while(
$oRs2->GetRecord()){
                
$oPS2->SearchByKey($oRs2->personId);    
                
$oPS2->GetRecord();
                if(
$i==0){
                    echo 
$tab."<img src=\"../picture/linesub.gif\" title=\"\"  border=\"0\" >";
                }else{
                    echo 
',';
                }
                echo 
"<font color=\"#000099\">"
                echo 
"&nbsp;".GetPrefix($oPS2->prefixId).$oPS2->fName."&nbsp;".$oPS2->lName."</font>&nbsp;";
                
$i++;
                if(
$i==$countrowps){
                    echo 
'<br>';
                }
        }
    
        
$oRs1->SearchByDrsFromDrsIDcasedept($oRs->DrsID);
        while(
$oRs1->GetRecord()){
    
                
$oDlc1->SearchByKey($oRs1->DlcID);  
                
$oDlc1->GetRecord();    
                
$oDlp1->SearchByKey($oDlc1->DlpID);  
                
$oDlp1->GetRecord();
                
$oPS1->SearchByKey($oRs1->DrsReceivePersonId);  
                
$oPS1->GetRecord();
                
                echo 
$tab."<img src=\"../picture/linesub.gif\" title=\"\"  border=\"0\" ><img src=\"../picture/reg.png\" title=\"\"  border=\"0\" ><strong>"//echo $oRs1->DocID;
                
echo "&nbsp;".$oDlp1->DlpName."&nbsp;".$oDP1->SearchDeptName($oDlc1->deptId)."</strong>";
                if(
$oRs1->DrsReceivePersonId!='0'){
                    echo 
"&nbsp;<strong>::</strong>&nbsp;<font color=\"#000099\">".GetPrefix($oPS1->prefixId).$oPS1->fName."&nbsp;".$oPS1->lName."</font>&nbsp;";
                    
                }
            
                
showSignSendDoc($oRs1->DocID);


            
showsteplinedoc2($oRs1->DocID,$tab);
        }
echo 
"</td></tr>";

}

?>
</table>
<?
}
function 
showSignSendDoc($searchDoc){
include_once(
"../../class/clsConnection.php");
include_once(
"../../class/clsDB.php");
include_once 
"../global.php";
include_once 
"../link/functionshow.php";
include_once 
"../class/clsDocuments.php";
include_once 
"../class/clsDocReceiveSend.php";
include_once 
"../class/clsDocLineConfig.php";
include_once 
"../class/clsDocLinePosition.php";
include_once 
"../class/clsPerson.php";
include_once 
"../class/clsDepartment.php";
include_once 
"../link/function.php";
include_once 
"getPrefix.php";
include_once 
"../class/clsDocWSign.php";

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

$oDoc = new Documents($oC);
$oRs = new DocReceiveSend($oC);
$oRs1 = new DocReceiveSend($oC);
$oRs2 = new DocReceiveSend($oC);
$oRs3 = new DocReceiveSend($oC);
$oRs4 = new DocReceiveSend($oC);
$oRs5 = new DocReceiveSend($oC);
$oRs6 = new DocReceiveSend($oC);
$oRs7 = new DocReceiveSend($oC);
$oRs8 = new DocReceiveSend($oC);
$oRs9 = new DocReceiveSend($oC);
$oDlc = new DocLineConfig($oC);
$oDlc5 = new DocLineConfig($oC);
$oDlp = new docLinePosition($oC);
$oPS = new person($oC);
$oDlc1 = new DocLineConfig($oC);
$oDlc5 = new DocLineConfig($oC);
$oDlp1 = new docLinePosition($oC);
$oPS1 = new person($oC);
$oPS2 = new person($oC);
$oDP = new Department($oC);
$oDP1 = new Department($oC);
$oDws = new docwsign($oC);

                    echo 
'<table width="80%" border="0" align=center  cellpadding=0 cellspacing=0  ><tr><td>';
                    
                    
$i=0;
                    
$oRs5->SearchByDocID($searchDoc);
                    while(
$oRs5->GetRecord()){
                        
                            echo 
'<table width="100%" border="0" align=center  cellpadding=0 cellspacing=0 bordercolor=#DADADA style=border-collapse:collapse>';
                            
//echo '<tr><td>'.$oRs5->DrsID.'</td></tr>';
                            
$oDoc->SearchByKey($searchDoc); $oDoc->GetRecord(); 
                            list(
$DocD,$DocT) = preg_split('[ ]',$oDoc->DocDateCreate);
                            if(
$oRs5->DsID=="1"){  
                                        echo 
'<tr><td  height=22 bgcolor=#F0F8FF><strong><font color=#336600>ข้อมูลการลงรับ</font></strong>';
                                        if(
$oRs5->DrsNoRegisReceive=='Y'){  echo '&nbsp;(รับหนังสือแต่ไม่ลงเลขรับใหม่)'; } 
                                        echo 
'</td></tr>';
                                        echo 
'<tr><td bgcolor=#F0F8FF>&nbsp;&nbsp;<font color=#FF6600>ลงรับวันที่</font> '.abbreDate2($DocD,'/')."&nbsp;".a2th($DocT);   echo '&nbsp;&nbsp;<font color=#FF6600>เลขทะเบียน'.ShowNameRSDoc2($oDoc->RsID).'</font> : '.a2th($oDoc->DocTypeNo).'</td></tr><br>';}
                                        if(
$oRs5->DrsByPass=="Y"){ 
                                             
$oRs9->SearchByDrsFromDrsID($oRs5->DrsID);
                                            
$oRs9->GetRecord();
                                            echo 
'<tr><td  height=22><strong><font color=#336600>&nbsp;</font></strong></td></tr>';
                                            echo 
'<tr><td  height=22 bgcolor=#FFFAE8><strong><font color=#336600>ข้อมูลการส่งผ่าน</font></strong></td></tr>';
                                            echo 
'<tr><td bgcolor=#FFFAE8>&nbsp;&nbsp;<font color=#FF6600>บันทึกต่อเนื่อง</font> '.nl2br($oRs5->DrsByPassPropose).'<br>'
                                             
$oDlc5->SearchByKey($oRs5->DlcID);  $oDlc5->GetRecord();
                                             
$oPS->SearchByKey($oRs9->DrsPsIDCreate); $oPS->GetRecord();   
                                            
$oDlp->SearchByKey($oDlc5->DlpID);  $oDlp->GetRecord();            

                                            echo 
'<tr><td bgcolor=#FFFAE8>&nbsp;&nbsp;'GetPrefix($oPS->prefixId).$oPS->fName."&nbsp;".$oPS->lName."&nbsp;"."(".ShowNamePosition($oDlp->DlpID,$oDlp->DlpName,$oDP->SearchDeptName($oDlc5->deptId)).")";                                
                                            list(
$DocD,$DocT) = preg_split('[ ]',$oRs5->DrsSendDate);
                                            echo 
'&nbsp;'.abbreDate2($DocD,'/')."&nbsp;".a2th($DocT).'</font></td></tr><br>';                        
                                            
                                            
$oRs7->SearchByDrsFromDrsID($oRs5->DrsID);
                                            
$oRs7->GetRecord();
                                            
                                            
//echo 'ส่ง---'.$oRs7->DrsID;
                                            
if($oRs7->DrsSendDate!='0000-00-00 00:00:00'){
                                                echo 
'<tr><td>&nbsp;</td></tr><tr><td  height=22 bgcolor=#F0F8FF><strong><font color=#336600>ข้อมูลการส่งถึงผู้รับผิดชอบ</font></strong></td></tr>';                                            
                                                list(
$DocD,$DocT) = preg_split('[ ]',$oRs7->DrsSendDate);
                                                echo 
'<tr><td bgcolor=#F0F8FF>&nbsp;&nbsp;<font color=#FF6600>บันทึกต่อเนื่อง</font> '.nl2br($oRs8->SearchDrsProposeByDrsFromDrsID($oRs7->DrsID)).'<br>'

                                                
$oDlc5->SearchByKey($oRs7->DlcID);  $oDlc5->GetRecord();
                                                
$oPS->SearchByKey($oDlc5->personId); $oPS->GetRecord();   
                                                echo 
'&nbsp;&nbsp;'.GetPrefix($oPS->prefixId).$oPS->fName."&nbsp;".$oPS->lName."&nbsp;";         
                                                 
$oDlp->SearchByKey($oDlc5->DlpID);  $oDlp->GetRecord();
                                                echo 
"(".ShowNamePosition($oDlp->DlpID,$oDlp->DlpName,$oDP->SearchDeptName($oDlc5->deptId)).")&nbsp;"
                                                list(
$DocD,$DocT) = preg_split('[ ]',$oRs7->DrsSendDate);
                                                echo 
abbreDate2($DocD,'/')."&nbsp;".a2th($DocT).'</font></td></tr><br>';    
                                            }

                                        }

                            if(
$oRs5->DsID=="6"){
                                    echo 
'<tr><td height=22 bgcolor=#F0F8FF><strong><font color=#336600>ข้อมูลไม่ลงทะเบียนรับ</font></strong></td></tr>'
                                    list(
$DocD,$DocT) = preg_split('[ ]',$oRs5->DrsReceiveDate );
                                    echo 
'<tr><td bgcolor=#F0F8FF>&nbsp;&nbsp;<font color=#FF6600>ไม่ลงรับวันที่</font> '.abbreDate2($DocD,'/')."&nbsp;".a2th($DocT);  echo '<br>';
                            }
                            if(
$oRs5->DsID=="7"){
                                    echo 
'<tr><td height=22 bgcolor=#F0F8FF><strong><font color=#336600>ข้อมูลแจ้งการส่งผิด</font></strong></td></tr>'
                                    list(
$DocD,$DocT) = preg_split('[ ]',$oRs5->DrsReceiveDate );
                                    echo 
'<tr><td bgcolor=#F0F8FF>&nbsp;&nbsp;<font color=#FF6600>แจ้งส่งผิดวันที่</font> '.abbreDate2($DocD,'/')."&nbsp;".a2th($DocT);  echo '<br></td></tr>';
                                    echo 
'<tr><td bgcolor=#F0F8FF>&nbsp;&nbsp;<font color=#FF6600>คำชี้แจง แจ้งการส่งผิด ::  </font> '.$oRs5->DrsSendBack;  echo '<br></td></tr>';
                                    echo 
'<tr><td bgcolor=#F0F8FF>&nbsp;&nbsp;<font color=#FF6600>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;หน่วยงานที่ส่งกลับ ::  </font> '.searchDlcIDPsDept($oRs5->DrsSendBackDlcID);  echo '<br></td></tr>';
                            }
                            if(
$oRs5->DsID=="2"){ 
                                       echo 
'<tr><td height=22 bgcolor=#FFFAE8><strong><font color=#336600>ข้อมูลเสนอลงนาม</font></strong></td></tr>'
                                       echo 
'<tr><td bgcolor=#FFFAE8>&nbsp;&nbsp;<font color=#FF6600>บันทึกต่อเนื่อง</font> '.nl2br($oRs5->DrsPropose).'<br>';  
                                       
$oPS->SearchByKey($oRs5->DrsPsIDCreate); $oPS->GetRecord();   
                                       echo 
'&nbsp;&nbsp;'.GetPrefix($oPS->prefixId).$oPS->fName."&nbsp;".$oPS->lName."&nbsp;";                         
                                          
$oDlc5->SearchByKey($oRs5->DrsDlcIDCreate);  $oDlc5->GetRecord();    
                                          
$oDlp->SearchByKey($oDlc5->DlpID);  $oDlp->GetRecord();            
                                          echo 
"(".ShowNamePosition($oDlp->DlpID,$oDlp->DlpName,$oDP->SearchDeptName($oDlc5->deptId)).")&nbsp;";  
                                        list(
$DocD,$DocT) = preg_split('[ ]',$oRs5->DrsReceiveDate );
                                        echo 
abbreDate2($DocD,'/')."&nbsp;".a2th($DocT); 
                                        echo 
'</td></tr><br>';  
                            }
                            if(
$oRs5->DrsWSign=='Y'){
                                            
$oDws->SearchByDrsIDDocID($oRs5->DrsID,$oRs5->DocID);
                                            
$oDws->GetRecord();
                                     echo 
'<tr><td>&nbsp;</td></tr>';
                                     echo 
'<tr><td height=22 bgcolor=#FFFAE8><strong><font color=#336600>ข้อมูล'.$GLOBALS['DOCFORSIGNNAME'].'</font></strong></td></tr>'
                                     echo 
'<tr><td bgcolor=#FFFAE8>&nbsp;&nbsp;<font color=#FF6600>บันทึกต่อเนื่อง</font> '.nl2br($oDws->DocSign).'<br>';  
                                      
$oPS->SearchByKey($oDws->personId); $oPS->GetRecord();   
                                      echo 
'&nbsp;&nbsp;'.GetPrefix($oPS->prefixId).$oPS->fName."&nbsp;".$oPS->lName."&nbsp;";  
                                      
$oDlc5->SearchByKey($oDws->DlcID);  $oDlc5->GetRecord();    
                                      
$oDlp->SearchByKey($oDlc5->DlpID);  $oDlp->GetRecord();            
                                     echo 
"(".ShowNamePosition($oDlp->DlpID,$oDlp->DlpName,$oDP->SearchDeptName($oDlc5->deptId)).")&nbsp;";  
                                        list(
$DocD,$DocT) = preg_split('[ ]',$oDws->signDateTime);
                                        echo 
abbreDate2($DocD,'/')."&nbsp;".a2th($DocT); 
                                        echo 
'</td></tr><br>';  
                            }
                             if(
$oRs5->DrsSignEndDoc=="Y"){ 
                                       echo 
'<tr><td>&nbsp;</td></tr>';
                                      echo 
'<tr><td height=22 bgcolor=#E4F0F9><strong><font color=#336600>ข้อมูลการลงนาม</font></strong></td></tr>';  
                                     echo 
'<tr><td bgcolor=#E4F0F9>&nbsp;&nbsp;<font color=#FF6600>บันทึกต่อเนื่อง</font> '.nl2br($oRs5->DrsSign).'<br>';  
                                      
$oPS->SearchByKey($oRs5->DrsSendPersonId); $oPS->GetRecord();   
                                      echo 
'&nbsp;&nbsp;'.GetPrefix($oPS->prefixId).$oPS->fName."&nbsp;".$oPS->lName."&nbsp;";     
                                     
$oDlc5->SearchByKey($oRs5->DrsSendDlcID);  $oDlc5->GetRecord();    
                                     
$oDlp->SearchByKey($oDlc5->DlpID);  $oDlp->GetRecord();
                                    echo 
"(".ShowNamePosition($oDlp->DlpID,$oDlp->DlpName,$oDP->SearchDeptName($oDlc5->deptId)).")&nbsp;"
                                    list(
$DocD,$DocT) = preg_split('[ ]',$oRs5->DrsSendDate);
                                    echo 
abbreDate2($DocD,'/')."&nbsp;".a2th($DocT); 
                                    echo 
'</td></tr><tr><td bgcolor=#E4F0F9><input name=canendDoc type=checkbox disabled checked>&nbsp;ยุติหนังสือ (ไม่ส่งถึงผู้รับผิดชอบ)</td></tr><br>';
                             }
                            
$oRs6->SearchByKey($oRs5->DrsFromDrsID);
                            
$oRs6->GetRecord();
                            
                             if(
$oRs5->DsID=="3" && $oRs6->DrsByPass!='Y'){ 
                                      echo 
'<tr><td height=22 bgcolor=#E4F0F9><strong><font color=#336600>ข้อมูลการลงนาม</font></strong></td></tr>';  
                                     echo 
'<tr><td bgcolor=#E4F0F9>&nbsp;&nbsp;<font color=#FF6600>บันทึกต่อเนื่อง</font> '.nl2br($oRs5->DrsSign).'<br>';  
                                      
$oPS->SearchByKey($oRs5->DrsPsIDCreate); $oPS->GetRecord();   
                                      echo 
'&nbsp;&nbsp;'.GetPrefix($oPS->prefixId).$oPS->fName."&nbsp;".$oPS->lName."&nbsp;";     
                                     
$oDlc5->SearchByKey($oRs5->DrsDlcIDCreate);  $oDlc5->GetRecord();    
                                     
$oDlp->SearchByKey($oDlc5->DlpID);  $oDlp->GetRecord();
                                    echo 
"(".ShowNamePosition($oDlp->DlpID,$oDlp->DlpName,$oDP->SearchDeptName($oDlc5->deptId)).")&nbsp;"
                                    list(
$DocD,$DocT) = preg_split('[ ]',$oRs5->DrsReceiveDate );
                                    echo 
abbreDate2($DocD,'/')."&nbsp;".a2th($DocT); 
                                    echo 
'</td></tr><br>';
                                    if(
$oRs5->DrsSendDate!='0000-00-00 00:00:00'){
                                                echo 
'<tr><td>&nbsp;</td></tr><tr><td  height=22 bgcolor=#F0F8FF><strong><font color=#336600>ข้อมูลการส่งถึงผู้รับผิดชอบ</font></strong></td></tr>';                                            
                                                list(
$DocD,$DocT) = preg_split('[ ]',$oRs5->DrsSendDate);
                                                echo 
'<tr><td bgcolor=#F0F8FF>&nbsp;&nbsp;<font color=#FF6600>บันทึกต่อเนื่อง</font> '.nl2br($oRs8->SearchDrsProposeByDrsFromDrsID($oRs5->DrsID)).'<br>'


                                                
$oDlc5->SearchByKey($oRs5->DlcID);  $oDlc5->GetRecord();

                                                
$oPS->SearchByKey($oRs5->DrsReceivePersonId ); $oPS->GetRecord();   
                                                echo 
'&nbsp;&nbsp;'.GetPrefix($oPS->prefixId).$oPS->fName."&nbsp;".$oPS->lName."&nbsp;";         
                                                 
$oDlp->SearchByKey($oDlc5->DlpID);  $oDlp->GetRecord();
                                                echo 
"(".ShowNamePosition($oDlp->DlpID,$oDlp->DlpName,$oDP->SearchDeptName($oDlc5->deptId)).")&nbsp;"
                                                list(
$DocD,$DocT) = preg_split('[ ]',$oRs5->DrsSendDate);
                                                echo 
abbreDate2($DocD,'/')."&nbsp;".a2th($DocT).'</font></td></tr><br>';


                                    }
                             }
                            echo 
'</table>';
               }
                    echo 
'</td></tr></table>';
                    
}
function 
showDeptForSend($deptId,$iselect,$DlcdeptId,$searchDoc){
include_once(
"../../class/clsConnection.php");
include_once(
"../../class/clsDB.php");
include_once 
"../global.php";
include_once 
"../class/clsDepartment.php";
include_once 
"../class/clsDocReceiveSend.php";

$oC = new clsConnection($GLOBALS['DBHOST'], $GLOBALS['DBNAME_EOFFICE'], $GLOBALS['DBUSER_EOFFICE'], $GLOBALS['DBPASS_EOFFICE']);
$oDPt = new Department($oC);
$oDPt2 = new Department($oC);
$oRs9 = new DocReceiveSend($oC);
//$iselect++;
global $iselect;
global 
$mydept;
global 
$pssend;
                        
$oDPt->SearchByKey($deptId);
                        
$oDPt->GetRecord();
                        
                        
$pssend=ShowSendtoPs2($deptId); 
                        if(
$pssend!=''){
                            
//echo "<tr><td>&nbsp;";
                                //echo "<input name=mainDepts id=mainDepts".$pssend." type=radio value=\"".$pssend."\"></td><td>";
                            
    
                            
echo "<input name=deptPs[".$deptId."]  id=select1[".$iselect."] type=checkbox  value=\"".$pssend."\"";
                            if(
$pssend==''){ echo " disabled "; }
                            echo 
" onClick=\"return NocheckAll2();\">";
                            if(
$DlcdeptId==$deptId){   $mydept=$iselect; }
                            
                            
$tab="&nbsp;";
                            if(
$oDPt->deptLevel%!= 0){  $stylefont="<b>";  $stylefont2="</b>"; }
                            for(
$i=1;$i<=$oDPt->deptLevel;$i++){
                                
$tab.="&nbsp;&nbsp;&nbsp;&nbsp;";
                            }
                            
$nextpssend=searchnextpssend($pssend,$oDPt->deptId);  $oRs9->searchHaveSendDoc($pssend,$nextpssend,$searchDoc); 
                            
$showimg="";
                            if(
$oRs9->GetRecord()==1){ 
                                
//$showimg="<img src=\"../picture/yes.gif\"  border=\"0\"  title=\"หมายถึงหน่วยงานย่อยหรือบุคลากรผู้นั้น เคยได้รับหนังสือนี้แล้ว\">"; 
                            

                            echo 
"<label for=\"select1[".$iselect."]\"";
                            echo 
iconv('TIS-620','UTF-8',$showimg.$tab.$stylefont.$oDPt->deptName.$stylefont2);
                            echo 
"</label>";
                            
//echo "</td></tr>";
                        
}else{
                            echo 
"<input name=deptPs[".$deptId."]  id=select1[".$iselect."] type=hidden  value=\"".$pssend."\">";
                        }
                        
                        
                        
                        
$oDPt2->RSmenuByDeptParent2($oDPt->deptId);
                        while(
$oDPt2->GetRecord()){
                            
$iselect++;
                            
showDeptForSend($oDPt2->deptId,$iselect,$DlcdeptId,$searchDoc);
                            
                        }
    

}
function 
showDeptForSendDocNew($deptId,$DlcdeptId,$searchDoc){
include_once(
"../../class/clsConnection.php");
include_once(
"../../class/clsDB.php");
include_once 
"../global.php";
include_once 
"../class/clsDepartment.php";
include_once 
"../class/clsDocReceiveSend.php";

$oC = new clsConnection($GLOBALS['DBHOST'], $GLOBALS['DBNAME_EOFFICE'], $GLOBALS['DBUSER_EOFFICE'], $GLOBALS['DBPASS_EOFFICE']);
$oDPt = new Department($oC);
$oDPt2 = new Department($oC);
$oRs9 = new DocReceiveSend($oC);

global 
$pssend;
//global $nextpssend;
                        
$oDPt->SearchByKey($deptId);
                        
$oDPt->GetRecord();
                        
                        
$pssend=ShowSendtoPs2($deptId); 
                        if(
$pssend!=''){ 
                            echo 
"<tr><td>&nbsp;&nbsp;";
                            
                            echo 
"<input name=deptPs[".$deptId."]   type=checkbox  value=\"".$pssend."\"";
                            if(
$pssend==''){ echo " disabled "; }
                            echo 
">";
                        
                            
$nextpssend=searchnextpssend($pssend,$oDPt->deptId);   
                            if(
$nextpssend!=""){ 
                                    
$oRs9->searchHaveSendDoc($pssend,$nextpssend,$searchDoc); 
                                    if(
$oRs9->GetRecord()==1){ 
                                            echo 
"<img src=\"../picture/yes.gif\"  border=\"0\"  title=\"หมายถึงหน่วยงานย่อยหรือบุคลากรผู้นั้น เคยได้รับหนังสือนี้แล้ว\">"
                                    } 
                            }
                            
                            
$tab="&nbsp;";
                            if(
$oDPt->deptLevel%!= 0){  $stylefont="<b>";  $stylefont2="</b>"; }
                            for(
$i=1;$i<=$oDPt->deptLevel;$i++){
                                
$tab.="&nbsp;&nbsp;&nbsp;&nbsp;";
                            }    
                            echo 
$tab.$stylefont.$oDPt->deptName.$stylefont2;
                            echo 
"</td></tr>";
                        }
                        
$oDPt2->RSmenuByDeptParent2($oDPt->deptId);
                        while(
$oDPt2->GetRecord()){
                            
showDeptForSendDocNew($oDPt2->deptId,$DlcdeptId,$searchDoc);
                            
                        }
    

}
function 
searchDocPath($cId){
include_once(
"../../class/clsConnection.php");
include_once(
"../../class/clsDB.php");
include_once 
"../global.php";
include_once 
"../class/clsCollegeDetail.php";

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

$oCD->SearchByKey($cId);
$oCD->GetRecord();

//---show documents path
return "http://".$oCD->collegeHost.$GLOBALS["ROOT_URL"]."eoffice/documents/";

}
function 
searchcollegeAbbr($cId){
include_once(
"../../class/clsConnection.php");
include_once(
"../../class/clsDB.php");
include_once 
"../global.php";
include_once 
"../class/clsCollegeDetail.php";

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

$oCD->SearchByKey($cId);
$oCD->GetRecord();
    
return 
$oCD->collegeAbbr;

}
function 
searchDlcIDPsDept($DlcID){
include_once(
"../../class/clsConnection.php");
include_once(
"../../class/clsDB.php");
include_once 
"../global.php";
include_once 
"../class/clsDocLineConfig.php";
include_once 
"../class/clsDepartment.php";

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

$oDlc->SearchByKey($DlcID);
$oDlc->GetRecord();

$oDP->SearchByKey($oDlc->deptId);
$oDP->GetRecord();


return 
$oDP->deptName

}
function 
searchDlcIDPsDeptID($DlcID){
include_once(
"../../class/clsConnection.php");
include_once(
"../../class/clsDB.php");
include_once 
"../global.php";
include_once 
"../class/clsDocLineConfig.php";
include_once 
"../class/clsDepartment.php";

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

$oDlc->SearchByKey($DlcID);
$oDlc->GetRecord();

$oDP->SearchByKey($oDlc->deptId);
$oDP->GetRecord();


return 
$oDP->deptId

}
function 
checkCountfileDocAtt($DrsReadDoc){
            
$len=strlen($DrsReadDoc);
            
$str=$DrsReadDoc;
            
$count=0;  
            for(
$i=0$i<$len$i++){  
                if(
$str{$i}==0){
                    
$count++;
                }
            }

return 
$count

}
function 
searchDlcPS2($DlpID,$dlcid,$DlcSeq,$deptId){
include_once(
"../../class/clsConnection.php");
include_once(
"../../class/clsDB.php");
include_once 
"../global.php";
include_once 
"../class/clsDocLineConfig.php";
include_once 
"../class/clsDocLinePosition.php";

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

    
$oDlp1->SearchByKey($DlpID);  
    
$oDlp1->GetRecord();
    if(
$oDlp1->DlpPID!="0"){ 
        return 
$DlcPS2=$dlcid;
    }else{
        return 
$DlcPS2=$oDlc2->SearchDlc2($DlcSeq,$oDlp1->DlpPID,$deptId);
    }
}
function 
searchPicDocSpeedLevel($DslID){
include_once(
"../../class/clsConnection.php");
include_once(
"../../class/clsDB.php");
include_once 
"../global.php";
include_once 
"../class/clsDocSpeedLevel.php";
$oC = new clsConnection($GLOBALS['DBHOST'], $GLOBALS['DBNAME_EOFFICE'], $GLOBALS['DBUSER_EOFFICE'], $GLOBALS['DBPASS_EOFFICE']);

$oDsl2 = new DocSpeedLevel($oC);

    if(
$DslID=="0"){ 
        
$rapid="../picture/rapid0.jpg";  
        
$rapidname=$oDsl2->SearchName(0); 
    }else if(
$DslID=="1"){  
        
$rapid="../picture/rapid1.jpg"
        
$rapidname=$oDsl2->SearchName(1); 
    }else if(
$DslID=="2"){  
        
$rapid="../picture/rapid2.jpg"
        
$rapidname=$oDsl2->SearchName(2); 
    }else if(
$DslID=="3"){ 
        
$rapid="../picture/rapid3.jpg";  
        
$rapidname=$oDsl2->SearchName(3); 
    }else{  
        
$rapid="../picture/blank.gif"
        
$rapidname=""
    }
    return 
"<img src=".$rapid." title=".$rapidname." border=0>";
}
function 
searchPicDocSecretLevel($DclID){
include_once(
"../../class/clsConnection.php");
include_once(
"../../class/clsDB.php");
include_once 
"../global.php";
include_once 
"../class/clsDocSecreLevel.php";
$oC = new clsConnection($GLOBALS['DBHOST'], $GLOBALS['DBNAME_EOFFICE'], $GLOBALS['DBUSER_EOFFICE'], $GLOBALS['DBPASS_EOFFICE']);

$oDcl2 = new DocSecretLevel($oC);

     if(
$DclID=="0"){ 
         
$secret="../picture/secret0.jpg"
        
$secretname=$oDcl2->SearchName(0);  
    }else if(
$DclID=="1"){  
        
$secret="../picture/secret1.jpg"
        
$secretname=$oDcl2->SearchName(1); 
    }else if(
$DclID=="2"){  
        
$secret="../picture/secret2.jpg"
        
$secretname=$oDcl2->SearchName(2); 
    }else if(
$DclID=="3"){ 
        
$secret="../picture/secret3.jpg";  
        
$secretname=$oDcl2->SearchName(3); 
    }else if(
$DclID=="4"){   
        
$secret="../picture/secret4.jpg"
        
$secretname=$oDcl2->SearchName(4);   
    }else{  
        
$secret="../picture/blank.gif";  
        
$secretname=""
    }    
            
    return 
"<img src=".$secret." title=".$secretname." border=0>";
}
function 
bgForRegisPage($DtID){
    if(
$DtID=="5" || $DtID=="6" || $DtID=="7" || $DtID=="9" || $DtID=="10" || $DtID=="11" || $DtID=="12" || $DtID=="13"){ 
            return 
"../picture/table_header_bg2.gif"
    }else{ 
            return 
"../picture/table_header_bg.gif";  
    }
}
function 
bgForRegisPage2($DtID){
    if(
$DtID=="5" || $DtID=="6" || $DtID=="7" || $DtID=="9" || $DtID=="10" || $DtID=="11" || $DtID=="12" || $DtID=="13"){ 
            return 
"../picture/table_header_bg6.gif"
    }else{ 
            return 
"../picture/table_header_bg5.gif";  
    }
}
function 
bgForSendPage($DtID){
    if(
$DtID=="6" || $DtID=="7" || $DtID=="9"){
            return 
"../picture/table_header_bg2.gif"
    }else{ 
            return 
"../picture/table_header_bg.gif";  
    }
}
function 
bgForSendPage2($DtID){
    if(
$DtID=="5" || $DtID=="6" || $DtID=="7" || $DtID=="9" || $DtID=="10" || $DtID=="11" || $DtID=="12" || $DtID=="13"){
            return 
"../picture/table_header_bg6.gif"
    }else{ 
            return 
"../picture/table_header_bg5.gif";  
    }
}
function 
bgForSignPage($DtID){
    if(
$DtID=="6" || $DtID=="7" || $DtID=="9"){
            return 
"../picture/table_header_bg2.gif"
    }else{ 
            return 
"../picture/table_header_bg.gif";  
    }
}
function 
bgForSignPage2($DtID){
    if(
$DtID=="5" || $DtID=="6" || $DtID=="7" || $DtID=="9" || $DtID=="10" || $DtID=="11" || $DtID=="12" || $DtID=="13"){
            return 
"../picture/table_header_bg6.gif"
    }else{ 
            return 
"../picture/table_header_bg5.gif";  
    }
}
function 
searchPosition($dicid){
include_once(
"../../class/clsConnection.php");
include_once(
"../../class/clsDB.php");
include_once 
"../global.php";
include_once 
"../class/clsDocLineConfig.php";
include_once 
"../class/clsDocLinePosition.php";

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

    
$oDlc2->SearchByKey($dicid);
    
$oDlc2->GetRecord();
    
    
$oDlp1->SearchByKey($oDlc2->DlpID);  
    
$oDlp1->GetRecord();
    return 
$oDlp1->DlpName;
}
function 
microtime_float()
{
    list(
$usec$sec) = explode(" "microtime());
    return ((float)
$usec + (float)$sec);
}
function 
searchPsAct($DocID,$RsID){

include_once(
"../../class/clsConnection.php");
include_once(
"../../class/clsDB.php");
include_once 
"../global.php";
include_once 
"../class/clsDocLineConfig.php";
include_once 
"../class/clsDocLinePosition.php";
include_once 
"getPrefix.php";
include_once 
"../class/clsPerson.php";
include_once 
"../class/clsDepartment.php";
include_once 
"../class/clsDocReceiveSend.php";

$oC = new clsConnection($GLOBALS['DBHOST'], $GLOBALS['DBNAME_EOFFICE'], $GLOBALS['DBUSER_EOFFICE'], $GLOBALS['DBPASS_EOFFICE']);
$oDlc2 = new DocLineConfig($oC);
$oDlp1 = new docLinePosition($oC);
$oPS = new person($oC);
$oDP = new Department($oC);
$oRs = new DocReceiveSend($oC);

    
$oRs->SearchDrsReceivePersonId($DocID);
    
$oRs->GetRecord();

    
$oDlc2->SearchByKey($oRs->DlcID);
    
$oDlc2->GetRecord();
    
    
$oDlp1->SearchByKey($oDlc2->DlpID);  
    
$oDlp1->GetRecord();

    
$oPS->SearchByKey($oRs->DrsReceivePersonId); 
    
$oPS->GetRecord(); 
    
    
$oDP->SearchByKey($oDlc2->deptId);
    
$oDP->GetRecord();

    if(
$RsID=="5"){ $psact="ผู้ลงทะเบียน"; }else{  $psact="ผู้ส่ง"; }
    return 
"<b>".$psact." ::</b><br>".GetPrefix($oPS->prefixId).$oPS->fName."&nbsp;".$oPS->lName."<br>"."(".$oDlp1->DlpName.")<br>".$oDP->deptName;

}
function 
showeDoc($eDoc){
    if(
$eDoc=="Y"){
        echo 
"<img src=\"../picture/eDoc.gif\" title=\"หนังสือรับอิเล็กทรอนิกส์\" >";
    }
}
function 
downloadProgramRead($d){
    if(
$d=="Y"){
        echo 
"<br><a href=\"../foxitDownload/FoxitReader31_enu_Setup.exe\" title=\"ดาวน์โหลดโปรแกรมสำหรับอ่าน pdf\">(ดาวน์โหลดโปรแกรม <img src=\"../picture/foxiticon.gif\" border=0> Foxit Reader ที่นี่)</a>&nbsp;<br>";
    }
}
function 
showStatusNoticeDoc($status){
    if(
$status=="1"){ return "แจ้งแก้ไข"; }else if($status=="2"){ return "ดำเนินการแก้ไขแล้ว"; }else if($status=="3"){  echo "แก้ไขเอง";}
}
function 
showStatusEditDocforSign($status){
    if(
$status==""){ return "ยังไม่ถูกแก้ไข"; }else if($status=="Y"){ return "แก้ไขแล้ว"; }
}
function 
chkBrowser($nameBroser){   
    return 
preg_match("/".$nameBroser."/",$_SERVER['HTTP_USER_AGENT']);   
}  
function 
showtextarea($fname,$InputThai){
    if(
chkBrowser("MSIE")==1){    //Internet Explorer $ver[2]"
        
echo "onKeyPress=\"if(event.keyCode==39){  alert('ระบบไม่สามารถบันทึกตัวอักษรนี้ได้!!'); return false;}else{     event.keyCode=KeyfontThai(event.keyCode,'".$InputThai."'); return event.keyCode;  }\"";
    } else{   
// if(chkBrowser("Firefox")==1) FireFox
        
echo "onkeypress=\"return chkNoKey(event)\" onKeyUp=\"CheckInput('".$InputThai."','".$fname."')\"";
    }  
}
function 
showstatussendreceivedoc($searchDoc,$c_id){
include_once(
"../../class/clsConnection.php");
include_once(
"../../class/clsDB.php");
include_once 
"../global.php";
include_once 
"../link/function.php";
include_once 
"getPrefix.php";
include_once 
"../class/clsSendReceive.php";
include_once 
"../class/clsCollegeDetail.php";

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

    echo 
"<table border=0 align=center width=97%>";
    
$oTsr->SearchBytsr_docidandtsr_fr_node($searchDoc,$c_id);
     while(
$oTsr->GetRecord()){
            
$oCd->SearchByKey($oTsr->tsr_to_node);
            
$oCd->GetRecord();
            echo 
"<tr><td><img src=\"../picture/linesub.gif\" title=\"\"  border=\"0\" >"."<img src=\"../picture/reg.png\" title=\"\"  border=\"0\" >&nbsp;<b>หน่วยงานภายนอก&nbsp;".$oCd->collegeAbbr."</b>";
                if(
$oTsr->tsr_receive=="Y"){ 
                    list(
$DocD,$DocT) = preg_split('[ ]',$oTsr->tsr_receivedate);  
                    echo 
"&nbsp;[วันที่ลงรับ ::&nbsp;".abbreDate2forCheck($DocD,'/')."&nbsp;".a2th($DocT)."]"
                }else if(
$oTsr->tsr_receive=="N"){ 
                    list(
$DocD,$DocT) = preg_split('[ ]',$oTsr->tsr_receivedate); 
                    echo 
"&nbsp;[วันที่ไม่่ลงรับ ::&nbsp;".abbreDate2forCheck($DocD,'/')."&nbsp;".a2th($DocT)."]";
                }else if(
$oTsr->tsr_receive=="R"){ 
                    list(
$DocD,$DocT) = preg_split('[ ]',$oTsr->tsr_receivedate); 
                    echo 
"&nbsp;[วันที่แจ้งส่งผิด ::&nbsp;".abbreDate2forCheck($DocD,'/')."&nbsp;".a2th($DocT)."]";
                }
                
            echo 
"</td></tr>";
            echo 
"<tr><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;สถานะ :: ".Showtsr_statusSender($oTsr->tsr_status,$oTsr->tsr_receive)."</td></tr>";
     }
     echo 
"</table>"
}
//----change group or position
function SearchSendAll($DlpId){
if(
$DlpId==|| $DlpId==|| $DlpId==|| $DlpId==4){
    return 
"All";
}
}
function 
SearchSendAll_send($DlpId){
    return 
"All";
}
function 
SearchSendAll_receive($DlpId){
if(
$DlpId==|| $DlpId==2){
    return 
"All";
}

}
function 
SearchCanKeepDocRegis($DlpId){
if(
$DlpId==|| $DlpId==2){
    return 
"All";
}
}
function 
SearchCanSeeAll($DlpId){
if(
$DlpId==|| $DlpId==2){
    return 
"All";
}
}
function 
SearchGroupforSelect($g){
if(
$g==107 || $g==110 || $g==111 || $g==112 || $g==115 || $g==116 || $g==117){
    return 
"Y";
}
}
function 
SearchGroupUsers(){
    return 
"108";
}
function 
SearchGroupSarabunStaff(){
    return 
"107";
}
function 
SearchGroupAdmin(){
    return 
"109";
}
function 
SearchGroupSarabunHead(){
    return 
"110";
}
function 
SearchGroupHeadDept(){
    return 
"111";
}
function 
SearchGroupBoss(){
    return 
"112";
}
function 
SearchGroupBossSecond(){
    return 
"115";
}
function 
SearchGroupBoss2(){
    return 
"116";
}

function 
SearchGroupBossSecond2(){
    return 
"117";
}
function 
SearchDlpIDSarabunCenter(){
    return 
"1";
}
function 
searchnextpssend($pssend,$deptId){
include_once(
"../../class/clsConnection.php");
include_once(
"../../class/clsDB.php");
include_once 
"../global.php";
include_once 
"../class/clsDocLineConfig.php";
include_once 
"../class/clsDepartment.php";
include_once 
"getPrefix.php";

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

$oDlc = new DocLineConfig($oC);
$oDlc2 = new DocLineConfig($oC);
$oDlc3 = new DocLineConfig($oC);
$oDP = new Department($oC);
$maxgroup=$oDP->SearchMaxDocGroup();

//    echo '---------------ss'.$oDlc->DlpID;
    
$oDlc->SearchByKey($pssend);
    
$oDlc->GetRecord();
    if(
$oDlc->DlpID=="5"){
            
$nextDlpID="6";
    }else if(
$oDlc->DlpID=="6"){
            
$nextDlpID="5";
    }else if(
$oDlc->DlpID=="11"){ 
            
$nextDlpID="12"
    }else if(
$oDlc->DlpID=="12"){ 
                
$nextDlpID="11";
    }else if(
$oDlc->DlpID=="15"){ 
                
$nextDlpID="16"
    }else if(
$oDlc->DlpID=="16"){ 
                
$nextDlpID="15"
    }else if(
$oDlc->DlpID=="18"){
                
$nextDlpID="19";
    }else if(
$oDlc->DlpID=="19"){ 
                
$nextDlpID="18"
    }else if(
$oDlc->DlpID=="28"){
                
$nextDlpID="29"
    }else if(
$oDlc->DlpID=="29"){
                
$nextDlpID="28";
    }else if(
$oDlc->DlpID=="30"){ 
                
$nextDlpID="31"
    }else if(
$oDlc->DlpID=="32"){ $nextDlpID="33"; }else if($oDlc->DlpID=="33"){ $nextDlpID="32"; }else if($oDlc->DlpID=="34"){ $nextDlpID="35"; }else if($oDlc->DlpID=="35"){ $nextDlpID="34"; }else if($oDlc->DlpID=="36"){ $nextDlpID="37"; }else if($oDlc->DlpID=="37"){ $nextDlpID="36"; }else if($oDlc->DlpID=="38"){ $nextDlpID="39"; }else if($oDlc->DlpID=="39"){ $nextDlpID="38"; }else if($oDlc->DlpID=="46"){ $nextDlpID="47"; }else if($oDlc->DlpID=="47"){ $nextDlpID="46"; }
    
$oDlc2->SearchDlcIDDlpID($nextDlpID,$deptId);
    
$oDlc2->GetRecord();
    return 
$oDlc2->DlcID;
}
function 
searchGetDlpIDCenter($DlpId){
    if(
$DlpId==|| $DlpId==|| $DlpId==|| $DlpId==4){
        return 
"Y";
    }else{
        return 
"N";
    }
}
function 
checkSarabunMain($DlpID){
    if(
$DlpID=="1" || $DlpID=="2"){   return 1;  }
}
function 
setNewHost($collegeID,$oldHost,$newHost){
include_once(
"../../class/clsConnection.php");
include_once(
"../../class/clsDB.php");
include_once 
"../global.php";
include_once 
"../class/clsCollegeDetail.php";
include_once 
"../class/clsSendReceive.php";


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

$oCd = new collegedetail($oC);
$oCd2 = new collegedetail($oC);
$oTsr = new sendreceive($oC);
$oTsr2 = new sendreceive($oC);
$oTsr3 = new sendreceive($oC);
$oTsr4 = new sendreceive($oC);

$oTsr->SearchByNodeEditHost('tsr_fr_node',$collegeID);
while(
$oTsr->GetRecord()){
    
$newvalue=str_replace($oldHost,$newHost,$oTsr->tsr_doc_url);
    
$oTsr2->UpdateEditHost($newvalue,$collegeID,'tsr_fr_node');
}

}
function 
GetDocRegisNofromCenter($selectdocregis,$RegisterName,$RegisterYear,$DocID,$DlcID,$personId){
require_once(
'../lib/nusoap.php');
include_once(
"../../class/clsConnection.php");
include_once(
"../../class/clsDB.php");
include_once 
"../global.php";
include_once 
"../class/clsDocuments.php";
include_once 
"../class/clsDocSpeedLevel.php";
include_once 
"../class/clsDocSecreLevel.php";
include_once 
"../class/clsPerson.php";
include_once 
"../class/clsSysConfig.php";
include_once 
"../class/clsDocNoRequest.php";

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

$oDoc = new Documents($oC);
$oDoc2 = new Documents($oC);
$oDsl = new DocSpeedLevel($oC);
$oDcl = new DocSecretLevel($oC);
$oPS = new person($oC);
$oSys = new sysConfig($oC);
$oDnr = new DocNoRequest($oC);

$oDoc->SearchByKey($DocID); $oDoc->GetRecord(); 
$oSys->RSsysConfig();
$oSys->GetRecord();

$wsdlurl 'http://203.157.2.6:8180/esrbcl_pbri/ESRBCLWS?wsdl';
$wsdlfile './eiam.wsdl';

    
$client = new nusoap_client($wsdlfile,true);
    
$client->soap_defencoding 'UTF-8';
        
$client->decode_utf8 false;
    
$err $client->getError();
    if(
$err){
        echo 
$err;
    }

    
//$params = array('xmlRequest' => $request);
    
$result $client->call('getUk');
     
    if (
$client->fault) {
        echo 
'Fault'print_r($result);
    } else {
        
// Check for errors
        
$err $client->getError();
        if (
$err) {
            
// Display the error
            
echo 'Error'$err;
        } else {
            
// Display the result
            //echo 'Result' . print_r($result);      
        
}
    }
    
$result3=$result['return'];
    
$getUk=$result3;
    if(
$getUk==''){
                echo 
'Error GetUk';
    }else{
                
$client = new nusoap_client($wsdlfile,true);
                
$client->soap_defencoding 'UTF-8';
                    
$client->decode_utf8 false;
                
$err $client->getError();
                if(
$err){
                    echo 
$err;
                }

                
//----get value from Documents table
                
list($yy$mm$dd) = preg_split('[-]',$oDoc->DocDate);
                
$DocDate=($yy-543)."-".$mm."-".$dd;
                
$DslID=$oDsl->SearchTHeGIF_SID($oDoc->DslID); 
                
$DclID=$oDcl->SearchTHeGIF_CID($oDoc->DclID); 
                 
$oPS->SearchByKey($oU->userPsCode); $oPS->GetRecord();  
                 
$JobTitle=iconv('TIS-620','UTF-8',$oSys->collegeName);
                
$sendDate=Date('Y-m-d').'T'.Date('h:m:s');

            
$doc '<?xml version="1.0" encoding="utf-8"?><GovernmentDocumentRegisterRequest><GovernmentDocumentRegister><UK>'.$getUk.'</UK><RegisterID>'.$selectdocregis.'</RegisterID><RegisterYear>'.$RegisterYear.'</RegisterYear><RegisterName>'.iconv('TIS-620','UTF-8',$RegisterName).'</RegisterName><CorrespondenceLetter><ID>'.iconv('TIS-620','UTF-8',th2a($oSys->sysDocNo)).'/'.'</ID><CorrespondenceDate>'.$DocDate.'</CorrespondenceDate><Subject>'.iconv('TIS-620','UTF-8',$oDoc->DocSubject).'</Subject><Secret><Code>'.$DclID.'</Code></Secret><Speed><Code>'.$DslID.'</Code></Speed><Sender><Firstname>'.iconv('TIS-620','UTF-8',$oPS->fName).'</Firstname><Lastname>'.iconv('TIS-620','UTF-8',$oPS->lName).'</Lastname><JobTitle>'.$JobTitle.'</JobTitle><Department><Code>21199</Code></Department><Ministry><Code>21</Code></Ministry></Sender><Receiver><Firstname>test</Firstname><Lastname>test</Lastname><JobTitle>test</JobTitle><Department><Code>21002</Code></Department><Ministry><Code>21</Code></Ministry></Receiver><Attachment>-</Attachment><Description>testRequestRegisDoc</Description><SendDate>'.$sendDate.'</SendDate><MainLetter xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" MimeType="" xsi:nil="true"/></CorrespondenceLetter></GovernmentDocumentRegister></GovernmentDocumentRegisterRequest>';

                
$params = array('uk' => $getUk,'xmlRequest'=>$doc);
                
$result $client->call('getMinistryRegisterNo',$params);
                 
                if (
$client->fault) {
                    echo 
'Fault'print_r($result);
                } else {
                    
// Check for errors
                    
$err $client->getError();
                    if (
$err) {
                        
// Display the error
                        
echo 'Error'$err;
                    } else {
                        
// Display the result
                        //echo 'Result' . print_r($result);      
                    
}
                    
$result4=$result['return'];

                }

                if(
$result4!=''){
                    
$xml simplexml_load_string($result4);
                    foreach(
$xml->children() as $GovernmentDocumentRegister){
                                
/*
                                echo "รหัสสมุดทะเบียน==".$GovernmentDocumentRegister->RegisterID.'<br>';
                                echo "ปี==".$GovernmentDocumentRegister->RegisterYear.'<br>';
                                echo "ชื่อสมุดทะเบียน==".iconv('UTF-8','TIS-620',$GovernmentDocumentRegister->RegisterName).'<br>';
                                */
                                
$RegisterNumber=$GovernmentDocumentRegister->RegisterNumber;
                                
/*
                                echo "ที่หนังสือ==".iconv('UTF-8','TIS-620',$RegisterNumber->ID).'<br>';            
                                echo "เลขทะเบียนหนังสือ==".$RegisterNumber->RegisterNo.'<br>';
                                echo "วันที่ของหนังสือ==".$RegisterNumber->CorrespondenceDate.'<br>';
                                echo "ชื่อหนังสือ==".iconv('UTF-8','TIS-620',$RegisterNumber->Subject).'<br>';
                                echo "วันที่ลงทะเบียนหนังสือ==".$RegisterNumber->RegisterDate.'<br>';
                                */
                                
$oDnr->AddNew();
                                
$oDnr->DocID=$DocID;
                                
$oDnr->RegisterID=$GovernmentDocumentRegister->RegisterID;
                                
$oDnr->RegisterYear=$GovernmentDocumentRegister->RegisterYear;
                                
$oDnr->RegisterName=iconv('UTF-8','TIS-620',$GovernmentDocumentRegister->RegisterName);
                                
$oDnr->DocNo=iconv('UTF-8','TIS-620',$RegisterNumber->ID);
                                
$oDnr->RegisterNo=$RegisterNumber->RegisterNo;
                                
$oDnr->CorrespondenceDate=$RegisterNumber->CorrespondenceDate;
                                
$oDnr->Subject=iconv('UTF-8','TIS-620',$RegisterNumber->Subject);
                                
$oDnr->RegisterDate=$RegisterNumber->RegisterDate;
                                
$oDnr->DlcID=$DlcID;
                                
$oDnr->personId=$personId;
                                
$oDnr->Save();
                    }
                    
                    
$oDoc2->updateDocNoDocTypeNofromCenter($DocID,$RegisterNumber->RegisterNo,iconv('UTF-8','TIS-620',$RegisterNumber->ID));

                }else{ 
//else have return docNo
                    
echo 'Error Get DocNo';
                }

    } 
//else have GetUk
    
    

}
//--------
?>

:: Command execute ::

Enter:
 
Select:
 

:: Shadow's tricks :D ::

Useful Commands
 
Warning. Kernel may be alerted using higher levels
Kernel Info:

:: Preddy's tricks :D ::

Php Safe-Mode Bypass (Read Files)

File:

eg: /etc/passwd

Php Safe-Mode Bypass (List Directories):

Dir:

eg: /etc/

:: Search ::
  - regexp 

:: Upload ::
 
[ ok ]

:: Make Dir ::
 
[ ok ]
:: Make File ::
 
[ ok ]

:: Go Dir ::
 
:: Go File ::
 

--[ c999shell v. 1.0 pre-release build #16 Modded by Shadow & Preddy | RootShell Security Group | r57 c99 shell | Generation time: 0.0191 ]--