Viewing file:      processReceiveDocSR.php (10.9 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 "../link/function.php"; include_once "../link/functionshow.php"; include_once "funct.php"; include_once "../class/clsSendReceive.php"; include_once "../class/clsDocLineConfig.php"; include_once "../class/clsDepartment.php"; include_once "../class/clsDocType.php"; include_once "../class/clsDocuments.php"; include_once "../class/clsDocReceiveSend.php"; include_once "../class/clsRunningDoc.php"; include_once "../class/clsDocattatches.php"; include_once "../class/clsSysConfig.php"; include_once "../class/clsCollegeDetail.php"; include_once "../class/clsSendNewDocSR.php";
  $oC = new clsConnection($GLOBALS['DBHOST'], $GLOBALS['DBNAME_EOFFICE'], $GLOBALS['DBUSER_EOFFICE'], $GLOBALS['DBPASS_EOFFICE']);
  $oTsr = new sendreceive($oC); $oTsre = new sendreceive($oC); $oDlc = new DocLineConfig($oC); $oDP = new Department($oC); $oDt1 = new doctype($oC); $oDoc = new Documents($oC); $oRs = new DocReceiveSend($oC); $oRs2 = new DocReceiveSend($oC); $oRd = new runningdoc($oC); $oDatt = new Docattatches($oC); $oDatt2 = new Docattatches($oC); $oDatt3 = new Docattatches($oC); $oDatt1 = new Docattatches($oC); $oSys = new sysConfig($oC); $oCd = new collegedetail($oC); $oSn = new sendnewdocsr($oC); $oSn2 = new sendnewdocsr($oC);
 
  $oDlc->SearchByKey($DlcID); $oDlc->GetRecord();  $oSys->SearchByKey($free); $oSys->GetRecord();
  $MaxDocGroup=$oDP->SearchMaxDocGroup();
  //print_r($_REQUEST); exit;
  if($p=="0"){           $timesend=getNowDateTh()." ".date('H:i:s');          $oTsr->SearchByKey($tsr_id);     $oTsr->GetRecord();
      if($oTsr->tsr_receive==""){  //case receive normal             $oTsr->Edit();         $oTsr->tsr_DlcID=$DlcID;         $oTsr->tsr_personId=$personId;         $oTsr->tsr_receive='N';         $oTsr->tsr_receivedate=$timesend;         $oTsr->Save();                      if($oTsr->tsr_fr_node==99){                          $folder=$GLOBALS["FOLDERFORSEND1"];                 }else if($oTsr->tsr_fr_node==8){                          $folder=$GLOBALS["FOLDERFORSEND3"];                  }else{                          $folder=$GLOBALS["FOLDERFORSEND2"];                  }                 $oCd->SearchByKey($oTsr->tsr_fr_node);                 $oCd->GetRecord();                      $tsr_receivedate=str_replace (' ','_',$oTsr->tsr_receivedate);                             $msg='?fn=setreceive&tsr_id='.$oTsr->tsr_id_send.'&tsr_fr_node='.$oTsr->tsr_fr_node.'&tsr_receive='.$oTsr->tsr_receive.'&tsr_receivedate='.$tsr_receivedate;                     $path_send='http://'.$oCd->collegeHost.'/'.$folder.'/'.'eoffice/admin/sendTSR.php'.$msg;                  $res=file_get_contents($path_send);      }                 echo "<meta http-equiv='refresh' content='0; URL=sendReceiveDoc_c.php?flagshow=1&page_id=$page_id'>"; }else if($p=="2"){              $timesend=getNowDateTh()." ".date('H:i:s');          $oTsr->SearchByKey($tsr_id);     $oTsr->GetRecord();
      if($oTsr->tsr_receive==""){  //case receive normal             $oTsr->Edit();         $oTsr->tsr_DlcID=$DlcID;         $oTsr->tsr_personId=$personId;         $oTsr->tsr_receive='R';         $oTsr->tsr_receivedate=$timesend;         $oTsr->Save();                      if($oTsr->tsr_fr_node==99){                          $folder=$GLOBALS["FOLDERFORSEND1"];                 }else if($oTsr->tsr_fr_node==8){                          $folder=$GLOBALS["FOLDERFORSEND3"];                  }else{                          $folder=$GLOBALS["FOLDERFORSEND2"];                  }                 $oCd->SearchByKey($oTsr->tsr_fr_node);                 $oCd->GetRecord();                      $tsr_receivedate=str_replace (' ','_',$oTsr->tsr_receivedate);                             $msg='?fn=setreceive&tsr_id='.$oTsr->tsr_id_send.'&tsr_fr_node='.$oTsr->tsr_fr_node.'&tsr_receive='.$oTsr->tsr_receive.'&tsr_receivedate='.$tsr_receivedate;                     $path_send='http://'.$oCd->collegeHost.'/'.$folder.'/'.'eoffice/admin/sendTSR.php'.$msg;                  $res=file_get_contents($path_send);      }                 echo "<meta http-equiv='refresh' content='0; URL=sendReceiveDoc_c.php?flagshow=1&page_id=$page_id'>"; }else if($p=="1"){
      $oTsr->SearchByKey($tsr_id);     $oTsr->GetRecord();          if($oTsr->tsr_receive==""){  //case receive normal                               $flagCommit = true;         $checkflagCommit= true;                  $timesend=getNowDateTh()." ".date('H:i:s');                  //    echo "$oC <pre>";  print_r($oC);  exit;                  $oTsr->Edit();         $oTsr->tsr_DlcID=$DlcID;         $oTsr->tsr_personId=$personId;         $oTsr->tsr_receive='Y';         $oTsr->tsr_receivedate=$timesend;     //print_r($oTsr); exit;     //echo '----------------'.$tsr_doc_url=$oTsr->tsr_doc_url;         $tsr_doc_url=$oTsr->tsr_doc_url;         $tsr_doc_chksum=$oTsr->tsr_doc_chksum;         $tsr_fr_node=$oTsr->tsr_fr_node;         $tsr_docname=$oTsr->tsr_docname;         $tsr_statusDocAtt=$oTsr->tsr_statusDocAtt;         $countstatusDocAtt=strlen($tsr_statusDocAtt);                  $checkflagCommit = $oTsr->Save();                           //$oC->BeginTrans();         if(!$checkflagCommit){ $flagCommit=$checkflagCommit;   }              $oDlc->SearchByKey($DlcID); $oDlc->GetRecord();                   //--runing number         $rd=ShowRunningDoc(1,$oTsr->tsr_DtID,$oDlc->deptId);          $max_DocTypeNo = getMaxDocTypeNo($DlcID);         $rd = ($rd>1) ? $rd : $max_DocTypeNo;                     //--------------add documents                     $oDoc->AddNew();                     $oDoc->DocID=$oDoc->GetNextCode();                     $e=$oDoc->GetNextCode();                     $oDoc->DlcID=$DlcID;                     //$oDoc->DtID=$oTsr->tsr_DtID;                             $oDoc->DtID=1;        // Force set status = 1                     $oDoc->DslID=$oTsr->tsr_DslID;                     $oDoc->DclID=$oTsr->tsr_DclID;                     $oDoc->DsID=1;                     $oDoc->RsID=1;                     $oDoc->DocDateCreate=$timesend;                     $oDoc->DocUserCreate=$personId;                     $oDoc->DocTypeNo=$rd;                     $oDoc->DocDate=$oTsr->tsr_DocDate;                     $oDoc->DocNo=$oTsr->tsr_DocNo;                     $oDoc->DocSubject=$oTsr->tsr_DocSubject;                     $oDoc->DocFrom=$oTsr->tsr_DocFrom;                     $oDoc->DocTo=$oTsr->tsr_DocTo;                     $oDoc->DocShortDesc=$oTsr->tsr_DocShortDesc;                     $oDoc->DocGroup=$MaxDocGroup;                     $oDoc->DocRef=$oTsr->tsr_DocRef;                     $oDoc->DocOther=$oTsr->tsr_DocOther;                     $oDoc->eDoc='Y';                     $oDoc->DocTelOwner=$oTsr->tsr_DocTelOwner;                     $oDoc->DocSendReal=$oTsr->tsr_DocSendReal;                     $oDoc->DocDeptOwner=$oTsr->tsr_DocDeptOwner;                     $oDoc->DocFaxOwner=$oTsr->tsr_DocFaxOwner;                     $oDoc->DocCopySend=$oTsr->tsr_DocCopySend;                     $oDoc->DocContactE=$oTsr->tsr_DocContactE;                     $oDoc->Doc_tsr_id=$oTsr->tsr_id;                     $checkflagCommit = $oDoc->Save();                     //$oC->BeginTrans();                     if(!$checkflagCommit){ $flagCommit=$checkflagCommit;   }                              //---------------add DocReceiveSend                     $oRs->AddNew();                     $oRs->DrsID=$oRs->GetNextCode();                     $oRs->DocID=$e;                     $oRs->DlcID=$DlcID;                     $oRs->DsID=1;                     $oRs->personId=0;                     $oRs->PtID=$oRs->PtID;                     $oRs->DrsDocTypeNo=$rd;                     $oRs->DrsReceiveDate=$timesend;                     $oRs->DrsReceivePersonId=$personId;                     $oRs->DrsDlcIDCreate=$DlcID;                     $oRs->DrsPsIDCreate=$personId;                     $oRs->DocGroup=$MaxDocGroup;                     $oRs->AnID=$oRs->AnID;                         $checkflagCommit = $oRs->Save();                     if(!$checkflagCommit){ $flagCommit=$checkflagCommit;   }                                                                   //--------update running doc                     //receiveOut                                  if(($oTsr->tsr_DtID=="1" || $oTsr->tsr_DtID=="2" || $oTsr->tsr_DtID=="3" || $oTsr->tsr_DtID=="14" || $oTsr->tsr_DtID=="15") && ($oSys->useDocTypeNoMix=='N')){                                 $oRd->SearchRunningBydocGroupDtIDfunctDeptdocNoMixN2($MaxDocGroup,$oTsr->tsr_DtID,$oDlc->deptId);                                 $oRd->GetRecord();                                     }else{                                 $oRd->SearchRunningBydocGroupDtIDfunctdocNoMixY2($MaxDocGroup,$oTsr->tsr_DtID);                                 $oRd->GetRecord();                                     }                             $oRd->Edit();                             $oRd->receiveNo=$rd;                             $checkflagCommit = $oRd->Save();                             if(!$checkflagCommit){ $flagCommit=$checkflagCommit;   }                                                               //----Get Doctmp to Documents                     $i=0;                     while($tsr_doc_url!=''){                             list($downloadurl,$tsr_doc_url)=preg_split('[,]',$tsr_doc_url,2);                             list($downloadfilename,$tsr_docname)=preg_split('[,]',$tsr_docname,2);                             list($downloadchksum,$tsr_doc_chksum)=preg_split('[,]',$tsr_doc_chksum,2);                                  $i++;                             if($countstatusDocAtt!=$i){                                 $checksDocAtt = substr($tsr_statusDocAtt,$i-1,-($countstatusDocAtt-1-($i-1)));                             }else{                                 $checksDocAtt = substr($tsr_statusDocAtt,$countstatusDocAtt-1);                             }                                                          if($checksDocAtt!='N'){                                                              $file_name = basename($downloadurl);                                  list($filename_,$filetype_)=preg_split("/\./",$file_name);                                 $pathfile=$GLOBALS['path_upload_documentsTmp'].$filename_.'-'.$tsr_fr_node.'.'.$filetype_;                                  $tempfile = $GLOBALS['path_upload_documents'].$filename_.'-'.$tsr_fr_node.'.'.$filetype_;                                                               copy($pathfile,$tempfile);                                         //----search DaSeq of DocID                                         $MaxDaSeq=$oDatt1->SearchMaxDaSeqDocID($oDoc->DocID);                                         $oDatt->AddNew();                                         $oDatt->DaID=$oDatt->GetNextCode();                                         $oDatt->DocID=$oDoc->DocID;                                         $oDatt->DaFileName=$downloadfilename;                                         $oDatt->DaUpFileName=$filename_.'-'.$tsr_fr_node.'.'.$filetype_;                                                                                   if($oDatt3->SearchByDaSeqCount0($oDoc->DocID)==0){                                             $oDatt->DaSeq=$MaxDaSeq+1;                                         }else{                                             $oDatt->DaSeq=0;                                         }                                         $checkflagCommit = $oDatt->Save();                                         if(!$checkflagCommit){ $flagCommit=$checkflagCommit;   }                             }                     }                     //------------------------                                 if($flagCommit){                 if($oTsr->tsr_fr_node==99){                          $folder=$GLOBALS["FOLDERFORSEND1"];                 }else if($oTsr->tsr_fr_node==8){                          $folder=$GLOBALS["FOLDERFORSEND3"];                  }else{                          $folder=$GLOBALS["FOLDERFORSEND2"];                  }                 $oCd->SearchByKey($oTsr->tsr_fr_node);                 $oCd->GetRecord();                                      $tsr_receivedate=str_replace (' ','_',$oTsr->tsr_receivedate);                             $msg='?fn=setreceive&tsr_id='.$oTsr->tsr_id_send.'&tsr_fr_node='.$oTsr->tsr_fr_node.'&tsr_receive='.$oTsr->tsr_receive.'&tsr_receivedate='.$tsr_receivedate;                     $path_send='http://'.$oCd->collegeHost.'/'.$folder.'/'.'eoffice/admin/sendTSR.php'.$msg;                  $res=file_get_contents($path_send);          }                  /*if($flagCommit){             $oC->CommitTrans();         }else{              $oC->RollbackTrans();         }*/         echo "<meta http-equiv='refresh' content='0; URL=regisDoc.php?RsID=1&DtID=$oTsr->tsr_DtID'>";     }else{         echo "<meta http-equiv='refresh' content='0; URL=sendReceiveDoc_c.php?flagshow=1&page_id=$page_id'>";     } }else if($p=="new"){         $timesend=getNowDateTh()." ".date('H:i:s');    
      $oSn->SearchByKey($sn_id);     $oSn->GetRecord();        
          $oSn->Edit();         $oSn->sn_receive='Y';         $oSn->sn_receivedate=$timesend;         $oSn->Save();
 
                                  $file_name = basename($oSn->sn_doc_url);                                  list($filename_,$filetype_)=preg_split("/\./",$file_name);                                 list($filetype_,$cc)=preg_split('[,]',$filetype_,2);                                 $pathfile=$GLOBALS['path_upload_documentsTmp'].$filename_.'-'.$oSn->sn_fr_node.'.'.$filetype_;                                  $tempfile = $GLOBALS['path_upload_documents'].$filename_.'-'.$oSn->sn_fr_node.'.'.$filetype_;                                                               copy($pathfile,$tempfile);                                         //----search DaSeq of DocID
 
                                  $oTsr->SearchBytsr_id_send_tsr_fr_node($oSn->sn_tsr_id_send,$oSn->sn_fr_node);                                 $oTsr->GetRecord();                                                                  $DocID=$oDoc->SearchDocIDDoc_tsr_id($oSn->sn_tsr_id_send);
 
                                          $oDatt->AddNew();                                         $oDatt->DaID=$oDatt->GetNextCode();                                         $oDatt->DocID=$DocID;                                         $oDatt->DaFileName=$oSn->sn_docname;                                         $oDatt->DaUpFileName=$filename_.'-'.$oSn->sn_fr_node.'.'.$filetype_;                                          $oDatt->DaAddNewSended='Y';                                         $oDatt->Save();
          echo "<meta http-equiv='refresh' content='0; URL=downloadNewSendDoc.php'>"; } ?>
  |