Merged in darojas/processmaker (pull request #329)
Se agregan metodos para InputDocuments y OutputDocuments
This commit is contained in:
@@ -770,7 +770,6 @@ class Cases
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get all upload document that they have send it
|
||||
*
|
||||
@@ -1062,4 +1061,232 @@ class Cases
|
||||
$oCriteria->addDescendingOrderByColumn('CREATE_DATE');
|
||||
return $oCriteria;
|
||||
}
|
||||
|
||||
/*
|
||||
* get all generate document
|
||||
*
|
||||
* @name getAllGeneratedDocumentsCriteria
|
||||
* @param string $sProcessUID
|
||||
* @param string $sApplicationUID
|
||||
* @param string $sTasKUID
|
||||
* @param string $sUserUID
|
||||
* @return object
|
||||
*/
|
||||
public function getAllGeneratedDocumentsCriteria($sProcessUID, $sApplicationUID, $sTasKUID, $sUserUID)
|
||||
{
|
||||
\G::LoadClass("configuration");
|
||||
$conf = new \Configurations();
|
||||
$confEnvSetting = $conf->getFormats();
|
||||
//verifica si la tabla OBJECT_PERMISSION
|
||||
$cases = new \cases();
|
||||
$cases->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 = $cases->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 = $cases->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 = '(USER DELETED)';
|
||||
}
|
||||
//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;
|
||||
\G::LoadClass('ArrayPeer');
|
||||
$oCriteria = new \Criteria('dbarray');
|
||||
$oCriteria->setDBArrayTable('outputDocuments');
|
||||
$oCriteria->addDescendingOrderByColumn('CREATE_DATE');
|
||||
return $oCriteria;
|
||||
}
|
||||
}
|
||||
234
workflow/engine/src/BusinessModel/Cases/InputDocument.php
Normal file
234
workflow/engine/src/BusinessModel/Cases/InputDocument.php
Normal file
@@ -0,0 +1,234 @@
|
||||
<?php
|
||||
namespace BusinessModel\Cases;
|
||||
|
||||
class InputDocument
|
||||
{
|
||||
/**
|
||||
* Get data of Cases InputDocument
|
||||
*
|
||||
* @param string $caseUid
|
||||
* @param string $userUid
|
||||
*
|
||||
* return array Return an array with data of an InputDocument
|
||||
*/
|
||||
public function getCasesInputDocuments($caseUid, $userUid)
|
||||
{
|
||||
try {
|
||||
$sApplicationUID = $caseUid;
|
||||
$sUserUID = $userUid;
|
||||
\G::LoadClass('case');
|
||||
$oCase = new \Cases();
|
||||
$fields = $oCase->loadCase( $sApplicationUID );
|
||||
$sProcessUID = $fields['PRO_UID'];
|
||||
$sTaskUID = '';
|
||||
$oCaseRest = new \BusinessModel\Cases();
|
||||
$oCaseRest->getAllUploadedDocumentsCriteria( $sProcessUID, $sApplicationUID, $sTaskUID, $sUserUID);
|
||||
$result = array ();
|
||||
global $_DBArray;
|
||||
foreach ($_DBArray['inputDocuments'] as $key => $row) {
|
||||
if (isset( $row['DOC_VERSION'] )) {
|
||||
$docrow = array ();
|
||||
$docrow['app_doc_uid'] = $row['APP_DOC_UID'];
|
||||
$docrow['app_doc_filename'] = $row['APP_DOC_FILENAME'];
|
||||
$docrow['doc_uid'] = $row['DOC_UID'];
|
||||
$docrow['app_doc_version'] = $row['DOC_VERSION'];
|
||||
$docrow['app_doc_create_date'] = $row['CREATE_DATE'];
|
||||
$docrow['app_doc_create_user'] = $row['CREATED_BY'];
|
||||
$docrow['app_doc_type'] = $row['TYPE'];
|
||||
$docrow['app_doc_index'] = $row['APP_DOC_INDEX'];
|
||||
$docrow['app_doc_link'] = 'cases/' . $row['DOWNLOAD_LINK'];
|
||||
$result[] = $docrow;
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get data of Cases InputDocument
|
||||
*
|
||||
* @param string $caseUid
|
||||
* @param string $userUid
|
||||
* @param string $inputDocumentUid
|
||||
*
|
||||
* return array Return an array with data of an InputDocument
|
||||
*/
|
||||
public function getCasesInputDocument($caseUid, $userUid, $inputDocumentUid)
|
||||
{
|
||||
try {
|
||||
$sApplicationUID = $caseUid;
|
||||
$sUserUID = $userUid;
|
||||
\G::LoadClass('case');
|
||||
$oCase = new \Cases();
|
||||
$fields = $oCase->loadCase( $sApplicationUID );
|
||||
$sProcessUID = $fields['PRO_UID'];
|
||||
$sTaskUID = '';
|
||||
$oCaseRest = new \BusinessModel\Cases();
|
||||
$oCaseRest->getAllUploadedDocumentsCriteria( $sProcessUID, $sApplicationUID, $sTaskUID, $sUserUID );
|
||||
$result = array ();
|
||||
global $_DBArray;
|
||||
foreach ($_DBArray['inputDocuments'] as $key => $row) {
|
||||
if (isset( $row['DOC_VERSION'] )) {
|
||||
$docrow = array ();
|
||||
$docrow['app_doc_uid'] = $row['APP_DOC_UID'];
|
||||
$docrow['app_doc_filename'] = $row['APP_DOC_FILENAME'];
|
||||
$docrow['doc_uid'] = $row['DOC_UID'];
|
||||
$docrow['app_doc_version'] = $row['DOC_VERSION'];
|
||||
$docrow['app_doc_create_date'] = $row['CREATE_DATE'];
|
||||
$docrow['app_doc_create_user'] = $row['CREATED_BY'];
|
||||
$docrow['app_doc_type'] = $row['TYPE'];
|
||||
$docrow['app_doc_index'] = $row['APP_DOC_INDEX'];
|
||||
$docrow['app_doc_link'] = 'cases/' . $row['DOWNLOAD_LINK'];
|
||||
if ($docrow['app_doc_uid'] == $inputDocumentUid) {
|
||||
$result = $docrow;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete InputDocument
|
||||
*
|
||||
* @param string $inputDocumentUid
|
||||
*
|
||||
* return array Return an array with data of an InputDocument
|
||||
*/
|
||||
public function removeInputDocument($inputDocumentUid)
|
||||
{
|
||||
try {
|
||||
$oAppDocument = \AppDocumentPeer::retrieveByPK( $inputDocumentUid, 1 );
|
||||
if (is_null( $oAppDocument ) || $oAppDocument->getAppDocStatus() == 'DELETED') {
|
||||
throw (new \Exception('This row doesn\'t exist!'));
|
||||
}
|
||||
\G::LoadClass('wsBase');
|
||||
$ws = new \wsBase();
|
||||
$ws->removeDocument($inputDocumentUid);
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get data of Cases InputDocument
|
||||
*
|
||||
* @param string $caseUid
|
||||
* @param string $inputDocumentUid
|
||||
* @param string $userUid
|
||||
*
|
||||
* return array Return an array with data of an InputDocument
|
||||
*/
|
||||
public function addCasesInputDocument($caseUid, $inputDocumentUid, $userUid)
|
||||
{
|
||||
try {
|
||||
if ((isset( $_FILES['form'] )) && ($_FILES['form']['error']['APP_DOC_FILENAME'] != 0)) {
|
||||
$code = $_FILES['form']['error']['APP_DOC_FILENAME'];
|
||||
switch ($code) {
|
||||
case UPLOAD_ERR_INI_SIZE:
|
||||
$message = \G::LoadTranslation( 'ID_UPLOAD_ERR_INI_SIZE' );
|
||||
break;
|
||||
case UPLOAD_ERR_FORM_SIZE:
|
||||
$message = \G::LoadTranslation( 'ID_UPLOAD_ERR_FORM_SIZE' );
|
||||
break;
|
||||
case UPLOAD_ERR_PARTIAL:
|
||||
$message = \G::LoadTranslation( 'ID_UPLOAD_ERR_PARTIAL' );
|
||||
break;
|
||||
case UPLOAD_ERR_NO_FILE:
|
||||
$message = \G::LoadTranslation( 'ID_UPLOAD_ERR_NO_FILE' );
|
||||
break;
|
||||
case UPLOAD_ERR_NO_TMP_DIR:
|
||||
$message = \G::LoadTranslation( 'ID_UPLOAD_ERR_NO_TMP_DIR' );
|
||||
break;
|
||||
case UPLOAD_ERR_CANT_WRITE:
|
||||
$message = \G::LoadTranslation( 'ID_UPLOAD_ERR_CANT_WRITE' );
|
||||
break;
|
||||
case UPLOAD_ERR_EXTENSION:
|
||||
$message = \G::LoadTranslation( 'ID_UPLOAD_ERR_EXTENSION' );
|
||||
break;
|
||||
default:
|
||||
$message = \G::LoadTranslation( 'ID_UPLOAD_ERR_UNKNOWN' );
|
||||
break;
|
||||
}
|
||||
\G::SendMessageText( $message, "ERROR" );
|
||||
$backUrlObj = explode( "sys" . SYS_SYS, $_SERVER['HTTP_REFERER'] );
|
||||
\G::header( "location: " . "/sys" . SYS_SYS . $backUrlObj[1] );
|
||||
die();
|
||||
}
|
||||
|
||||
\G::LoadClass("case");
|
||||
|
||||
//$inputDocumentUid = $_GET["UID"]; //$_POST["form"]["DOC_UID"]
|
||||
$appDocUid = '';
|
||||
//$appDocUid = $_POST["form"]["APP_DOC_UID"];
|
||||
$docVersion = '';
|
||||
//$docVersion = intval($_POST["form"]["docVersion"]);
|
||||
$appDocType = 'INPUT';
|
||||
//$appDocType = $_POST["form"]["APP_DOC_TYPE"];
|
||||
$appDocComment = (isset($_POST["form"]["APP_DOC_COMMENT"]))? $_POST["form"]["APP_DOC_COMMENT"] : "";
|
||||
$actionType = $_POST["form"]["actionType"];
|
||||
|
||||
$case = new \Cases();
|
||||
$case->thisIsTheCurrentUser($_SESSION["APPLICATION"], $_SESSION["INDEX"], $_SESSION["USER_LOGGED"], "REDIRECT", "casesListExtJs");
|
||||
|
||||
//Load the fields
|
||||
$arrayField = $case->loadCase($_SESSION["APPLICATION"]);
|
||||
$arrayField["APP_DATA"] = array_merge($arrayField["APP_DATA"], \G::getSystemConstants());
|
||||
|
||||
//Triggers
|
||||
$arrayTrigger = $case->loadTriggers($_SESSION["TASK"], "INPUT_DOCUMENT", $inputDocumentUid, "AFTER");
|
||||
|
||||
|
||||
//Add Input Document
|
||||
if (isset($_FILES) && isset($_FILES["form"]) && count($_FILES["form"]) > 0) {
|
||||
$appDocUid = $case->addInputDocument(
|
||||
$inputDocumentUid,
|
||||
$appDocUid,
|
||||
$docVersion,
|
||||
$appDocType,
|
||||
$appDocComment,
|
||||
$actionType,
|
||||
$_SESSION["APPLICATION"],
|
||||
$_SESSION["INDEX"],
|
||||
$_SESSION["TASK"],
|
||||
$_SESSION["USER_LOGGED"],
|
||||
"xmlform",
|
||||
$_FILES["form"]["name"]["APP_DOC_FILENAME"],
|
||||
$_FILES["form"]["error"]["APP_DOC_FILENAME"],
|
||||
$_FILES["form"]["tmp_name"]["APP_DOC_FILENAME"]
|
||||
);
|
||||
}
|
||||
|
||||
if ($_SESSION["TRIGGER_DEBUG"]["NUM_TRIGGERS"] > 0) {
|
||||
//Trigger - Execute after - Start
|
||||
$arrayField["APP_DATA"] = $case->executeTriggers(
|
||||
$_SESSION["TASK"],
|
||||
"INPUT_DOCUMENT",
|
||||
$inputDocumentUid,
|
||||
"AFTER",
|
||||
$arrayField["APP_DATA"]
|
||||
);
|
||||
//Trigger - Execute after - End
|
||||
}
|
||||
|
||||
//Save data
|
||||
$arrayData = array();
|
||||
$arrayData["APP_NUMBER"] = $arrayField["APP_NUMBER"];
|
||||
//$arrayData["APP_PROC_STATUS"] = $arrayField["APP_PROC_STATUS"];
|
||||
$arrayData["APP_DATA"] = $arrayField["APP_DATA"];
|
||||
$arrayData["DEL_INDEX"] = $_SESSION["INDEX"];
|
||||
$arrayData["TAS_UID"] = $_SESSION["TASK"];
|
||||
|
||||
$case->updateCase($_SESSION["APPLICATION"], $arrayData);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
230
workflow/engine/src/BusinessModel/Cases/OutputDocument.php
Normal file
230
workflow/engine/src/BusinessModel/Cases/OutputDocument.php
Normal file
@@ -0,0 +1,230 @@
|
||||
<?php
|
||||
namespace BusinessModel\Cases;
|
||||
|
||||
class OutputDocument
|
||||
{
|
||||
/**
|
||||
* Get data of Cases OutputDocument
|
||||
*
|
||||
* @param string $caseUid
|
||||
* @param string $userUid
|
||||
*
|
||||
* return array Return an array with data of an OutputDocument
|
||||
*/
|
||||
public function getCasesOutputDocuments($caseUid, $userUid)
|
||||
{
|
||||
try {
|
||||
\G::LoadClass('case');
|
||||
$oCase = new \Cases();
|
||||
$fields = $oCase->loadCase( $caseUid );
|
||||
$sProcessUID = $fields['PRO_UID'];
|
||||
$sTaskUID = '';
|
||||
$oCriteria = new \BusinessModel\Cases();
|
||||
$oCriteria->getAllGeneratedDocumentsCriteria( $sProcessUID, $caseUid, $sTaskUID, $userUid);
|
||||
$result = array ();
|
||||
global $_DBArray;
|
||||
foreach ($_DBArray['outputDocuments'] as $key => $row) {
|
||||
if (isset( $row['DOC_VERSION'] )) {
|
||||
$docrow = array ();
|
||||
$docrow['app_doc_uid'] = $row['APP_DOC_UID'];
|
||||
$docrow['app_doc_filename'] = $row['DOWNLOAD_FILE'];
|
||||
$docrow['doc_uid'] = $row['DOC_UID'];
|
||||
$docrow['app_doc_version'] = $row['DOC_VERSION'];
|
||||
$docrow['app_doc_create_date'] = $row['CREATE_DATE'];
|
||||
$docrow['app_doc_create_user'] = $row['CREATED_BY'];
|
||||
$docrow['app_doc_type'] = $row['TYPE'];
|
||||
$docrow['app_doc_index'] = $row['APP_DOC_INDEX'];
|
||||
$docrow['app_doc_link'] = 'cases/' . $row['DOWNLOAD_LINK'];
|
||||
$result[] = $docrow;
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get data of Cases OutputDocument
|
||||
*
|
||||
* @param string $caseUid
|
||||
* @param string $userUid
|
||||
* @param string $outputDocumentUid
|
||||
*
|
||||
* return array Return an array with data of an OutputDocument
|
||||
*/
|
||||
public function getCasesOutputDocument($caseUid, $userUid, $outputDocumentUid)
|
||||
{
|
||||
try {
|
||||
$sApplicationUID = $caseUid;
|
||||
$sUserUID = $userUid;
|
||||
\G::LoadClass('case');
|
||||
$oCase = new \Cases();
|
||||
$fields = $oCase->loadCase( $sApplicationUID );
|
||||
$sProcessUID = $fields['PRO_UID'];
|
||||
$sTaskUID = '';
|
||||
$oCaseRest = new \BusinessModel\Cases();
|
||||
$oCaseRest->getAllGeneratedDocumentsCriteria( $sProcessUID, $sApplicationUID, $sTaskUID, $sUserUID );
|
||||
$result = array ();
|
||||
global $_DBArray;
|
||||
foreach ($_DBArray['outputDocuments'] as $key => $row) {
|
||||
if (isset( $row['DOC_VERSION'] )) {
|
||||
$docrow = array ();
|
||||
$docrow['app_doc_uid'] = $row['APP_DOC_UID'];
|
||||
$docrow['app_doc_filename'] = $row['DOWNLOAD_FILE'];
|
||||
$docrow['doc_uid'] = $row['DOC_UID'];
|
||||
$docrow['app_doc_version'] = $row['DOC_VERSION'];
|
||||
$docrow['app_doc_create_date'] = $row['CREATE_DATE'];
|
||||
$docrow['app_doc_create_user'] = $row['CREATED_BY'];
|
||||
$docrow['app_doc_type'] = $row['TYPE'];
|
||||
$docrow['app_doc_index'] = $row['APP_DOC_INDEX'];
|
||||
$docrow['app_doc_link'] = 'cases/' . $row['DOWNLOAD_LINK'];
|
||||
if ($docrow['app_doc_uid'] == $outputDocumentUid) {
|
||||
$result = $docrow;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete OutputDocument
|
||||
*
|
||||
* @param string $outputDocumentUid
|
||||
*
|
||||
* return array Return an array with data of an OutputDocument
|
||||
*/
|
||||
public function removeOutputDocument($outputDocumentUid)
|
||||
{
|
||||
try {
|
||||
$oAppDocument = \AppDocumentPeer::retrieveByPK( $outputDocumentUid, 1 );
|
||||
if (is_null( $oAppDocument ) || $oAppDocument->getAppDocStatus() == 'DELETED') {
|
||||
throw (new \Exception('This row doesn\'t exist!'));
|
||||
}
|
||||
\G::LoadClass('wsBase');
|
||||
$ws = new \wsBase();
|
||||
$ws->removeDocument($outputDocumentUid);
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get data of Cases OutputDocument
|
||||
*
|
||||
* @param string $caseUid
|
||||
* @param string $outputDocumentUid
|
||||
* @param string $userUid
|
||||
*
|
||||
* return array Return an array with data of an OutputDocument
|
||||
*/
|
||||
public function addCasesOutputDocument($caseUid, $outputDocumentUid, $userUid)
|
||||
{
|
||||
try {
|
||||
if ((isset( $_FILES['form'] )) && ($_FILES['form']['error']['APP_DOC_FILENAME'] != 0)) {
|
||||
$code = $_FILES['form']['error']['APP_DOC_FILENAME'];
|
||||
switch ($code) {
|
||||
case UPLOAD_ERR_INI_SIZE:
|
||||
$message = \G::LoadTranslation( 'ID_UPLOAD_ERR_INI_SIZE' );
|
||||
break;
|
||||
case UPLOAD_ERR_FORM_SIZE:
|
||||
$message = \G::LoadTranslation( 'ID_UPLOAD_ERR_FORM_SIZE' );
|
||||
break;
|
||||
case UPLOAD_ERR_PARTIAL:
|
||||
$message = \G::LoadTranslation( 'ID_UPLOAD_ERR_PARTIAL' );
|
||||
break;
|
||||
case UPLOAD_ERR_NO_FILE:
|
||||
$message = \G::LoadTranslation( 'ID_UPLOAD_ERR_NO_FILE' );
|
||||
break;
|
||||
case UPLOAD_ERR_NO_TMP_DIR:
|
||||
$message = \G::LoadTranslation( 'ID_UPLOAD_ERR_NO_TMP_DIR' );
|
||||
break;
|
||||
case UPLOAD_ERR_CANT_WRITE:
|
||||
$message = \G::LoadTranslation( 'ID_UPLOAD_ERR_CANT_WRITE' );
|
||||
break;
|
||||
case UPLOAD_ERR_EXTENSION:
|
||||
$message = \G::LoadTranslation( 'ID_UPLOAD_ERR_EXTENSION' );
|
||||
break;
|
||||
default:
|
||||
$message = \G::LoadTranslation( 'ID_UPLOAD_ERR_UNKNOWN' );
|
||||
break;
|
||||
}
|
||||
\G::SendMessageText( $message, "ERROR" );
|
||||
$backUrlObj = explode( "sys" . SYS_SYS, $_SERVER['HTTP_REFERER'] );
|
||||
\G::header( "location: " . "/sys" . SYS_SYS . $backUrlObj[1] );
|
||||
die();
|
||||
}
|
||||
|
||||
\G::LoadClass("case");
|
||||
|
||||
//$inputDocumentUid = $_GET["UID"]; //$_POST["form"]["DOC_UID"]
|
||||
$appDocUid = '';
|
||||
//$appDocUid = $_POST["form"]["APP_DOC_UID"];
|
||||
$docVersion = '';
|
||||
//$docVersion = intval($_POST["form"]["docVersion"]);
|
||||
$appDocType = 'INPUT';
|
||||
//$appDocType = $_POST["form"]["APP_DOC_TYPE"];
|
||||
$appDocComment = (isset($_POST["form"]["APP_DOC_COMMENT"]))? $_POST["form"]["APP_DOC_COMMENT"] : "";
|
||||
$actionType = $_POST["form"]["actionType"];
|
||||
|
||||
$case = new \Cases();
|
||||
$case->thisIsTheCurrentUser($_SESSION["APPLICATION"], $_SESSION["INDEX"], $_SESSION["USER_LOGGED"], "REDIRECT", "casesListExtJs");
|
||||
|
||||
//Load the fields
|
||||
$arrayField = $case->loadCase($_SESSION["APPLICATION"]);
|
||||
$arrayField["APP_DATA"] = array_merge($arrayField["APP_DATA"], \G::getSystemConstants());
|
||||
|
||||
//Triggers
|
||||
$arrayTrigger = $case->loadTriggers($_SESSION["TASK"], "INPUT_DOCUMENT", $outputDocumentUid, "AFTER");
|
||||
|
||||
|
||||
//Add Input Document
|
||||
if (isset($_FILES) && isset($_FILES["form"]) && count($_FILES["form"]) > 0) {
|
||||
$appDocUid = $case->addInputDocument(
|
||||
$outputDocumentUid,
|
||||
$appDocUid,
|
||||
$docVersion,
|
||||
$appDocType,
|
||||
$appDocComment,
|
||||
$actionType,
|
||||
$_SESSION["APPLICATION"],
|
||||
$_SESSION["INDEX"],
|
||||
$_SESSION["TASK"],
|
||||
$_SESSION["USER_LOGGED"],
|
||||
"xmlform",
|
||||
$_FILES["form"]["name"]["APP_DOC_FILENAME"],
|
||||
$_FILES["form"]["error"]["APP_DOC_FILENAME"],
|
||||
$_FILES["form"]["tmp_name"]["APP_DOC_FILENAME"]
|
||||
);
|
||||
}
|
||||
|
||||
if ($_SESSION["TRIGGER_DEBUG"]["NUM_TRIGGERS"] > 0) {
|
||||
//Trigger - Execute after - Start
|
||||
$arrayField["APP_DATA"] = $case->executeTriggers(
|
||||
$_SESSION["TASK"],
|
||||
"INPUT_DOCUMENT",
|
||||
$outputDocumentUid,
|
||||
"AFTER",
|
||||
$arrayField["APP_DATA"]
|
||||
);
|
||||
//Trigger - Execute after - End
|
||||
}
|
||||
|
||||
//Save data
|
||||
$arrayData = array();
|
||||
$arrayData["APP_NUMBER"] = $arrayField["APP_NUMBER"];
|
||||
//$arrayData["APP_PROC_STATUS"] = $arrayField["APP_PROC_STATUS"];
|
||||
$arrayData["APP_DATA"] = $arrayField["APP_DATA"];
|
||||
$arrayData["DEL_INDEX"] = $_SESSION["INDEX"];
|
||||
$arrayData["TAS_UID"] = $_SESSION["TASK"];
|
||||
|
||||
$case->updateCase($_SESSION["APPLICATION"], $arrayData);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
namespace Services\Api\ProcessMaker\Cases;
|
||||
|
||||
use \ProcessMaker\Services\Api;
|
||||
use \Luracast\Restler\RestException;
|
||||
|
||||
/**
|
||||
* Cases\InputDocument Api Controller
|
||||
*
|
||||
* @protected
|
||||
*/
|
||||
class InputDocument extends Api
|
||||
{
|
||||
/**
|
||||
* @url GET /:cas_uid/input-documents
|
||||
*
|
||||
* @param string $cas_uid {@min 32}{@max 32}
|
||||
*/
|
||||
public function doGetInputDocuments($cas_uid)
|
||||
{
|
||||
try {
|
||||
$userUid = $this->getUserId();
|
||||
$inputDocument = new \BusinessModel\Cases\InputDocument();
|
||||
$response = $inputDocument->getCasesInputDocuments($cas_uid, $userUid);
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @url GET /:cas_uid/input-document/:inp_doc_uid
|
||||
*
|
||||
* @param string $cas_uid {@min 32}{@max 32}
|
||||
* @param string $inp_doc_uid {@min 32}{@max 32}
|
||||
*/
|
||||
public function doGetInputDocument($cas_uid, $inp_doc_uid)
|
||||
{
|
||||
try {
|
||||
$userUid = $this->getUserId();
|
||||
$inputDocument = new \BusinessModel\Cases\InputDocument();
|
||||
$response = $inputDocument->getCasesInputDocument($cas_uid, $userUid, $inp_doc_uid);
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @url DELETE /:cas_uid/input-document/:inp_doc_uid
|
||||
*
|
||||
* @param string $cas_uid {@min 32}{@max 32}
|
||||
* @param string $inp_doc_uid {@min 32}{@max 32}
|
||||
*/
|
||||
public function doDeleteInputDocument($cas_uid, $inp_doc_uid)
|
||||
{
|
||||
try {
|
||||
$inputDocument = new \BusinessModel\Cases\InputDocument();
|
||||
$inputDocument->removeInputDocument($inp_doc_uid);
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @url POST /:cas_uid/input-document
|
||||
*
|
||||
* @param string $cas_uid {@min 32}{@max 32}
|
||||
* @param string $inp_doc_uid {@min 32}{@max 32}
|
||||
*/
|
||||
public function doPostInputDocument($cas_uid, $inp_doc_uid)
|
||||
{
|
||||
try {
|
||||
$userUid = $this->getUserId();
|
||||
$inputDocument = new \BusinessModel\Cases\InputDocument();
|
||||
$response = $inputDocument->addCasesInputDocument($cas_uid, $inp_doc_uid, $userUid);
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
namespace Services\Api\ProcessMaker\Cases;
|
||||
|
||||
use \ProcessMaker\Services\Api;
|
||||
use \Luracast\Restler\RestException;
|
||||
|
||||
/**
|
||||
* Cases\OutputDocument Api Controller
|
||||
*
|
||||
* @protected
|
||||
*/
|
||||
class OutputDocument extends Api
|
||||
{
|
||||
/**
|
||||
* @url GET /:cas_uid/output-documents
|
||||
*
|
||||
* @param string $cas_uid {@min 32}{@max 32}
|
||||
*/
|
||||
public function doGetOutputDocuments($cas_uid)
|
||||
{
|
||||
try {
|
||||
$userUid = $this->getUserId();
|
||||
$outputDocument = new \BusinessModel\Cases\OutputDocument();
|
||||
$response = $outputDocument->getCasesOutputDocuments($cas_uid, $userUid);
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @url GET /:cas_uid/output-document/:out_doc_uid
|
||||
*
|
||||
* @param string $cas_uid {@min 32}{@max 32}
|
||||
* @param string $out_doc_uid {@min 32}{@max 32}
|
||||
*/
|
||||
public function doGetOutputDocument($cas_uid, $out_doc_uid)
|
||||
{
|
||||
try {
|
||||
$userUid = $this->getUserId();
|
||||
$outputDocument = new \BusinessModel\Cases\OutputDocument();
|
||||
$response = $outputDocument->getCasesOutputDocument($cas_uid, $userUid, $out_doc_uid);
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @url DELETE /:cas_uid/output-document/:out_doc_uid
|
||||
*
|
||||
* @param string $cas_uid {@min 32}{@max 32}
|
||||
* @param string $out_doc_uid {@min 32}{@max 32}
|
||||
*/
|
||||
public function doDeleteOutputDocument($cas_uid, $out_doc_uid)
|
||||
{
|
||||
try {
|
||||
$outputDocument = new \BusinessModel\Cases\OutputDocument();
|
||||
$outputDocument->removeOutputDocument($out_doc_uid);
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @url POST /:cas_uid/output-document
|
||||
*
|
||||
* @param string $cas_uid {@min 32}{@max 32}
|
||||
* @param string $out_doc_uid {@min 32}{@max 32}
|
||||
*/
|
||||
public function doPostOutputDocument($cas_uid, $out_doc_uid)
|
||||
{
|
||||
try {
|
||||
$userUid = $this->getUserId();
|
||||
$outputDocument = new \BusinessModel\Cases\OutputDocument();
|
||||
$response = $outputDocument->addCasesOutputDocument($cas_uid, $out_doc_uid, $userUid);
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -64,4 +64,5 @@ debug = 1
|
||||
|
||||
[alias: cases]
|
||||
case = "Services\Api\ProcessMaker\Case"
|
||||
input-document = "Services\Api\ProcessMaker\Cases\InputDocument"
|
||||
input-document = "Services\Api\ProcessMaker\Cases\InputDocument"
|
||||
output-document = "Services\Api\ProcessMaker\Cases\OutputDocument"
|
||||
Reference in New Issue
Block a user