Viewing file: processSendDoc.php (69.47 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;
$checkflagCommit= true;
$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();
}
//---main document
$oDoc2->SearchByKey($DocID);
$oDoc2->GetRecord();
$oRs4->SearchByDrsIDRegisterDoc($DrsID);
$oRs4->GetRecord();
$timesend=getNowDateTh()." ".date('H:i:s');
$checkupdate=0;
$checkupdate2=0;
$checkupdate3=0;
//-----------------send to Dept----------------------------------
//----send All deptId----------------------------------------------------------------
if($checkAll=="1"){ //send All deptId
if($maindept!=1){
$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!=''){
$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;
}
if($DocShowIn=="1" && $DocShowOut=="2"){
$addDocShowInOut="3";
}else{
if($DocShowIn=="1"){
$addDocShowInOut=$DocShowIn;
}else if($DocShowIn=="2"){
$addDocShowInOut=$DocShowIn;
}
}
$oDoc->DocShowInOut=$addDocShowInOut;
$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->PtID=$PtID;
//echo "PtID2=".$oRs2->PtID."<br>";
$oRs2->DrsReceiveDate=$timesend;
$oDlc->SearchByKey($oDoc->DlcID); $oDlc->GetRecord();
$oRs2->DrsReceivePersonId='';
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->AnID=$AnID;
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>";
//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->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;
}
if($DocShowIn=="1" && $DocShowOut=="2"){
$addDocShowInOut="3";
}else{
if($DocShowIn=="1"){
$addDocShowInOut=$DocShowIn;
}else if($DocShowIn=="2"){
$addDocShowInOut=$DocShowIn;
}
}
$oDoc->DocShowInOut=$addDocShowInOut;
$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->PtID=$PtID;
//echo "PtID2=".$oRs2->PtID."<br>";
$oRs2->DrsReceiveDate=$timesend;
$oDlc->SearchByKey($oDoc->DlcID); $oDlc->GetRecord();
$oRs2->DrsReceivePersonId='';
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->AnID=$AnID;
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);
//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->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;
}
if($DocShowIn=="1" && $DocShowOut=="2"){
$addDocShowInOut="3";
}else{
if($DocShowIn=="1"){
$addDocShowInOut=$DocShowIn;
}else if($DocShowIn=="2"){
$addDocShowInOut=$DocShowIn;
}
}
$oDoc->DocShowInOut=$addDocShowInOut;
$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->PtID=$PtID;
//echo "PtID2=".$oRs2->PtID."<br>";
$oRs2->DrsReceiveDate=$timesend;
$oDlc->SearchByKey($oDoc->DlcID); $oDlc->GetRecord();
$oRs2->DrsReceivePersonId='';
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->AnID=$AnID;
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->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;
}
if($DocShowIn=="1" && $DocShowOut=="2"){
$addDocShowInOut="3";
}else{
if($DocShowIn=="1"){
$addDocShowInOut=$DocShowIn;
}else if($DocShowIn=="2"){
$addDocShowInOut=$DocShowIn;
}
}
$oDoc->DocShowInOut=$addDocShowInOut;
$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->DrsReceiveDate=$timesend;
$oDlc->SearchByKey($oDoc->DlcID); $oDlc->GetRecord();
$oRs2->DrsReceivePersonId='';
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->AnID=$AnID;
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);
//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->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;
}
if($DocShowIn=="1" && $DocShowOut=="2"){
$addDocShowInOut="3";
}else{
if($DocShowIn=="1"){
$addDocShowInOut=$DocShowIn;
}else if($DocShowIn=="2"){
$addDocShowInOut=$DocShowIn;
}
}
$oDoc->DocShowInOut=$addDocShowInOut;
$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->PtID=$PtID;
//echo "PtID2=".$oRs2->PtID."<br>";
$oRs2->DrsReceiveDate=$timesend;
$oDlc->SearchByKey($oDoc->DlcID); $oDlc->GetRecord();
$oRs2->DrsReceivePersonId='';
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->AnID=$AnID;
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{ //--maindept=1
$oDPt2->RSDeptByMaxdeptDate2();
while($oDPt2->GetRecord()){
if($deptPs[$oDPt2->deptId]!=""){
$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>";
//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->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;
}
if($DocShowIn=="1" && $DocShowOut=="2"){
$addDocShowInOut="3";
}else{
if($DocShowIn=="1"){
$addDocShowInOut=$DocShowIn;
}else if($DocShowIn=="2"){
$addDocShowInOut=$DocShowIn;
}
}
$oDoc->DocShowInOut=$addDocShowInOut;
$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->PtID=$PtID;
//echo "PtID2=".$oRs2->PtID."<br>";
$oRs2->DrsReceiveDate=$timesend;
$oDlc->SearchByKey($oDoc->DlcID); $oDlc->GetRecord();
$oRs2->DrsReceivePersonId='';
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->AnID=$AnID;
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; }
}
} //loop dept
}
}else{
//----not send All deptId----------------------------------------------------------------
//--case not maindept
if($maindept!=1){
$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>";
//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->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;
}
if($DocShowIn=="1" && $DocShowOut=="2"){
$addDocShowInOut="3";
}else{
if($DocShowIn=="1"){
$addDocShowInOut=$DocShowIn;
}else if($DocShowIn=="2"){
$addDocShowInOut=$DocShowIn;
}
}
$oDoc->DocShowInOut=$addDocShowInOut;
$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->PtID=$PtID;
//echo "PtID2=".$oRs2->PtID."<br>";
$oRs2->DrsReceiveDate=$timesend;
$oDlc->SearchByKey($oDoc->DlcID); $oDlc->GetRecord();
$oRs2->DrsReceivePersonId='';
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->AnID=$AnID;
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);
//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;
}
if($DocShowIn=="1" && $DocShowOut=="2"){
$addDocShowInOut="3";
}else{
if($DocShowIn=="1"){
$addDocShowInOut=$DocShowIn;
}else if($DocShowIn=="2"){
$addDocShowInOut=$DocShowIn;
}
}
$oDoc->DocShowInOut=$addDocShowInOut;
$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->PtID=$PtID;
//echo "PtID2=".$oRs2->PtID."<br>";
$oRs2->DrsReceiveDate=$timesend;
$oDlc->SearchByKey($oDoc->DlcID); $oDlc->GetRecord();
$oRs2->DrsReceivePersonId='';
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->AnID=$AnID;
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->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->DrsReceiveDate=$timesend;
$oDlc->SearchByKey($oDoc->DlcID); $oDlc->GetRecord();
$oRs2->DrsReceivePersonId='';
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->AnID=$AnID;
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->PtID=$PtID;
//echo "PtID2=".$oRs2->PtID."<br>";
$oRs2->DrsReceiveDate=$timesend;
$oDlc->SearchByKey($oDoc->DlcID); $oDlc->GetRecord();
$oRs2->DrsReceivePersonId='';
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->AnID=$AnID;
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->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;
}
if($DocShowIn=="1" && $DocShowOut=="2"){
$addDocShowInOut="3";
}else{
if($DocShowIn=="1"){
$addDocShowInOut=$DocShowIn;
}else if($DocShowIn=="2"){
$addDocShowInOut=$DocShowIn;
}
}
$oDoc->DocShowInOut=$addDocShowInOut;
$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->PtID=$PtID;
//echo "PtID2=".$oRs2->PtID."<br>";
$oRs2->DrsReceiveDate=$timesend;
$oDlc->SearchByKey($oDoc->DlcID); $oDlc->GetRecord();
$oRs2->DrsReceivePersonId='';
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->AnID=$AnID;
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{ //---case main dept
$oDPt2->RSDeptByMaxdeptDate2();
while($oDPt2->GetRecord()){
if($deptPs[$oDPt2->deptId]!=""){
$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;
}
if($DocShowIn=="1" && $DocShowOut=="2"){
$addDocShowInOut="3";
}else{
if($DocShowIn=="1"){
$addDocShowInOut=$DocShowIn;
}else if($DocShowIn=="2"){
$addDocShowInOut=$DocShowIn;
}
}
$oDoc->DocShowInOut=$addDocShowInOut;
$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='';
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->AnID=$AnID;
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; }
}
} //loop dept
} //end case check main dept
} //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;
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;
if($mainPsselect==$oPS2->personId && ($PtID!=1 && $PtID!=2 && $PtID!=6)){ $DrsMainPs="Y"; }else{ $DrsMainPs=""; }
$oRs1->DrsMainPs=$DrsMainPs;
//echo "DrsMainPs=".$DrsMainPs."<br>";
$oRs1->AnID=$AnID;
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;
if($checkDocSpeedDate=="Y"){ $speedDate=splitDateForm($DocSpeedLevelDueDate,"/"); }else{ $speedDate=$DrsDocDueDate; }
$oRs1->DrsDocDueDate=$speedDate;
$oRs1->DrsDlcIDCreate=$DlcIDlogin;
$oRs1->DrsPsIDCreate=$personId;
$oRs1->DrsPropose=$DrsSend;
$oRs1->DrsFromDrsID=$oRs4->DrsID;
$oRs1->DocGroup=$DocGroup;
if($mainPsselect==$oPS2->personId && ($PtID!=1 && $PtID!=2 && $PtID!=6)){ $DrsMainPs="Y"; }else{ $DrsMainPs=""; }
$oRs1->DrsMainPs=$DrsMainPs;
//echo "DrsMainPs=".$DrsMainPs."<br>";
$oRs1->AnID=$AnID;
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;
if($checkDocSpeedDate=="Y"){ $speedDate=splitDateForm($DocSpeedLevelDueDate,"/"); }else{ $speedDate=$DrsDocDueDate; }
$oRs1->DrsDocDueDate=$speedDate;
$oRs1->DrsDlcIDCreate=$DlcIDlogin;
$oRs1->DrsPsIDCreate=$personId;
$oRs1->DrsPropose=$DrsSend;
$oRs1->DrsFromDrsID=$oRs4->DrsID;
$oRs1->DocGroup=$DocGroup;;
if($mainPsselect==$oPSd->personId && ($PtID!=1 && $PtID!=2 && $PtID!=6)){ $DrsMainPs="Y"; }else{ $DrsMainPs=""; }
$oRs1->DrsMainPs=$DrsMainPs;
//echo "DrsMainPs=".$DrsMainPs."<br>";
$oRs1->AnID=$AnID;
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++;
}
}
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;
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->DrsSendToPs="Y";
$oRs5->AnID=$AnID;
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; }
$checkupdate3++;
//echo 'ddddddd';
}
}
//echo "1=".$checkupdate."2=".$checkupdate2."<br>";
if($checkupdate!="0" || $checkupdate2!="0" || ($checkupdate3!="0" && $showsendtops=="Y")){
//------------------update RSdoc status=3
$oRs->SearchByKey($DrsID);
//echo "update RSdoc status=3<br>";
//echo "DrsID_edit=".$DrsID."<br>";
$oRs->GetRecord();
$oRs->Edit();
$oRs->PtID=$PtID;
$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->AnID=$AnID;
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" || ($checkupdate3!="0" && $showsendtops=="Y")){
//echo "update RSdoc status=3<br>";
$oDoc3->SearchByKey($DocID);
$oDoc3->GetRecord();
$oDoc3->Edit();
$oDoc3->PtID=$PtID;
//echo "PtID=".$oDoc3->PtID."<br>";
if($checkDocSpeedDate=="Y"){ $speedDate=splitDateForm($DocSpeedLevelDueDate,"/"); }else{ $speedDate=$oDoc3->DocSpeedLevelDueDate; }
$oDoc3->DocSpeedLevelDueDate=$speedDate;
//echo "DocSpeedLevelDueDate=".$oDoc3->DocSpeedLevelDueDate."<br>";
$oDoc3->AnID=$AnID;
//echo "AnID=".$oDoc3->AnID."<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>";
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->Save();
// if(!$checkflagCommit){ $flagCommit=$checkflagCommit; echo "grtgtg"; }
}
$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'>";
}
}
?>
|