$lastVersion = $oAppDocument->getLastAppDocVersion($_GET['DOC'], $_SESSION['APPLICATION']); $aFields = $oAppDocument->load($_GET['DOC'], $lastVersion); $listing = false; $oPluginRegistry =& PMPluginRegistry::getSingleton(); if ($oPluginRegistry->existsTrigger(PM_CASE_DOCUMENT_LIST)) { $folderData = new folderData(null, null, $_SESSION['APPLICATION'], null, $_SESSION['USER_LOGGED']); $folderData->PMType = "OUTPUT"; $folderData->returnList = true; $listing = $oPluginRegistry->executeTriggers(PM_CASE_DOCUMENT_LIST, $folderData); } require_once 'classes/model/OutputDocument.php'; $oOutputDocument = new OutputDocument(); $aGields = $oOutputDocument->load($aFields['DOC_UID']); if (isset($aGields['OUT_DOC_VERSIONING']) && $aGields['OUT_DOC_VERSIONING'] != 0) { $oAppDocument = new AppDocument(); $lastDocVersion = $oAppDocument->getLastDocVersion($_GET['UID'], $_SESSION['APPLICATION']); } else { $lastDocVersion = ''; } $aFields['VIEW1'] = G::LoadTranslation('ID_OPEN'); $aFields['VIEW2'] = G::LoadTranslation('ID_OPEN'); $aFields['FILE1'] = 'cases_ShowOutputDocument?a=' . $aFields['APP_DOC_UID'] . '&v=' . $lastDocVersion . '&ext=doc&random=' . rand() . '&PHPSESSID=' . @session_id(); $aFields['FILE2'] = 'cases_ShowOutputDocument?a=' . $aFields['APP_DOC_UID'] . '&v=' . $lastDocVersion . '&ext=pdf&random=' . rand() . '&PHPSESSID=' . @session_id(); if (is_array($listing)) { //If exist in Plugin Document List foreach ($listing as $folderitem) { if ($folderitem->filename == $aFields['APP_DOC_UID'] && $folderitem->type == 'DOC') { $aFields['VIEW1'] = G::LoadTranslation('ID_GET_EXTERNAL_FILE'); $aFields['FILE1'] = $folderitem->downloadScript; continue; }
public function getAllGeneratedDocumentsCriteria($sProcessUID, $sApplicationUID, $sTasKUID, $sUserUID) { G::LoadClass("configuration"); $conf = new Configurations(); $confEnvSetting = $conf->getFormats(); //verifica si la tabla OBJECT_PERMISSION $this->verifyTable(); $listing = false; $oPluginRegistry = & PMPluginRegistry::getSingleton(); if ($oPluginRegistry->existsTrigger(PM_CASE_DOCUMENT_LIST)) { $folderData = new folderData(null, null, $sApplicationUID, null, $sUserUID); $folderData->PMType = "OUTPUT"; $folderData->returnList = true; //$oPluginRegistry = & PMPluginRegistry::getSingleton(); $listing = $oPluginRegistry->executeTriggers(PM_CASE_DOCUMENT_LIST, $folderData); } $aObjectPermissions = $this->getAllObjects($sProcessUID, $sApplicationUID, $sTasKUID, $sUserUID); if (!is_array($aObjectPermissions)) { $aObjectPermissions = array( 'DYNAFORMS' => array(-1), 'INPUT_DOCUMENTS' => array(-1), 'OUTPUT_DOCUMENTS' => array(-1) ); } if (!isset($aObjectPermissions['DYNAFORMS'])) { $aObjectPermissions['DYNAFORMS'] = array(-1); } else { if (!is_array($aObjectPermissions['DYNAFORMS'])) { $aObjectPermissions['DYNAFORMS'] = array(-1); } } if (!isset($aObjectPermissions['INPUT_DOCUMENTS'])) { $aObjectPermissions['INPUT_DOCUMENTS'] = array(-1); } else { if (!is_array($aObjectPermissions['INPUT_DOCUMENTS'])) { $aObjectPermissions['INPUT_DOCUMENTS'] = array(-1); } } if (!isset($aObjectPermissions['OUTPUT_DOCUMENTS'])) { $aObjectPermissions['OUTPUT_DOCUMENTS'] = array(-1); } else { if (!is_array($aObjectPermissions['OUTPUT_DOCUMENTS'])) { $aObjectPermissions['OUTPUT_DOCUMENTS'] = array(-1); } } $aDelete = $this->getAllObjectsFrom($sProcessUID, $sApplicationUID, $sTasKUID, $sUserUID, 'DELETE'); $oAppDocument = new AppDocument(); $oCriteria = new Criteria('workflow'); $oCriteria->add(AppDocumentPeer::APP_UID, $sApplicationUID); $oCriteria->add(AppDocumentPeer::APP_DOC_TYPE, 'OUTPUT'); $oCriteria->add(AppDocumentPeer::APP_DOC_STATUS, array('ACTIVE'), Criteria::IN); //$oCriteria->add(AppDocumentPeer::APP_DOC_UID, $aObjectPermissions['OUTPUT_DOCUMENTS'], Criteria::IN); $oCriteria->add( $oCriteria->getNewCriterion( AppDocumentPeer::APP_DOC_UID, $aObjectPermissions['OUTPUT_DOCUMENTS'], Criteria::IN)->addOr($oCriteria->getNewCriterion(AppDocumentPeer::USR_UID, $sUserUID, Criteria::EQUAL)) ); $aConditions = array(); $aConditions[] = array(AppDocumentPeer::APP_UID, AppDelegationPeer::APP_UID); $aConditions[] = array(AppDocumentPeer::DEL_INDEX, AppDelegationPeer::DEL_INDEX); $oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN); $oCriteria->add(AppDelegationPeer::PRO_UID, $sProcessUID); $oCriteria->addAscendingOrderByColumn(AppDocumentPeer::APP_DOC_INDEX); $oDataset = AppDocumentPeer::doSelectRS($oCriteria); $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); $aOutputDocuments = array(); $aOutputDocuments[] = array( 'APP_DOC_UID' => 'char', 'DOC_UID' => 'char', 'APP_DOC_COMMENT' => 'char', 'APP_DOC_FILENAME' => 'char', 'APP_DOC_INDEX' => 'integer' ); $oUser = new Users(); while ($aRow = $oDataset->getRow()) { $oCriteria2 = new Criteria('workflow'); $oCriteria2->add(AppDelegationPeer::APP_UID, $sApplicationUID); $oCriteria2->add(AppDelegationPeer::DEL_INDEX, $aRow['DEL_INDEX']); $oDataset2 = AppDelegationPeer::doSelectRS($oCriteria2); $oDataset2->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset2->next(); $aRow2 = $oDataset2->getRow(); $oTask = new Task(); if ($oTask->taskExists($aRow2['TAS_UID'])) { $aTask = $oTask->load($aRow2['TAS_UID']); } else { $aTask = array('TAS_TITLE' => '(TASK DELETED)'); } $lastVersion = $oAppDocument->getLastDocVersion($aRow['DOC_UID'], $sApplicationUID); if ($lastVersion == $aRow['DOC_VERSION']) { //Only show last document Version $aAux = $oAppDocument->load($aRow['APP_DOC_UID'], $aRow['DOC_VERSION']); //Get output Document information $oOutputDocument = new OutputDocument(); $aGields = $oOutputDocument->load($aRow['DOC_UID']); //OUTPUTDOCUMENT $outDocTitle = $aGields['OUT_DOC_TITLE']; switch ($aGields['OUT_DOC_GENERATE']) { //G::LoadTranslation(ID_DOWNLOAD) case "PDF": $fileDoc = 'javascript:alert("NO DOC")'; $fileDocLabel = " "; $filePdf = 'cases_ShowOutputDocument?a=' . $aRow['APP_DOC_UID'] . '&v=' . $aRow['DOC_VERSION'] . '&ext=pdf&random=' . rand(); $filePdfLabel = ".pdf"; if (is_array($listing)) { foreach ($listing as $folderitem) { if (($folderitem->filename == $aRow['APP_DOC_UID']) && ($folderitem->type == "PDF")) { $filePdfLabel = G::LoadTranslation('ID_GET_EXTERNAL_FILE') . " .pdf"; $filePdf = $folderitem->downloadScript; continue; } } } break; case "DOC": $fileDoc = 'cases_ShowOutputDocument?a=' . $aRow['APP_DOC_UID'] . '&v=' . $aRow['DOC_VERSION'] . '&ext=doc&random=' . rand(); $fileDocLabel = ".doc"; $filePdf = 'javascript:alert("NO PDF")'; $filePdfLabel = " "; if (is_array($listing)) { foreach ($listing as $folderitem) { if (($folderitem->filename == $aRow['APP_DOC_UID']) && ($folderitem->type == "DOC")) { $fileDocLabel = G::LoadTranslation('ID_GET_EXTERNAL_FILE') . " .doc"; $fileDoc = $folderitem->downloadScript; continue; } } } break; case "BOTH": $fileDoc = 'cases_ShowOutputDocument?a=' . $aRow['APP_DOC_UID'] . '&v=' . $aRow['DOC_VERSION'] . '&ext=doc&random=' . rand(); $fileDocLabel = ".doc"; if (is_array($listing)) { foreach ($listing as $folderitem) { if (($folderitem->filename == $aRow['APP_DOC_UID']) && ($folderitem->type == "DOC")) { $fileDocLabel = G::LoadTranslation('ID_GET_EXTERNAL_FILE') . " .doc"; $fileDoc = $folderitem->downloadScript; continue; } } } $filePdf = 'cases_ShowOutputDocument?a=' . $aRow['APP_DOC_UID'] . '&v=' . $aRow['DOC_VERSION'] . '&ext=pdf&random=' . rand(); $filePdfLabel = ".pdf"; if (is_array($listing)) { foreach ($listing as $folderitem) { if (($folderitem->filename == $aRow['APP_DOC_UID']) && ($folderitem->type == "PDF")) { $filePdfLabel = G::LoadTranslation('ID_GET_EXTERNAL_FILE') . " .pdf"; $filePdf = $folderitem->downloadScript; continue; } } } break; } try { $aAux1 = $oUser->load($aAux['USR_UID']); $sUser = $conf->usersNameFormatBySetParameters($confEnvSetting["format"], $aAux1["USR_USERNAME"], $aAux1["USR_FIRSTNAME"], $aAux1["USR_LASTNAME"]); } catch (Exception $oException) { $sUser = '******'; } //if both documents were generated, we choose the pdf one, only if doc was //generate then choose the doc file. $firstDocLink = $filePdf; $firstDocLabel = $filePdfLabel; if ($aGields['OUT_DOC_GENERATE'] == 'DOC') { $firstDocLink = $fileDoc; $firstDocLabel = $fileDocLabel; } $aFields = array( 'APP_DOC_UID' => $aAux['APP_DOC_UID'], 'DOC_UID' => $aAux['DOC_UID'], 'APP_DOC_COMMENT' => $aAux['APP_DOC_COMMENT'], 'APP_DOC_FILENAME' => $aAux['APP_DOC_FILENAME'], 'APP_DOC_INDEX' => $aAux['APP_DOC_INDEX'], 'ORIGIN' => $aTask['TAS_TITLE'], 'CREATE_DATE' => $aAux['APP_DOC_CREATE_DATE'], 'CREATED_BY' => $sUser, 'FILEDOC' => $fileDoc, 'FILEPDF' => $filePdf, 'OUTDOCTITLE' => $outDocTitle, 'DOC_VERSION' => $aAux['DOC_VERSION'], 'TYPE' => $aAux['APP_DOC_TYPE'] . ' ' . $aGields['OUT_DOC_GENERATE'], 'DOWNLOAD_LINK' => $firstDocLink, 'DOWNLOAD_FILE' => $aAux['APP_DOC_FILENAME'] . $firstDocLabel ); if (trim($fileDocLabel) != '') { $aFields['FILEDOCLABEL'] = $fileDocLabel; } if (trim($filePdfLabel) != '') { $aFields['FILEPDFLABEL'] = $filePdfLabel; } if ($aFields['APP_DOC_FILENAME'] != '') { $aFields['TITLE'] = $aFields['APP_DOC_FILENAME']; } else { $aFields['TITLE'] = $aFields['APP_DOC_COMMENT']; } $aFields['POSITION'] = $_SESSION['STEP_POSITION']; $aFields['CONFIRM'] = G::LoadTranslation('ID_CONFIRM_DELETE_ELEMENT'); if (in_array($aRow['APP_DOC_UID'], $aObjectPermissions['OUTPUT_DOCUMENTS'])) { if (in_array($aRow['APP_DOC_UID'], $aDelete['OUTPUT_DOCUMENTS'])) { $aFields['ID_DELETE'] = G::LoadTranslation('ID_DELETE'); } } $aOutputDocuments[] = $aFields; } $oDataset->next(); } global $_DBArray; $_DBArray['outputDocuments'] = $aOutputDocuments; $_SESSION['_DBArray'] = $_DBArray; G::LoadClass('ArrayPeer'); $oCriteria = new Criteria('dbarray'); $oCriteria->setDBArrayTable('outputDocuments'); $oCriteria->addDescendingOrderByColumn('CREATE_DATE'); return $oCriteria; }
/** * Get data of Cases OutputDocument * * @param string $applicationUid * @param string $outputDocumentUid * @param string $userUid * * return object Return an object with data of an OutputDocument */ public function addCasesOutputDocument($applicationUid, $outputDocumentUid, $userUid) { try { $sApplication = $applicationUid; $index = \AppDelegation::getCurrentIndex($applicationUid); $sUserLogged = $userUid; $outputID = $outputDocumentUid; $g = new \G(); $g->sessionVarSave(); \G::LoadClass( 'case' ); $oCase = new \Cases(); $oCase->thisIsTheCurrentUser( $sApplication, $index, $sUserLogged, '', 'casesListExtJs' ); //require_once 'classes/model/OutputDocument.php'; $oOutputDocument = new \OutputDocument(); $aOD = $oOutputDocument->load( $outputID ); $Fields = $oCase->loadCase( $sApplication ); $sFilename = preg_replace( '[^A-Za-z0-9_]', '_', \G::replaceDataField( $aOD['OUT_DOC_FILENAME'], $Fields['APP_DATA'] ) ); require_once (PATH_TRUNK . "workflow" . PATH_SEP . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "AppFolder.php"); require_once (PATH_TRUNK . "workflow" . PATH_SEP . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "AppDocument.php"); //Get the Custom Folder ID (create if necessary) $oFolder = new \AppFolder(); $folderId = $oFolder->createFromPath( $aOD['OUT_DOC_DESTINATION_PATH'], $sApplication ); //Tags $fileTags = $oFolder->parseTags( $aOD['OUT_DOC_TAGS'], $sApplication ); //Get last Document Version and apply versioning if is enabled $oAppDocument = new \AppDocument(); $lastDocVersion = $oAppDocument->getLastDocVersion( $outputID, $sApplication ); $oCriteria = new \Criteria( 'workflow' ); $oCriteria->add( \AppDocumentPeer::APP_UID, $sApplication ); $oCriteria->add( \AppDocumentPeer::DOC_UID, $outputID ); $oCriteria->add( \AppDocumentPeer::DOC_VERSION, $lastDocVersion ); $oCriteria->add( \AppDocumentPeer::APP_DOC_TYPE, 'OUTPUT' ); $oDataset = \AppDocumentPeer::doSelectRS( $oCriteria ); $oDataset->setFetchmode( \ResultSet::FETCHMODE_ASSOC ); $oDataset->next(); if (($aOD['OUT_DOC_VERSIONING']) && ($lastDocVersion != 0)) { //Create new Version of current output $lastDocVersion ++; if ($aRow = $oDataset->getRow()) { $aFields = array ('APP_DOC_UID' => $aRow['APP_DOC_UID'],'APP_UID' => $sApplication,'DEL_INDEX' => $index,'DOC_UID' => $outputID,'DOC_VERSION' => $lastDocVersion + 1,'USR_UID' => $sUserLogged,'APP_DOC_TYPE' => 'OUTPUT','APP_DOC_CREATE_DATE' => date( 'Y-m-d H:i:s' ),'APP_DOC_FILENAME' => $sFilename,'FOLDER_UID' => $folderId,'APP_DOC_TAGS' => $fileTags); $oAppDocument = new \AppDocument(); $oAppDocument->create( $aFields ); $sDocUID = $aRow['APP_DOC_UID']; } } else { ////No versioning so Update a current Output or Create new if no exist if ($aRow = $oDataset->getRow()) { //Update $aFields = array ('APP_DOC_UID' => $aRow['APP_DOC_UID'],'APP_UID' => $sApplication,'DEL_INDEX' => $index,'DOC_UID' => $outputID,'DOC_VERSION' => $lastDocVersion,'USR_UID' => $sUserLogged,'APP_DOC_TYPE' => 'OUTPUT','APP_DOC_CREATE_DATE' => date( 'Y-m-d H:i:s' ),'APP_DOC_FILENAME' => $sFilename,'FOLDER_UID' => $folderId,'APP_DOC_TAGS' => $fileTags ); $oAppDocument = new \AppDocument(); $oAppDocument->update( $aFields ); $sDocUID = $aRow['APP_DOC_UID']; } else { //we are creating the appdocument row //create if ($lastDocVersion == 0) { $lastDocVersion ++; } $aFields = array ('APP_UID' => $sApplication,'DEL_INDEX' => $index,'DOC_UID' => $outputID,'DOC_VERSION' => $lastDocVersion,'USR_UID' => $sUserLogged,'APP_DOC_TYPE' => 'OUTPUT','APP_DOC_CREATE_DATE' => date( 'Y-m-d H:i:s' ),'APP_DOC_FILENAME' => $sFilename,'FOLDER_UID' => $folderId,'APP_DOC_TAGS' => $fileTags ); $oAppDocument = new \AppDocument(); $aFields['APP_DOC_UID'] = $sDocUID = $oAppDocument->create( $aFields ); } } $sFilename = $aFields['APP_DOC_UID'] . "_" . $lastDocVersion; $pathOutput = PATH_DOCUMENT . \G::getPathFromUID($sApplication) . PATH_SEP . 'outdocs' . PATH_SEP; //G::pr($sFilename);die; \G::mk_dir( $pathOutput ); $aProperties = array (); if (! isset( $aOD['OUT_DOC_MEDIA'] )) { $aOD['OUT_DOC_MEDIA'] = 'Letter'; } if (! isset( $aOD['OUT_DOC_LEFT_MARGIN'] )) { $aOD['OUT_DOC_LEFT_MARGIN'] = '15'; } if (! isset( $aOD['OUT_DOC_RIGHT_MARGIN'] )) { $aOD['OUT_DOC_RIGHT_MARGIN'] = '15'; } if (! isset( $aOD['OUT_DOC_TOP_MARGIN'] )) { $aOD['OUT_DOC_TOP_MARGIN'] = '15'; } if (! isset( $aOD['OUT_DOC_BOTTOM_MARGIN'] )) { $aOD['OUT_DOC_BOTTOM_MARGIN'] = '15'; } $aProperties['media'] = $aOD['OUT_DOC_MEDIA']; $aProperties['margins'] = array ('left' => $aOD['OUT_DOC_LEFT_MARGIN'],'right' => $aOD['OUT_DOC_RIGHT_MARGIN'],'top' => $aOD['OUT_DOC_TOP_MARGIN'],'bottom' => $aOD['OUT_DOC_BOTTOM_MARGIN'] ); if (isset($aOD['OUT_DOC_REPORT_GENERATOR'])) { $aProperties['report_generator'] = $aOD['OUT_DOC_REPORT_GENERATOR']; } $this->generate( $outputID, $Fields['APP_DATA'], $pathOutput, $sFilename, $aOD['OUT_DOC_TEMPLATE'], (boolean) $aOD['OUT_DOC_LANDSCAPE'], $aOD['OUT_DOC_GENERATE'], $aProperties , $applicationUid); //Plugin Hook PM_UPLOAD_DOCUMENT for upload document //G::LoadClass('plugin'); $oPluginRegistry = & \PMPluginRegistry::getSingleton(); if ($oPluginRegistry->existsTrigger( PM_UPLOAD_DOCUMENT ) && class_exists( 'uploadDocumentData' )) { $triggerDetail = $oPluginRegistry->getTriggerInfo( PM_UPLOAD_DOCUMENT ); $aFields['APP_DOC_PLUGIN'] = $triggerDetail->sNamespace; $oAppDocument1 = new \AppDocument(); $oAppDocument1->update( $aFields ); $sPathName = PATH_DOCUMENT . \G::getPathFromUID($sApplication) . PATH_SEP; $oData['APP_UID'] = $sApplication; $oData['ATTACHMENT_FOLDER'] = true; switch ($aOD['OUT_DOC_GENERATE']) { case "BOTH": $documentData = new \uploadDocumentData( $sApplication, $sUserLogged, $pathOutput . $sFilename . '.pdf', $sFilename . '.pdf', $sDocUID, $oAppDocument->getDocVersion() ); $documentData->sFileType = "PDF"; $documentData->bUseOutputFolder = true; $uploadReturn = $oPluginRegistry->executeTriggers( PM_UPLOAD_DOCUMENT, $documentData ); if ($uploadReturn) { //Only delete if the file was saved correctly unlink( $pathOutput . $sFilename . '.pdf' ); } $documentData = new \uploadDocumentData( $sApplication, $sUserLogged, $pathOutput . $sFilename . '.doc', $sFilename . '.doc', $sDocUID, $oAppDocument->getDocVersion() ); $documentData->sFileType = "DOC"; $documentData->bUseOutputFolder = true; $uploadReturn = $oPluginRegistry->executeTriggers( PM_UPLOAD_DOCUMENT, $documentData ); if ($uploadReturn) { //Only delete if the file was saved correctly unlink( $pathOutput . $sFilename . '.doc' ); } break; case "PDF": $documentData = new \uploadDocumentData( $sApplication, $sUserLogged, $pathOutput . $sFilename . '.pdf', $sFilename . '.pdf', $sDocUID, $oAppDocument->getDocVersion() ); $documentData->sFileType = "PDF"; $documentData->bUseOutputFolder = true; $uploadReturn = $oPluginRegistry->executeTriggers( PM_UPLOAD_DOCUMENT, $documentData ); if ($uploadReturn) { //Only delete if the file was saved correctly unlink( $pathOutput . $sFilename . '.pdf' ); } break; case "DOC": $documentData = new \uploadDocumentData( $sApplication, $sUserLogged, $pathOutput . $sFilename . '.doc', $sFilename . '.doc', $sDocUID, $oAppDocument->getDocVersion() ); $documentData->sFileType = "DOC"; $documentData->bUseOutputFolder = true; $uploadReturn = $oPluginRegistry->executeTriggers( PM_UPLOAD_DOCUMENT, $documentData ); if ($uploadReturn) { //Only delete if the file was saved correctly unlink( $pathOutput . $sFilename . '.doc' ); } break; } } $g->sessionVarRestore(); $oAppDocument = \AppDocumentPeer::retrieveByPK( $aFields['APP_DOC_UID'], $lastDocVersion); if ($oAppDocument->getAppDocStatus() == 'DELETED') { $oAppDocument->setAppDocStatus('ACTIVE'); $oAppDocument->save(); } $response = $this->getCasesOutputDocument($applicationUid, $userUid, $aFields['APP_DOC_UID']); return $response; } catch (\Exception $e) { throw $e; } }
/** * * @method * * Generates an Output Document * * @name PMFGenerateOutputDocument * @label PMF Generate Output Document * * @param string(32) | $outputID | Output ID | Output Document ID * @return none | $none | None | None * */ function PMFGenerateOutputDocument($outputID, $sApplication = null, $index = null, $sUserLogged = null) { $g = new G(); $g->sessionVarSave(); if ($sApplication) { $_SESSION["APPLICATION"] = $sApplication; } else { $sApplication = $_SESSION["APPLICATION"]; } if ($index) { $_SESSION["INDEX"] = $index; } else { $index = $_SESSION["INDEX"]; } if ($sUserLogged) { $_SESSION["USER_LOGGED"] = $sUserLogged; } else { $sUserLogged = $_SESSION["USER_LOGGED"]; } G::LoadClass('case'); $oCase = new Cases(); $oCase->thisIsTheCurrentUser($sApplication, $index, $sUserLogged, '', 'casesListExtJs'); //require_once 'classes/model/OutputDocument.php'; $oOutputDocument = new OutputDocument(); $aOD = $oOutputDocument->load($outputID); $Fields = $oCase->loadCase($sApplication); //The $_GET['UID'] variable is used when a process executes. //$_GET['UID']=($aOD['OUT_DOC_VERSIONING'])?$_GET['UID']:$aOD['OUT_DOC_UID']; //$sUID = ($aOD['OUT_DOC_VERSIONING'])?$_GET['UID']:$aOD['OUT_DOC_UID']; $sFilename = preg_replace('[^A-Za-z0-9_]', '_', G::replaceDataField($aOD['OUT_DOC_FILENAME'], $Fields['APP_DATA'])); require_once 'classes/model/AppFolder.php'; require_once 'classes/model/AppDocument.php'; //Get the Custom Folder ID (create if necessary) $oFolder = new AppFolder(); //$aOD['OUT_DOC_DESTINATION_PATH'] = ($aOD['OUT_DOC_DESTINATION_PATH']=='')?PATH_DOCUMENT // . $_SESSION['APPLICATION'] . PATH_SEP . 'outdocs'. PATH_SEP:$aOD['OUT_DOC_DESTINATION_PATH']; $folderId = $oFolder->createFromPath($aOD['OUT_DOC_DESTINATION_PATH'], $sApplication); //Tags $fileTags = $oFolder->parseTags($aOD['OUT_DOC_TAGS'], $sApplication); //Get last Document Version and apply versioning if is enabled $oAppDocument = new AppDocument(); $lastDocVersion = $oAppDocument->getLastDocVersion($outputID, $sApplication); $oCriteria = new Criteria('workflow'); $oCriteria->add(AppDocumentPeer::APP_UID, $sApplication); //$oCriteria->add(AppDocumentPeer::DEL_INDEX, $index); $oCriteria->add(AppDocumentPeer::DOC_UID, $outputID); $oCriteria->add(AppDocumentPeer::DOC_VERSION, $lastDocVersion); $oCriteria->add(AppDocumentPeer::APP_DOC_TYPE, 'OUTPUT'); $oDataset = AppDocumentPeer::doSelectRS($oCriteria); $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); if ($aOD['OUT_DOC_VERSIONING'] && $lastDocVersion != 0) { //Create new Version of current output $lastDocVersion++; if ($aRow = $oDataset->getRow()) { $aFields = array('APP_DOC_UID' => $aRow['APP_DOC_UID'], 'APP_UID' => $sApplication, 'DEL_INDEX' => $index, 'DOC_UID' => $outputID, 'DOC_VERSION' => $lastDocVersion + 1, 'USR_UID' => $sUserLogged, 'APP_DOC_TYPE' => 'OUTPUT', 'APP_DOC_CREATE_DATE' => date('Y-m-d H:i:s'), 'APP_DOC_FILENAME' => $sFilename, 'FOLDER_UID' => $folderId, 'APP_DOC_TAGS' => $fileTags); $oAppDocument = new AppDocument(); $oAppDocument->create($aFields); $sDocUID = $aRow['APP_DOC_UID']; } } else { ////No versioning so Update a current Output or Create new if no exist if ($aRow = $oDataset->getRow()) { //Update $aFields = array('APP_DOC_UID' => $aRow['APP_DOC_UID'], 'APP_UID' => $sApplication, 'DEL_INDEX' => $index, 'DOC_UID' => $outputID, 'DOC_VERSION' => $lastDocVersion, 'USR_UID' => $sUserLogged, 'APP_DOC_TYPE' => 'OUTPUT', 'APP_DOC_CREATE_DATE' => date('Y-m-d H:i:s'), 'APP_DOC_FILENAME' => $sFilename, 'FOLDER_UID' => $folderId, 'APP_DOC_TAGS' => $fileTags); $oAppDocument = new AppDocument(); $oAppDocument->update($aFields); $sDocUID = $aRow['APP_DOC_UID']; } else { //we are creating the appdocument row //create if ($lastDocVersion == 0) { $lastDocVersion++; } $aFields = array('APP_UID' => $sApplication, 'DEL_INDEX' => $index, 'DOC_UID' => $outputID, 'DOC_VERSION' => $lastDocVersion, 'USR_UID' => $sUserLogged, 'APP_DOC_TYPE' => 'OUTPUT', 'APP_DOC_CREATE_DATE' => date('Y-m-d H:i:s'), 'APP_DOC_FILENAME' => $sFilename, 'FOLDER_UID' => $folderId, 'APP_DOC_TAGS' => $fileTags); $oAppDocument = new AppDocument(); $aFields['APP_DOC_UID'] = $sDocUID = $oAppDocument->create($aFields); } } $sFilename = $aFields['APP_DOC_UID'] . "_" . $lastDocVersion; $pathOutput = PATH_DOCUMENT . G::getPathFromUID($sApplication) . PATH_SEP . 'outdocs' . PATH_SEP; //G::pr($sFilename);die; G::mk_dir($pathOutput); $aProperties = array(); if (!isset($aOD['OUT_DOC_MEDIA'])) { $aOD['OUT_DOC_MEDIA'] = 'Letter'; } if (!isset($aOD['OUT_DOC_LEFT_MARGIN'])) { $aOD['OUT_DOC_LEFT_MARGIN'] = '15'; } if (!isset($aOD['OUT_DOC_RIGHT_MARGIN'])) { $aOD['OUT_DOC_RIGHT_MARGIN'] = '15'; } if (!isset($aOD['OUT_DOC_TOP_MARGIN'])) { $aOD['OUT_DOC_TOP_MARGIN'] = '15'; } if (!isset($aOD['OUT_DOC_BOTTOM_MARGIN'])) { $aOD['OUT_DOC_BOTTOM_MARGIN'] = '15'; } $aProperties['media'] = $aOD['OUT_DOC_MEDIA']; $aProperties['margins'] = array('left' => $aOD['OUT_DOC_LEFT_MARGIN'], 'right' => $aOD['OUT_DOC_RIGHT_MARGIN'], 'top' => $aOD['OUT_DOC_TOP_MARGIN'], 'bottom' => $aOD['OUT_DOC_BOTTOM_MARGIN']); if (isset($aOD['OUT_DOC_REPORT_GENERATOR'])) { $aProperties['report_generator'] = $aOD['OUT_DOC_REPORT_GENERATOR']; } $oOutputDocument->generate($outputID, $Fields['APP_DATA'], $pathOutput, $sFilename, $aOD['OUT_DOC_TEMPLATE'], (bool) $aOD['OUT_DOC_LANDSCAPE'], $aOD['OUT_DOC_GENERATE'], $aProperties); //Plugin Hook PM_UPLOAD_DOCUMENT for upload document //G::LoadClass('plugin'); $oPluginRegistry =& PMPluginRegistry::getSingleton(); if ($oPluginRegistry->existsTrigger(PM_UPLOAD_DOCUMENT) && class_exists('uploadDocumentData')) { $triggerDetail = $oPluginRegistry->getTriggerInfo(PM_UPLOAD_DOCUMENT); $aFields['APP_DOC_PLUGIN'] = $triggerDetail->sNamespace; $oAppDocument1 = new AppDocument(); $oAppDocument1->update($aFields); $sPathName = PATH_DOCUMENT . G::getPathFromUID($sApplication) . PATH_SEP; $oData['APP_UID'] = $sApplication; $oData['ATTACHMENT_FOLDER'] = true; switch ($aOD['OUT_DOC_GENERATE']) { case "BOTH": $documentData = new uploadDocumentData($sApplication, $sUserLogged, $pathOutput . $sFilename . '.pdf', $sFilename . '.pdf', $sDocUID, $oAppDocument->getDocVersion()); $documentData->sFileType = "PDF"; $documentData->bUseOutputFolder = true; $uploadReturn = $oPluginRegistry->executeTriggers(PM_UPLOAD_DOCUMENT, $documentData); if ($uploadReturn) { //Only delete if the file was saved correctly unlink($pathOutput . $sFilename . '.pdf'); } $documentData = new uploadDocumentData($sApplication, $sUserLogged, $pathOutput . $sFilename . '.doc', $sFilename . '.doc', $sDocUID, $oAppDocument->getDocVersion()); $documentData->sFileType = "DOC"; $documentData->bUseOutputFolder = true; $uploadReturn = $oPluginRegistry->executeTriggers(PM_UPLOAD_DOCUMENT, $documentData); if ($uploadReturn) { //Only delete if the file was saved correctly unlink($pathOutput . $sFilename . '.doc'); } break; case "PDF": $documentData = new uploadDocumentData($sApplication, $sUserLogged, $pathOutput . $sFilename . '.pdf', $sFilename . '.pdf', $sDocUID, $oAppDocument->getDocVersion()); $documentData->sFileType = "PDF"; $documentData->bUseOutputFolder = true; $uploadReturn = $oPluginRegistry->executeTriggers(PM_UPLOAD_DOCUMENT, $documentData); if ($uploadReturn) { //Only delete if the file was saved correctly unlink($pathOutput . $sFilename . '.pdf'); } break; case "DOC": $documentData = new uploadDocumentData($sApplication, $sUserLogged, $pathOutput . $sFilename . '.doc', $sFilename . '.doc', $sDocUID, $oAppDocument->getDocVersion()); $documentData->sFileType = "DOC"; $documentData->bUseOutputFolder = true; $uploadReturn = $oPluginRegistry->executeTriggers(PM_UPLOAD_DOCUMENT, $documentData); if ($uploadReturn) { //Only delete if the file was saved correctly unlink($pathOutput . $sFilename . '.doc'); } break; } } $g->sessionVarRestore(); }
$aOD['OUT_DOC_RIGHT_MARGIN'] = '10'; } if (!isset($aOD['OUT_DOC_TOP_MARGIN'])) { $aOD['OUT_DOC_TOP_MARGIN'] = '10'; } if (!isset($aOD['OUT_DOC_BOTTOM_MARGIN'])) { $aOD['OUT_DOC_BOTTOM_MARGIN'] = '10'; } $aProperties['media'] = $aOD['OUT_DOC_MEDIA']; $aProperties['margins'] = array('left' => $aOD['OUT_DOC_LEFT_MARGIN'], 'right' => $aOD['OUT_DOC_RIGHT_MARGIN'], 'top' => $aOD['OUT_DOC_TOP_MARGIN'], 'bottom' => $aOD['OUT_DOC_BOTTOM_MARGIN']); $CheckDocuments = "SELECT AD.APP_DOC_UID FROM APP_DOCUMENT AD WHERE AD.APP_UID = '" . $appuid . "' AND APP_DOC_TYPE='OUTPUT' AND DOC_UID='" . $uidOuput . "' "; $CheckDocuments1 = executeQuery($CheckDocuments); //Verifica q si guecreado el documento if (sizeof($CheckDocuments1) == 0) { $oAppDocument = new AppDocument(); $lastDocVersion = $oAppDocument->getLastDocVersion($uidOuput, $appuid); $oCriteria = new Criteria('workflow'); $oCriteria->add(AppDocumentPeer::APP_UID, $appuid); $oCriteria->add(AppDocumentPeer::DOC_UID, $uidOuput); $oCriteria->add(AppDocumentPeer::DOC_VERSION, $lastDocVersion); $oCriteria->add(AppDocumentPeer::APP_DOC_TYPE, 'OUTPUT'); $oDataset = AppDocumentPeer::doSelectRS($oCriteria); $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); $aFields = array('APP_UID' => $appuid, 'DEL_INDEX' => $index, 'DOC_UID' => $uidOuput, 'DOC_VERSION' => $lastDocVersion + 1, 'USR_UID' => $_SESSION['USER_LOGGED'], 'APP_DOC_TYPE' => 'OUTPUT', 'APP_DOC_CREATE_DATE' => date('Y-m-d H:i:s'), 'APP_DOC_FILENAME' => $sFilename, 'FOLDER_UID' => '', 'APP_DOC_TAGS' => ''); $oAppDocument = new AppDocument(); $oAppDocument->create($aFields); } $Generated = $oOutputDocument->generate($uidOuput, $DataOutPutDoc, $pathOutput, $sFilename, $aOD['OUT_DOC_TEMPLATE'], (bool) $aOD['OUT_DOC_LANDSCAPE'], $aOD['OUT_DOC_GENERATE'], $aProperties); //$templateHTML=G::replaceDataField ( $aOD ['OUT_DOC_TEMPLATE'],$APP_DATA ); $templateHTML = G::replaceDataField($aOD['OUT_DOC_TEMPLATE'], $APP_DATA);
/** * Get data of Cases OutputDocument * * @param string $applicationUid * @param string $outputDocumentUid * @param string $userUid * * return object Return an object with data of an OutputDocument */ public function addCasesOutputDocument($applicationUid, $outputDocumentUid, $userUid) { try { $sApplication = $applicationUid; $index = \AppDelegation::getCurrentIndex($applicationUid); $sUserLogged = $userUid; $outputID = $outputDocumentUid; $g = new \G(); $g->sessionVarSave(); \G::LoadClass('case'); $oCase = new \Cases(); $oCase->thisIsTheCurrentUser($sApplication, $index, $sUserLogged, '', 'casesListExtJs'); //require_once 'classes/model/OutputDocument.php'; $oOutputDocument = new \OutputDocument(); $aOD = $oOutputDocument->load($outputID); $Fields = $oCase->loadCase($sApplication); $sFilename = preg_replace('[^A-Za-z0-9_]', '_', \G::replaceDataField($aOD['OUT_DOC_FILENAME'], $Fields['APP_DATA'])); require_once PATH_TRUNK . "workflow" . PATH_SEP . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "AppFolder.php"; require_once PATH_TRUNK . "workflow" . PATH_SEP . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "AppDocument.php"; //Get the Custom Folder ID (create if necessary) $oFolder = new \AppFolder(); $folderId = $oFolder->createFromPath($aOD['OUT_DOC_DESTINATION_PATH'], $sApplication); //Tags $fileTags = $oFolder->parseTags($aOD['OUT_DOC_TAGS'], $sApplication); //Get last Document Version and apply versioning if is enabled $oAppDocument = new \AppDocument(); $lastDocVersion = $oAppDocument->getLastDocVersion($outputID, $sApplication); $oCriteria = new \Criteria('workflow'); $oCriteria->add(\AppDocumentPeer::APP_UID, $sApplication); $oCriteria->add(\AppDocumentPeer::DOC_UID, $outputID); $oCriteria->add(\AppDocumentPeer::DOC_VERSION, $lastDocVersion); $oCriteria->add(\AppDocumentPeer::APP_DOC_TYPE, 'OUTPUT'); $oDataset = \AppDocumentPeer::doSelectRS($oCriteria); $oDataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC); $oDataset->next(); if ($aOD['OUT_DOC_VERSIONING'] && $lastDocVersion != 0) { //Create new Version of current output $lastDocVersion++; if ($aRow = $oDataset->getRow()) { $aFields = array('APP_DOC_UID' => $aRow['APP_DOC_UID'], 'APP_UID' => $sApplication, 'DEL_INDEX' => $index, 'DOC_UID' => $outputID, 'DOC_VERSION' => $lastDocVersion + 1, 'USR_UID' => $sUserLogged, 'APP_DOC_TYPE' => 'OUTPUT', 'APP_DOC_CREATE_DATE' => date('Y-m-d H:i:s'), 'APP_DOC_FILENAME' => $sFilename, 'FOLDER_UID' => $folderId, 'APP_DOC_TAGS' => $fileTags); $oAppDocument = new \AppDocument(); $oAppDocument->create($aFields); $sDocUID = $aRow['APP_DOC_UID']; } } else { ////No versioning so Update a current Output or Create new if no exist if ($aRow = $oDataset->getRow()) { //Update $aFields = array('APP_DOC_UID' => $aRow['APP_DOC_UID'], 'APP_UID' => $sApplication, 'DEL_INDEX' => $index, 'DOC_UID' => $outputID, 'DOC_VERSION' => $lastDocVersion, 'USR_UID' => $sUserLogged, 'APP_DOC_TYPE' => 'OUTPUT', 'APP_DOC_CREATE_DATE' => date('Y-m-d H:i:s'), 'APP_DOC_FILENAME' => $sFilename, 'FOLDER_UID' => $folderId, 'APP_DOC_TAGS' => $fileTags); $oAppDocument = new \AppDocument(); $oAppDocument->update($aFields); $sDocUID = $aRow['APP_DOC_UID']; } else { //we are creating the appdocument row //create if ($lastDocVersion == 0) { $lastDocVersion++; } $aFields = array('APP_UID' => $sApplication, 'DEL_INDEX' => $index, 'DOC_UID' => $outputID, 'DOC_VERSION' => $lastDocVersion, 'USR_UID' => $sUserLogged, 'APP_DOC_TYPE' => 'OUTPUT', 'APP_DOC_CREATE_DATE' => date('Y-m-d H:i:s'), 'APP_DOC_FILENAME' => $sFilename, 'FOLDER_UID' => $folderId, 'APP_DOC_TAGS' => $fileTags); $oAppDocument = new \AppDocument(); $aFields['APP_DOC_UID'] = $sDocUID = $oAppDocument->create($aFields); } } $sFilename = $aFields['APP_DOC_UID'] . "_" . $lastDocVersion; $pathOutput = PATH_DOCUMENT . \G::getPathFromUID($sApplication) . PATH_SEP . 'outdocs' . PATH_SEP; //G::pr($sFilename);die; \G::mk_dir($pathOutput); $aProperties = array(); if (!isset($aOD['OUT_DOC_MEDIA'])) { $aOD['OUT_DOC_MEDIA'] = 'Letter'; } if (!isset($aOD['OUT_DOC_LEFT_MARGIN'])) { $aOD['OUT_DOC_LEFT_MARGIN'] = '15'; } if (!isset($aOD['OUT_DOC_RIGHT_MARGIN'])) { $aOD['OUT_DOC_RIGHT_MARGIN'] = '15'; } if (!isset($aOD['OUT_DOC_TOP_MARGIN'])) { $aOD['OUT_DOC_TOP_MARGIN'] = '15'; } if (!isset($aOD['OUT_DOC_BOTTOM_MARGIN'])) { $aOD['OUT_DOC_BOTTOM_MARGIN'] = '15'; } $aProperties['media'] = $aOD['OUT_DOC_MEDIA']; $aProperties['margins'] = array('left' => $aOD['OUT_DOC_LEFT_MARGIN'], 'right' => $aOD['OUT_DOC_RIGHT_MARGIN'], 'top' => $aOD['OUT_DOC_TOP_MARGIN'], 'bottom' => $aOD['OUT_DOC_BOTTOM_MARGIN']); if (isset($aOD['OUT_DOC_REPORT_GENERATOR'])) { $aProperties['report_generator'] = $aOD['OUT_DOC_REPORT_GENERATOR']; } $this->generate($outputID, $Fields['APP_DATA'], $pathOutput, $sFilename, $aOD['OUT_DOC_TEMPLATE'], (bool) $aOD['OUT_DOC_LANDSCAPE'], $aOD['OUT_DOC_GENERATE'], $aProperties, $applicationUid); /*----------------------------------********---------------------------------*/ $licensedFeatures =& \PMLicensedFeatures::getSingleton(); if ($licensedFeatures->verifyfeature('7qhYmF1eDJWcEdwcUZpT0k4S0xTRStvdz09')) { \G::LoadClass("pmDrive"); $pmDrive = new \PMDrive(); if ($pmDrive->getStatusService()) { $app = new \Application(); $user = new \Users(); $dataUser = $user->load($userUid); $pmDrive->setDriveUser($dataUser['USR_EMAIL']); $appData = $app->Load($applicationUid); if ($appData['APP_DRIVE_FOLDER_UID'] == null) { $process = new \Process(); $process->setProUid($appData['PRO_UID']); $result = $pmDrive->createFolder($process->getProTitle() . ' - ' . G::LoadTranslation("ID_CASE") . ' #' . $appData['APP_NUMBER'], $pmDrive->getFolderIdPMDrive($userUid)); $appData['APP_DRIVE_FOLDER_UID'] = $result->id; $app->update($appData); } $fileIdDriveDoc = ''; $fileIdDrivePdf = ''; $sFilenameOriginal = preg_replace('[^A-Za-z0-9_]', '_', \G::replaceDataField($aOD['OUT_DOC_FILENAME'], $Fields['APP_DATA'])); switch ($aOD['OUT_DOC_GENERATE']) { case "BOTH": $result = $pmDrive->uploadFile('application/pdf', $pathOutput . $sFilename . '.pdf', $sFilenameOriginal . '.pdf', $appData['APP_DRIVE_FOLDER_UID']); $oAppDocument->setDriveDownload('OUTPUT_PDF', $result->webContentLink); $fileIdDrivePdf = $result->id; $result = $pmDrive->uploadFile('application/doc', $pathOutput . $sFilename . '.doc', $sFilenameOriginal . '.doc', $appData['APP_DRIVE_FOLDER_UID']); $oAppDocument->setDriveDownload('OUTPUT_DOC', $result->webContentLink); $fileIdDriveDoc = $result->id; break; case "PDF": $result = $pmDrive->uploadFile('application/pdf', $pathOutput . $sFilename . '.pdf', $sFilenameOriginal . '.pdf', $appData['APP_DRIVE_FOLDER_UID']); $oAppDocument->setDriveDownload('OUTPUT_PDF', $result->webContentLink); $fileIdDrivePdf = $result->id; break; case "DOC": $result = $pmDrive->uploadFile('application/doc', $pathOutput . $sFilename . '.doc', $sFilenameOriginal . '.doc', $appData['APP_DRIVE_FOLDER_UID']); $oAppDocument->setDriveDownload('OUTPUT_DOC', $result->webContentLink); $fileIdDriveDoc = $result->id; break; } $aFields['DOC_VERSION'] = $oAppDocument->getDocVersion(); // $docVersion; $aFields['APP_DOC_UID'] = $oAppDocument->getAppDocUid(); //$appDocUid; $appDocUid = $aFields['APP_DOC_UID']; $oAppDocument->update($aFields); //$option = 'pmDrive'; //add permissions $criteria = new \Criteria('workflow'); $criteria->addSelectColumn(\ApplicationPeer::PRO_UID); $criteria->addSelectColumn(\TaskUserPeer::TAS_UID); $criteria->addSelectColumn(\TaskUserPeer::USR_UID); $criteria->addSelectColumn(\TaskUserPeer::TU_RELATION); $criteria->add(\ApplicationPeer::APP_UID, $applicationUid); $criteria->addJoin(\ApplicationPeer::PRO_UID, \TaskPeer::PRO_UID, \Criteria::LEFT_JOIN); $criteria->addJoin(\TaskPeer::TAS_UID, \TaskUserPeer::TAS_UID, \Criteria::LEFT_JOIN); $dataset = \ApplicationPeer::doSelectRS($criteria); $dataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC); $userPermission = array(); $case = new \Cases(); while ($dataset->next()) { $row = $dataset->getRow(); if ($row['TU_RELATION'] == 1) { //users $dataUser = $user->load($row['USR_UID']); if (array_search($dataUser['USR_EMAIL'], $userPermission) === false) { $objectPermissions = $case->getAllObjects($row['PRO_UID'], $applicationUid, $row['TAS_UID'], $row['USR_UID']); if (array_search($appDocUid, $objectPermissions['OUTPUT_DOCUMENTS']) !== false) { $userPermission[] = $dataUser['USR_EMAIL']; } } } else { //Groups $criteria = new \Criteria('workflow'); $criteria->addSelectColumn(\UsersPeer::USR_EMAIL); $criteria->addSelectColumn(\UsersPeer::USR_UID); $criteria->add(\GroupUserPeer::GRP_UID, $row['USR_UID']); $criteria->addJoin(\GroupUserPeer::USR_UID, \UsersPeer::USR_UID, \Criteria::LEFT_JOIN); $oDataset = \AppDelegationPeer::doSelectRS($criteria); $oDataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC); while ($oDataset->next()) { $aRow = $oDataset->getRow(); if (array_search($aRow['USR_EMAIL'], $userPermission) === false) { $objectPermissions = $case->getAllObjects($row['PRO_UID'], $applicationUid, $row['TAS_UID'], $aRow['USR_UID']); if (array_search($appDocUid, $objectPermissions['OUTPUT_DOCUMENTS']) !== false) { $userPermission[] = $aRow['USR_EMAIL']; } } } } } $userPermission = array_unique($userPermission); foreach ($userPermission as $key => $val) { $pmDrive->setPermission($appData['APP_DRIVE_FOLDER_UID'], $val, 'user', 'writer'); $pmDrive->setPermission($fileIdDrivePdf, $val); $pmDrive->setPermission($fileIdDriveDoc, $val); } } } /*----------------------------------********---------------------------------*/ //Plugin Hook PM_UPLOAD_DOCUMENT for upload document //G::LoadClass('plugin'); $oPluginRegistry =& \PMPluginRegistry::getSingleton(); if ($oPluginRegistry->existsTrigger(PM_UPLOAD_DOCUMENT) && class_exists('uploadDocumentData')) { $triggerDetail = $oPluginRegistry->getTriggerInfo(PM_UPLOAD_DOCUMENT); $aFields['APP_DOC_PLUGIN'] = $triggerDetail->sNamespace; $oAppDocument1 = new \AppDocument(); $oAppDocument1->update($aFields); $sPathName = PATH_DOCUMENT . \G::getPathFromUID($sApplication) . PATH_SEP; $oData['APP_UID'] = $sApplication; $oData['ATTACHMENT_FOLDER'] = true; switch ($aOD['OUT_DOC_GENERATE']) { case "BOTH": $documentData = new \uploadDocumentData($sApplication, $sUserLogged, $pathOutput . $sFilename . '.pdf', $sFilename . '.pdf', $sDocUID, $oAppDocument->getDocVersion()); $documentData->sFileType = "PDF"; $documentData->bUseOutputFolder = true; $uploadReturn = $oPluginRegistry->executeTriggers(PM_UPLOAD_DOCUMENT, $documentData); if ($uploadReturn) { //Only delete if the file was saved correctly unlink($pathOutput . $sFilename . '.pdf'); } $documentData = new \uploadDocumentData($sApplication, $sUserLogged, $pathOutput . $sFilename . '.doc', $sFilename . '.doc', $sDocUID, $oAppDocument->getDocVersion()); $documentData->sFileType = "DOC"; $documentData->bUseOutputFolder = true; $uploadReturn = $oPluginRegistry->executeTriggers(PM_UPLOAD_DOCUMENT, $documentData); if ($uploadReturn) { //Only delete if the file was saved correctly unlink($pathOutput . $sFilename . '.doc'); } break; case "PDF": $documentData = new \uploadDocumentData($sApplication, $sUserLogged, $pathOutput . $sFilename . '.pdf', $sFilename . '.pdf', $sDocUID, $oAppDocument->getDocVersion()); $documentData->sFileType = "PDF"; $documentData->bUseOutputFolder = true; $uploadReturn = $oPluginRegistry->executeTriggers(PM_UPLOAD_DOCUMENT, $documentData); if ($uploadReturn) { //Only delete if the file was saved correctly unlink($pathOutput . $sFilename . '.pdf'); } break; case "DOC": $documentData = new \uploadDocumentData($sApplication, $sUserLogged, $pathOutput . $sFilename . '.doc', $sFilename . '.doc', $sDocUID, $oAppDocument->getDocVersion()); $documentData->sFileType = "DOC"; $documentData->bUseOutputFolder = true; $uploadReturn = $oPluginRegistry->executeTriggers(PM_UPLOAD_DOCUMENT, $documentData); if ($uploadReturn) { //Only delete if the file was saved correctly unlink($pathOutput . $sFilename . '.doc'); } break; } } $g->sessionVarRestore(); $oAppDocument = \AppDocumentPeer::retrieveByPK($aFields['APP_DOC_UID'], $lastDocVersion); if ($oAppDocument->getAppDocStatus() == 'DELETED') { $oAppDocument->setAppDocStatus('ACTIVE'); $oAppDocument->save(); } $response = $this->getCasesOutputDocument($applicationUid, $userUid, $aFields['APP_DOC_UID']); return $response; } catch (\Exception $e) { throw $e; } }