|
|
|
|
@@ -2,25 +2,48 @@
|
|
|
|
|
namespace ProcessMaker\BusinessModel\Cases;
|
|
|
|
|
|
|
|
|
|
use ProcessMaker\Plugins\PluginRegistry;
|
|
|
|
|
use AppDocument;
|
|
|
|
|
use AppDocumentPeer;
|
|
|
|
|
use Exception;
|
|
|
|
|
use Criteria;
|
|
|
|
|
use ResultSet;
|
|
|
|
|
use G;
|
|
|
|
|
use ObjectPermissionPeer;
|
|
|
|
|
use StepPeer;
|
|
|
|
|
use StepSupervisorPeer;
|
|
|
|
|
use AppDelegation;
|
|
|
|
|
use AppDelegationPeer;
|
|
|
|
|
use Users;
|
|
|
|
|
use Configurations;
|
|
|
|
|
use Bootstrap;
|
|
|
|
|
use WsBase;
|
|
|
|
|
use ApplicationPeer;
|
|
|
|
|
use ProcessMaker\BusinessModel\ProcessSupervisor;
|
|
|
|
|
use ProcessMaker\BusinessModel\Cases AS BusinessModelCases;
|
|
|
|
|
use Cases;
|
|
|
|
|
use ProcessUserPeer;
|
|
|
|
|
use AppFolder;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class InputDocument
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Verify exists app_doc_uid in table APP_DOCUMENT
|
|
|
|
|
*
|
|
|
|
|
* @param string $applicationUid
|
|
|
|
|
* @param string $appDocumentUid
|
|
|
|
|
*
|
|
|
|
|
* return void Throw exception
|
|
|
|
|
* @return void Throw exception
|
|
|
|
|
* @throws Exception
|
|
|
|
|
*/
|
|
|
|
|
private function throwExceptionIfNotExistsAppDocument($appDocumentUid)
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$appDocument = \AppDocumentPeer::retrieveByPK($appDocumentUid, 1);
|
|
|
|
|
$appDocument = AppDocumentPeer::retrieveByPK($appDocumentUid, 1);
|
|
|
|
|
|
|
|
|
|
if (is_null($appDocument)) {
|
|
|
|
|
throw new \Exception(\G::LoadTranslation("ID_CASES_INPUT_DOES_NOT_EXIST", array($appDocumentUid)));
|
|
|
|
|
throw new Exception(G::LoadTranslation("ID_CASES_INPUT_DOES_NOT_EXIST", array($appDocumentUid)));
|
|
|
|
|
}
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
} catch (Exception $e) {
|
|
|
|
|
throw $e;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@@ -31,15 +54,16 @@ class InputDocument
|
|
|
|
|
* @param string $applicationUid Unique id of Case
|
|
|
|
|
* @param string $delIndex Delegataion index
|
|
|
|
|
* @param string $userUid Unique id of User
|
|
|
|
|
* @param string $inputDocumentUid
|
|
|
|
|
* @param string $appDocumentUid
|
|
|
|
|
*
|
|
|
|
|
* return void Throw exception the user does not have permission to delete
|
|
|
|
|
* @return void Throw exception the user does not have permission to delete
|
|
|
|
|
* @throws Exception
|
|
|
|
|
*/
|
|
|
|
|
public function throwExceptionIfHaventPermissionToDelete($applicationUid, $delIndex, $userUid, $appDocumentUid)
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
//Verify data inbox
|
|
|
|
|
$case = new \ProcessMaker\BusinessModel\Cases();
|
|
|
|
|
$case = new BusinessModelCases();
|
|
|
|
|
$arrayResult = $case->getStatusInfo($applicationUid, $delIndex, $userUid);
|
|
|
|
|
|
|
|
|
|
$flagInbox = 1;
|
|
|
|
|
@@ -49,11 +73,11 @@ class InputDocument
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Verify data Supervisor
|
|
|
|
|
$application = \ApplicationPeer::retrieveByPK($applicationUid);
|
|
|
|
|
$application = ApplicationPeer::retrieveByPK($applicationUid);
|
|
|
|
|
|
|
|
|
|
$flagSupervisor = 0;
|
|
|
|
|
|
|
|
|
|
$supervisor = new \ProcessMaker\BusinessModel\ProcessSupervisor();
|
|
|
|
|
$supervisor = new ProcessSupervisor();
|
|
|
|
|
$processSupervisor= $supervisor->getProcessSupervisors($application->getProUid(), "ASSIGNED");
|
|
|
|
|
|
|
|
|
|
$arraySupervisor = $processSupervisor["data"];
|
|
|
|
|
@@ -66,7 +90,7 @@ class InputDocument
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($flagInbox == 0 && $flagSupervisor == 0) {
|
|
|
|
|
throw new \Exception(\G::LoadTranslation("ID_USER_NOT_HAVE_PERMISSION_DELETE_INPUT_DOCUMENT", array($userUid)));
|
|
|
|
|
throw new Exception(G::LoadTranslation("ID_USER_NOT_HAVE_PERMISSION_DELETE_INPUT_DOCUMENT", array($userUid)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//verfiry exists $appDocumentUid
|
|
|
|
|
@@ -75,16 +99,16 @@ class InputDocument
|
|
|
|
|
//Verify data permission
|
|
|
|
|
$flagPermission = 0;
|
|
|
|
|
|
|
|
|
|
$criteria = new \Criteria("workflow");
|
|
|
|
|
$criteria = new Criteria("workflow");
|
|
|
|
|
|
|
|
|
|
$criteria->addSelectColumn(\AppDocumentPeer::DOC_UID);
|
|
|
|
|
$criteria->addSelectColumn(AppDocumentPeer::DOC_UID);
|
|
|
|
|
|
|
|
|
|
$criteria->add(\AppDocumentPeer::APP_DOC_UID, $appDocumentUid, \Criteria::EQUAL);
|
|
|
|
|
$criteria->add(\AppDocumentPeer::APP_UID, $applicationUid, \Criteria::EQUAL);
|
|
|
|
|
$criteria->add(\AppDocumentPeer::APP_DOC_TYPE, "INPUT", \Criteria::EQUAL);
|
|
|
|
|
$criteria->add(AppDocumentPeer::APP_DOC_UID, $appDocumentUid, Criteria::EQUAL);
|
|
|
|
|
$criteria->add(AppDocumentPeer::APP_UID, $applicationUid, Criteria::EQUAL);
|
|
|
|
|
$criteria->add(AppDocumentPeer::APP_DOC_TYPE, "INPUT", Criteria::EQUAL);
|
|
|
|
|
|
|
|
|
|
$rsCriteria = \AppDocumentPeer::doSelectRS($criteria);
|
|
|
|
|
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
|
|
|
|
$rsCriteria = AppDocumentPeer::doSelectRS($criteria);
|
|
|
|
|
$rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
|
|
|
|
|
|
|
|
|
if ($rsCriteria->next()) {
|
|
|
|
|
$row = $rsCriteria->getRow();
|
|
|
|
|
@@ -92,27 +116,27 @@ class InputDocument
|
|
|
|
|
$inputDocumentUid = $row["DOC_UID"];
|
|
|
|
|
|
|
|
|
|
//Criteria
|
|
|
|
|
$criteria2 = new \Criteria("workflow");
|
|
|
|
|
$criteria2 = new Criteria("workflow");
|
|
|
|
|
|
|
|
|
|
$criteria2->addSelectColumn(\ObjectPermissionPeer::OP_UID);
|
|
|
|
|
$criteria2->addSelectColumn(ObjectPermissionPeer::OP_UID);
|
|
|
|
|
|
|
|
|
|
$criteria2->add(\ObjectPermissionPeer::PRO_UID, $application->getProUid(), \Criteria::EQUAL);
|
|
|
|
|
$criteria2->add(\ObjectPermissionPeer::OP_OBJ_TYPE, "INPUT", \Criteria::EQUAL);
|
|
|
|
|
$criteria2->add(ObjectPermissionPeer::PRO_UID, $application->getProUid(), Criteria::EQUAL);
|
|
|
|
|
$criteria2->add(ObjectPermissionPeer::OP_OBJ_TYPE, "INPUT", Criteria::EQUAL);
|
|
|
|
|
$criteria2->add(
|
|
|
|
|
$criteria2->getNewCriterion(\ObjectPermissionPeer::OP_OBJ_UID, $inputDocumentUid, \Criteria::EQUAL)->addOr(
|
|
|
|
|
$criteria2->getNewCriterion(\ObjectPermissionPeer::OP_OBJ_UID, "0", \Criteria::EQUAL))->addOr(
|
|
|
|
|
$criteria2->getNewCriterion(\ObjectPermissionPeer::OP_OBJ_UID, "", \Criteria::EQUAL))
|
|
|
|
|
$criteria2->getNewCriterion(ObjectPermissionPeer::OP_OBJ_UID, $inputDocumentUid, Criteria::EQUAL)->addOr(
|
|
|
|
|
$criteria2->getNewCriterion(ObjectPermissionPeer::OP_OBJ_UID, "0", Criteria::EQUAL))->addOr(
|
|
|
|
|
$criteria2->getNewCriterion(ObjectPermissionPeer::OP_OBJ_UID, "", Criteria::EQUAL))
|
|
|
|
|
);
|
|
|
|
|
$criteria2->add(\ObjectPermissionPeer::OP_ACTION, "DELETE", \Criteria::EQUAL);
|
|
|
|
|
$criteria2->add(ObjectPermissionPeer::OP_ACTION, "DELETE", Criteria::EQUAL);
|
|
|
|
|
|
|
|
|
|
//User
|
|
|
|
|
$criteriaU = clone $criteria2;
|
|
|
|
|
|
|
|
|
|
$criteriaU->add(\ObjectPermissionPeer::OP_USER_RELATION, 1, \Criteria::EQUAL);
|
|
|
|
|
$criteriaU->add(\ObjectPermissionPeer::USR_UID, $userUid, \Criteria::EQUAL);
|
|
|
|
|
$criteriaU->add(ObjectPermissionPeer::OP_USER_RELATION, 1, Criteria::EQUAL);
|
|
|
|
|
$criteriaU->add(ObjectPermissionPeer::USR_UID, $userUid, Criteria::EQUAL);
|
|
|
|
|
|
|
|
|
|
$rsCriteriaU = \ObjectPermissionPeer::doSelectRS($criteriaU);
|
|
|
|
|
$rsCriteriaU->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
|
|
|
|
$rsCriteriaU = ObjectPermissionPeer::doSelectRS($criteriaU);
|
|
|
|
|
$rsCriteriaU->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
|
|
|
|
|
|
|
|
|
if ($rsCriteriaU->next()) {
|
|
|
|
|
$flagPermission = 1;
|
|
|
|
|
@@ -122,13 +146,13 @@ class InputDocument
|
|
|
|
|
if ($flagPermission == 0) {
|
|
|
|
|
$criteriaG = clone $criteria2;
|
|
|
|
|
|
|
|
|
|
$criteriaG->add(\ObjectPermissionPeer::OP_USER_RELATION, 2, \Criteria::EQUAL);
|
|
|
|
|
$criteriaG->add(ObjectPermissionPeer::OP_USER_RELATION, 2, Criteria::EQUAL);
|
|
|
|
|
|
|
|
|
|
$criteriaG->addJoin(\ObjectPermissionPeer::USR_UID, \GroupUserPeer::GRP_UID, \Criteria::LEFT_JOIN);
|
|
|
|
|
$criteriaG->add(\GroupUserPeer::USR_UID, $userUid, \Criteria::EQUAL);
|
|
|
|
|
$criteriaG->addJoin(ObjectPermissionPeer::USR_UID, GroupUserPeer::GRP_UID, Criteria::LEFT_JOIN);
|
|
|
|
|
$criteriaG->add(GroupUserPeer::USR_UID, $userUid, Criteria::EQUAL);
|
|
|
|
|
|
|
|
|
|
$rsCriteriaG = \ObjectPermissionPeer::doSelectRS($criteriaG);
|
|
|
|
|
$rsCriteriaG->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
|
|
|
|
$rsCriteriaG = ObjectPermissionPeer::doSelectRS($criteriaG);
|
|
|
|
|
$rsCriteriaG->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
|
|
|
|
|
|
|
|
|
if ($rsCriteriaG->next()) {
|
|
|
|
|
$flagPermission = 1;
|
|
|
|
|
@@ -137,9 +161,9 @@ class InputDocument
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($flagPermission == 0) {
|
|
|
|
|
throw new \Exception(\G::LoadTranslation("ID_USER_NOT_HAVE_PERMISSION_DELETE_INPUT_DOCUMENT", array($userUid)));
|
|
|
|
|
throw new Exception(G::LoadTranslation("ID_USER_NOT_HAVE_PERMISSION_DELETE_INPUT_DOCUMENT", array($userUid)));
|
|
|
|
|
}
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
} catch (Exception $e) {
|
|
|
|
|
throw $e;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@@ -151,53 +175,54 @@ class InputDocument
|
|
|
|
|
* @param string $delIndex Delegataion index
|
|
|
|
|
* @param string $appDocumentUid
|
|
|
|
|
*
|
|
|
|
|
* return void Throw exception if not exists input Document in Steps
|
|
|
|
|
* @return void Throw exception if not exists input Document in Steps
|
|
|
|
|
* @throws Exception
|
|
|
|
|
*/
|
|
|
|
|
public function throwExceptionIfInputDocumentNotExistsInSteps($applicacionUid, $delIndex, $appDocumentUid)
|
|
|
|
|
public function throwExceptionIfInputDocumentNotExistsInSteps($applicationUid, $delIndex, $appDocumentUid)
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
//Verify Case
|
|
|
|
|
$appDelegation = \AppDelegationPeer::retrieveByPK($applicacionUid, $delIndex);
|
|
|
|
|
$appDelegation = AppDelegationPeer::retrieveByPK($applicationUid, $delIndex);
|
|
|
|
|
|
|
|
|
|
if (is_null($appDelegation)) {
|
|
|
|
|
throw new \Exception(\G::LoadTranslation("ID_CASE_DEL_INDEX_DOES_NOT_EXIST", array("app_uid", $applicacionUid, "del_index", $delIndex)));
|
|
|
|
|
throw new Exception(G::LoadTranslation("ID_CASE_DEL_INDEX_DOES_NOT_EXIST", array("app_uid", $applicationUid, "del_index", $delIndex)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$taskUid = $appDelegation->getTasUid();
|
|
|
|
|
|
|
|
|
|
//Verify Steps
|
|
|
|
|
$criteria = new \Criteria("workflow");
|
|
|
|
|
$criteria = new Criteria("workflow");
|
|
|
|
|
|
|
|
|
|
$criteria->addSelectColumn(\AppDocumentPeer::DOC_UID);
|
|
|
|
|
$criteria->addSelectColumn(AppDocumentPeer::DOC_UID);
|
|
|
|
|
|
|
|
|
|
$criteria->add(\AppDocumentPeer::APP_DOC_UID, $appDocumentUid, \Criteria::EQUAL);
|
|
|
|
|
$criteria->add(\AppDocumentPeer::APP_UID, $applicacionUid, \Criteria::EQUAL);
|
|
|
|
|
$criteria->add(\AppDocumentPeer::APP_DOC_TYPE, "INPUT", \Criteria::EQUAL);
|
|
|
|
|
$criteria->add(AppDocumentPeer::APP_DOC_UID, $appDocumentUid, Criteria::EQUAL);
|
|
|
|
|
$criteria->add(AppDocumentPeer::APP_UID, $applicationUid, Criteria::EQUAL);
|
|
|
|
|
$criteria->add(AppDocumentPeer::APP_DOC_TYPE, "INPUT", Criteria::EQUAL);
|
|
|
|
|
|
|
|
|
|
$rsCriteria = \AppDocumentPeer::doSelectRS($criteria);
|
|
|
|
|
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
|
|
|
|
$rsCriteria = AppDocumentPeer::doSelectRS($criteria);
|
|
|
|
|
$rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
|
|
|
|
|
|
|
|
|
if ($rsCriteria->next()) {
|
|
|
|
|
$row = $rsCriteria->getRow();
|
|
|
|
|
|
|
|
|
|
$inputDocumentUid = $row["DOC_UID"];
|
|
|
|
|
|
|
|
|
|
$criteria = new \Criteria("workflow");
|
|
|
|
|
$criteria = new Criteria("workflow");
|
|
|
|
|
|
|
|
|
|
$criteria->addSelectColumn(\StepPeer::STEP_UID);
|
|
|
|
|
$criteria->addSelectColumn(StepPeer::STEP_UID);
|
|
|
|
|
|
|
|
|
|
$criteria->add(\StepPeer::TAS_UID, $taskUid, \Criteria::EQUAL);
|
|
|
|
|
$criteria->add(\StepPeer::STEP_TYPE_OBJ, "INPUT_DOCUMENT", \Criteria::EQUAL);
|
|
|
|
|
$criteria->add(\StepPeer::STEP_UID_OBJ, $inputDocumentUid, \Criteria::EQUAL);
|
|
|
|
|
$criteria->add(StepPeer::TAS_UID, $taskUid, Criteria::EQUAL);
|
|
|
|
|
$criteria->add(StepPeer::STEP_TYPE_OBJ, "INPUT_DOCUMENT", Criteria::EQUAL);
|
|
|
|
|
$criteria->add(StepPeer::STEP_UID_OBJ, $inputDocumentUid, Criteria::EQUAL);
|
|
|
|
|
|
|
|
|
|
$rsCriteria = \StepPeer::doSelectRS($criteria);
|
|
|
|
|
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
|
|
|
|
$rsCriteria = StepPeer::doSelectRS($criteria);
|
|
|
|
|
$rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
|
|
|
|
|
|
|
|
|
if (!$rsCriteria->next()) {
|
|
|
|
|
throw new \Exception(\G::LoadTranslation("ID_CASES_INPUT_DOCUMENT_DOES_NOT_EXIST", array($appDocumentUid)));
|
|
|
|
|
throw new Exception(G::LoadTranslation("ID_CASES_INPUT_DOCUMENT_DOES_NOT_EXIST", array($appDocumentUid)));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
} catch (Exception $e) {
|
|
|
|
|
throw $e;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@@ -205,39 +230,40 @@ class InputDocument
|
|
|
|
|
/**
|
|
|
|
|
* Get criteria for AppDocument
|
|
|
|
|
*
|
|
|
|
|
* return object
|
|
|
|
|
* @return object
|
|
|
|
|
* @throws Exception
|
|
|
|
|
*/
|
|
|
|
|
public function getAppDocumentCriteriaByData($applicationUid)
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$criteria = new \Criteria("workflow");
|
|
|
|
|
$criteria = new Criteria("workflow");
|
|
|
|
|
|
|
|
|
|
$criteria->addSelectColumn(\AppDocumentPeer::APP_DOC_UID);
|
|
|
|
|
$criteria->addSelectColumn(\AppDocumentPeer::DOC_VERSION);
|
|
|
|
|
$criteria->addSelectColumn(\AppDocumentPeer::DOC_UID);
|
|
|
|
|
$criteria->addSelectColumn(\AppDocumentPeer::USR_UID);
|
|
|
|
|
$criteria->addSelectColumn(\AppDocumentPeer::APP_DOC_TYPE);
|
|
|
|
|
$criteria->addSelectColumn(\AppDocumentPeer::APP_DOC_CREATE_DATE);
|
|
|
|
|
$criteria->addSelectColumn(\AppDocumentPeer::APP_DOC_INDEX);
|
|
|
|
|
$criteria->addSelectColumn(AppDocumentPeer::APP_DOC_UID);
|
|
|
|
|
$criteria->addSelectColumn(AppDocumentPeer::DOC_VERSION);
|
|
|
|
|
$criteria->addSelectColumn(AppDocumentPeer::DOC_UID);
|
|
|
|
|
$criteria->addSelectColumn(AppDocumentPeer::USR_UID);
|
|
|
|
|
$criteria->addSelectColumn(AppDocumentPeer::APP_DOC_TYPE);
|
|
|
|
|
$criteria->addSelectColumn(AppDocumentPeer::APP_DOC_CREATE_DATE);
|
|
|
|
|
$criteria->addSelectColumn(AppDocumentPeer::APP_DOC_INDEX);
|
|
|
|
|
|
|
|
|
|
$sql = "
|
|
|
|
|
SELECT MAX(APPDOC.DOC_VERSION)
|
|
|
|
|
FROM " . \AppDocumentPeer::TABLE_NAME . " AS APPDOC
|
|
|
|
|
WHERE APPDOC.APP_DOC_UID = " . \AppDocumentPeer::APP_DOC_UID . "
|
|
|
|
|
FROM " . AppDocumentPeer::TABLE_NAME . " AS APPDOC
|
|
|
|
|
WHERE APPDOC.APP_DOC_UID = " . AppDocumentPeer::APP_DOC_UID . "
|
|
|
|
|
";
|
|
|
|
|
|
|
|
|
|
$criteria->add(
|
|
|
|
|
$criteria->getNewCriterion(\AppDocumentPeer::APP_UID, $applicationUid, \Criteria::EQUAL)->addAnd(
|
|
|
|
|
$criteria->getNewCriterion(\AppDocumentPeer::APP_DOC_TYPE, array("INPUT", "ATTACHED"), \Criteria::IN))->addAnd(
|
|
|
|
|
$criteria->getNewCriterion(\AppDocumentPeer::APP_DOC_STATUS, array("ACTIVE"), \Criteria::IN))->addAnd(
|
|
|
|
|
$criteria->getNewCriterion(\AppDocumentPeer::DOC_VERSION, \AppDocumentPeer::DOC_VERSION . " IN ($sql)", \Criteria::CUSTOM))
|
|
|
|
|
$criteria->getNewCriterion(AppDocumentPeer::APP_UID, $applicationUid, Criteria::EQUAL)->addAnd(
|
|
|
|
|
$criteria->getNewCriterion(AppDocumentPeer::APP_DOC_TYPE, array("INPUT", "ATTACHED"), Criteria::IN))->addAnd(
|
|
|
|
|
$criteria->getNewCriterion(AppDocumentPeer::APP_DOC_STATUS, array("ACTIVE"), Criteria::IN))->addAnd(
|
|
|
|
|
$criteria->getNewCriterion(AppDocumentPeer::DOC_VERSION, AppDocumentPeer::DOC_VERSION . " IN ($sql)", Criteria::CUSTOM))
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$criteria->addAscendingOrderByColumn(\AppDocumentPeer::APP_DOC_INDEX);
|
|
|
|
|
$criteria->addAscendingOrderByColumn(AppDocumentPeer::APP_DOC_INDEX);
|
|
|
|
|
|
|
|
|
|
//Return
|
|
|
|
|
return $criteria;
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
} catch (Exception $e) {
|
|
|
|
|
throw $e;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@@ -247,23 +273,43 @@ class InputDocument
|
|
|
|
|
*
|
|
|
|
|
* @param array $record Record
|
|
|
|
|
*
|
|
|
|
|
* return array Return an array with data AppDocument
|
|
|
|
|
* @return array Return an array with data AppDocument
|
|
|
|
|
* @throws Exception
|
|
|
|
|
*/
|
|
|
|
|
public function getAppDocumentDataFromRecord(array $record)
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
return array(
|
|
|
|
|
"app_doc_uid" => $record["APP_DOC_UID"],
|
|
|
|
|
"app_doc_filename" => $record["APP_DOC_FILENAME"],
|
|
|
|
|
"doc_uid" => $record["DOC_UID"],
|
|
|
|
|
"app_doc_version" => $record["DOC_VERSION"],
|
|
|
|
|
"app_doc_create_date" => $record["APP_DOC_CREATE_DATE"],
|
|
|
|
|
"app_doc_create_user" => $record["APP_DOC_CREATE_USER"],
|
|
|
|
|
"app_doc_type" => $record["APP_DOC_TYPE"],
|
|
|
|
|
"app_doc_index" => (int)($record["APP_DOC_INDEX"]),
|
|
|
|
|
"app_doc_link" => $record["APP_DOC_LINK"]
|
|
|
|
|
);
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
$newArray = array();
|
|
|
|
|
if (isset($record["APP_DOC_UID"])) {
|
|
|
|
|
$newArray["app_doc_uid"] = $record["APP_DOC_UID"];
|
|
|
|
|
}
|
|
|
|
|
if (isset($record["APP_DOC_FILENAME"])) {
|
|
|
|
|
$newArray["app_doc_filename"] = $record["APP_DOC_FILENAME"];
|
|
|
|
|
}
|
|
|
|
|
if (isset($record["DOC_UID"])) {
|
|
|
|
|
$newArray["doc_uid"] = $record["DOC_UID"];
|
|
|
|
|
}
|
|
|
|
|
if (isset($record["DOC_VERSION"])) {
|
|
|
|
|
$newArray["app_doc_version"] = $record["DOC_VERSION"];
|
|
|
|
|
}
|
|
|
|
|
if (isset($record["APP_DOC_CREATE_DATE"])) {
|
|
|
|
|
$newArray["app_doc_create_date"] = $record["APP_DOC_CREATE_DATE"];
|
|
|
|
|
}
|
|
|
|
|
if (isset($record["APP_DOC_CREATE_USER"])) {
|
|
|
|
|
$newArray["app_doc_create_user"] = $record["APP_DOC_CREATE_USER"];
|
|
|
|
|
}
|
|
|
|
|
if (isset($record["APP_DOC_TYPE"])) {
|
|
|
|
|
$newArray["app_doc_type"] = $record["APP_DOC_TYPE"];
|
|
|
|
|
}
|
|
|
|
|
if (isset($record["APP_DOC_INDEX"])) {
|
|
|
|
|
$newArray["app_doc_index"] = $record["APP_DOC_INDEX"];
|
|
|
|
|
}
|
|
|
|
|
if (isset($record["APP_DOC_LINK"])) {
|
|
|
|
|
$newArray["app_doc_link"] = $record["APP_DOC_LINK"];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $newArray;
|
|
|
|
|
} catch (Exception $e) {
|
|
|
|
|
throw $e;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@@ -274,17 +320,18 @@ class InputDocument
|
|
|
|
|
* @param string $applicationUid Unique id of Case
|
|
|
|
|
* @param string $userUid Unique id of User
|
|
|
|
|
*
|
|
|
|
|
* return array Return data of input documents
|
|
|
|
|
* @return array Return data of input documents
|
|
|
|
|
* @throws Exception
|
|
|
|
|
*/
|
|
|
|
|
public function getCasesInputDocumentsBySupervisor($applicationUid, $userUid)
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
//Verify data Supervisor
|
|
|
|
|
$application = \ApplicationPeer::retrieveByPK($applicationUid);
|
|
|
|
|
$application = ApplicationPeer::retrieveByPK($applicationUid);
|
|
|
|
|
|
|
|
|
|
$flagSupervisor = 0;
|
|
|
|
|
|
|
|
|
|
$supervisor = new \ProcessMaker\BusinessModel\ProcessSupervisor();
|
|
|
|
|
$supervisor = new ProcessSupervisor();
|
|
|
|
|
$processSupervisor = $supervisor->getProcessSupervisors($application->getProUid(), "ASSIGNED");
|
|
|
|
|
$arraySupervisor = $processSupervisor["data"];
|
|
|
|
|
|
|
|
|
|
@@ -295,9 +342,9 @@ class InputDocument
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$user = new \Users();
|
|
|
|
|
$appDocument = new \AppDocument();
|
|
|
|
|
$configuraction = new \Configurations();
|
|
|
|
|
$user = new Users();
|
|
|
|
|
$appDocument = new AppDocument();
|
|
|
|
|
$configuraction = new Configurations();
|
|
|
|
|
|
|
|
|
|
$confEnvSetting = $configuraction->getFormats();
|
|
|
|
|
|
|
|
|
|
@@ -306,8 +353,8 @@ class InputDocument
|
|
|
|
|
//Query
|
|
|
|
|
$criteria = $this->getAppDocumentCriteriaByData($applicationUid);
|
|
|
|
|
|
|
|
|
|
$rsCriteria = \AppDocumentPeer::doSelectRS($criteria);
|
|
|
|
|
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
|
|
|
|
$rsCriteria = AppDocumentPeer::doSelectRS($criteria);
|
|
|
|
|
$rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
|
|
|
|
|
|
|
|
|
while ($rsCriteria->next()) {
|
|
|
|
|
$row = $rsCriteria->getRow();
|
|
|
|
|
@@ -324,12 +371,12 @@ class InputDocument
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!empty($arrayInputDocument) && $flagSupervisor == 0) {
|
|
|
|
|
throw new \Exception(\G::LoadTranslation("ID_USER_IS_NOT_SUPERVISOR"));
|
|
|
|
|
throw new Exception(G::LoadTranslation("ID_USER_IS_NOT_SUPERVISOR"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Return
|
|
|
|
|
return $arrayInputDocument;
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
} catch (Exception $e) {
|
|
|
|
|
throw $e;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@@ -340,13 +387,14 @@ class InputDocument
|
|
|
|
|
* @param string $applicationUid
|
|
|
|
|
* @param string $userUid
|
|
|
|
|
*
|
|
|
|
|
* return array Return an array with data of an InputDocument
|
|
|
|
|
* @return array Return an array with data of an InputDocument
|
|
|
|
|
* @throws Exception
|
|
|
|
|
*/
|
|
|
|
|
public function getCasesInputDocuments($applicationUid, $userUid)
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
//Verify data inbox
|
|
|
|
|
$case = new \ProcessMaker\BusinessModel\Cases();
|
|
|
|
|
$case = new BusinessModelCases();
|
|
|
|
|
$arrayResult = $case->getStatusInfo($applicationUid, 0, $userUid);
|
|
|
|
|
|
|
|
|
|
$flagInbox = true;
|
|
|
|
|
@@ -355,9 +403,9 @@ class InputDocument
|
|
|
|
|
$flagInbox = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$user = new \Users();
|
|
|
|
|
$appDocument = new \AppDocument();
|
|
|
|
|
$configuraction = new \Configurations();
|
|
|
|
|
$user = new Users();
|
|
|
|
|
$appDocument = new AppDocument();
|
|
|
|
|
$configuraction = new Configurations();
|
|
|
|
|
|
|
|
|
|
$confEnvSetting = $configuraction->getFormats();
|
|
|
|
|
|
|
|
|
|
@@ -367,11 +415,11 @@ class InputDocument
|
|
|
|
|
$criteria = $this->getAppDocumentCriteriaByData($applicationUid);
|
|
|
|
|
|
|
|
|
|
if (!$flagInbox) {
|
|
|
|
|
$criteria->add(\AppDocumentPeer::USR_UID, $userUid, \Criteria::EQUAL);
|
|
|
|
|
$criteria->add(AppDocumentPeer::USR_UID, $userUid, Criteria::EQUAL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$rsCriteria = \AppDocumentPeer::doSelectRS($criteria);
|
|
|
|
|
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
|
|
|
|
$rsCriteria = AppDocumentPeer::doSelectRS($criteria);
|
|
|
|
|
$rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
|
|
|
|
|
|
|
|
|
while ($rsCriteria->next()) {
|
|
|
|
|
$row = $rsCriteria->getRow();
|
|
|
|
|
@@ -393,7 +441,7 @@ class InputDocument
|
|
|
|
|
|
|
|
|
|
//Return
|
|
|
|
|
return $arrayInputDocument;
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
} catch (Exception $e) {
|
|
|
|
|
throw $e;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@@ -405,7 +453,8 @@ class InputDocument
|
|
|
|
|
* @param string $userUid
|
|
|
|
|
* @param string $inputDocumentUid
|
|
|
|
|
*
|
|
|
|
|
* return array Return an array with data of an InputDocument
|
|
|
|
|
* @return array Return an array with data of an InputDocument
|
|
|
|
|
* @throws Exception
|
|
|
|
|
*/
|
|
|
|
|
public function getCasesInputDocument($applicationUid, $userUid, $inputDocumentUid)
|
|
|
|
|
{
|
|
|
|
|
@@ -413,11 +462,11 @@ class InputDocument
|
|
|
|
|
$sApplicationUID = $applicationUid;
|
|
|
|
|
$sUserUID = $userUid;
|
|
|
|
|
|
|
|
|
|
$oCase = new \Cases();
|
|
|
|
|
$oCase = new Cases();
|
|
|
|
|
$fields = $oCase->loadCase( $sApplicationUID );
|
|
|
|
|
$sProcessUID = $fields['PRO_UID'];
|
|
|
|
|
$sTaskUID = '';
|
|
|
|
|
$oCaseRest = new \ProcessMaker\BusinessModel\Cases();
|
|
|
|
|
$oCaseRest = new BusinessModelCases();
|
|
|
|
|
$oCaseRest->getAllUploadedDocumentsCriteria( $sProcessUID, $sApplicationUID, $sTaskUID, $sUserUID );
|
|
|
|
|
$result = array ();
|
|
|
|
|
global $_DBArray;
|
|
|
|
|
@@ -439,7 +488,7 @@ class InputDocument
|
|
|
|
|
if ($docrow["app_doc_uid"] == $inputDocumentUid) {
|
|
|
|
|
$flagInputDocument = true;
|
|
|
|
|
|
|
|
|
|
$appDocument = \AppDocumentPeer::retrieveByPK($inputDocumentUid, $row["DOC_VERSION"]);
|
|
|
|
|
$appDocument = AppDocumentPeer::retrieveByPK($inputDocumentUid, $row["DOC_VERSION"]);
|
|
|
|
|
|
|
|
|
|
if (is_null($appDocument)) {
|
|
|
|
|
$flagInputDocument = false;
|
|
|
|
|
@@ -452,12 +501,12 @@ class InputDocument
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!$flagInputDocument) {
|
|
|
|
|
throw new \Exception(\G::LoadTranslation("ID_CASES_INPUT_DOES_NOT_EXIST", array($inputDocumentUid)));
|
|
|
|
|
throw new Exception(G::LoadTranslation("ID_CASES_INPUT_DOES_NOT_EXIST", array($inputDocumentUid)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$oResponse = json_decode(json_encode($result), false);
|
|
|
|
|
return $oResponse;
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
} catch (Exception $e) {
|
|
|
|
|
throw $e;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@@ -468,12 +517,12 @@ class InputDocument
|
|
|
|
|
* @param $app_uid
|
|
|
|
|
* @param $app_doc_uid
|
|
|
|
|
* @param $version
|
|
|
|
|
* @throws \Exception
|
|
|
|
|
* @throws Exception
|
|
|
|
|
*/
|
|
|
|
|
public function downloadInputDocument($app_uid, $app_doc_uid, $version)
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$oAppDocument = new \AppDocument();
|
|
|
|
|
$oAppDocument = new AppDocument();
|
|
|
|
|
if ($version == 0) {
|
|
|
|
|
$docVersion = $oAppDocument->getLastAppDocVersion($app_doc_uid);
|
|
|
|
|
} else {
|
|
|
|
|
@@ -484,8 +533,8 @@ class InputDocument
|
|
|
|
|
$iDocVersion = $oAppDocument->getDocVersion();
|
|
|
|
|
$info = pathinfo($oAppDocument->getAppDocFilename());
|
|
|
|
|
|
|
|
|
|
$app_uid = \G::getPathFromUID($oAppDocument->Fields['APP_UID']);
|
|
|
|
|
$file = \G::getPathFromFileUID($oAppDocument->Fields['APP_UID'], $sAppDocUid);
|
|
|
|
|
$app_uid = G::getPathFromUID($oAppDocument->Fields['APP_UID']);
|
|
|
|
|
$file = G::getPathFromFileUID($oAppDocument->Fields['APP_UID'], $sAppDocUid);
|
|
|
|
|
|
|
|
|
|
$ext = (isset($info['extension']) ? $info['extension'] : '');
|
|
|
|
|
$realPath = PATH_DOCUMENT . $app_uid . '/' . $file[0] . $file[1] . '_' . $iDocVersion . '.' . $ext;
|
|
|
|
|
@@ -513,7 +562,7 @@ class InputDocument
|
|
|
|
|
}
|
|
|
|
|
@fclose($fp);
|
|
|
|
|
}
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
} catch (Exception $e) {
|
|
|
|
|
throw $e;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@@ -691,19 +740,20 @@ class InputDocument
|
|
|
|
|
*
|
|
|
|
|
* @param string $inputDocumentUid
|
|
|
|
|
*
|
|
|
|
|
* return array Return an array with data of an InputDocument
|
|
|
|
|
* @return array Return an array with data of an InputDocument
|
|
|
|
|
* @throws Exception
|
|
|
|
|
*/
|
|
|
|
|
public function removeInputDocument($inputDocumentUid)
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$oAppDocument = \AppDocumentPeer::retrieveByPK( $inputDocumentUid, 1 );
|
|
|
|
|
$oAppDocument = AppDocumentPeer::retrieveByPK( $inputDocumentUid, 1 );
|
|
|
|
|
if (is_null( $oAppDocument ) || $oAppDocument->getAppDocStatus() == 'DELETED') {
|
|
|
|
|
throw new \Exception(\G::LoadTranslation("ID_CASES_INPUT_DOES_NOT_EXIST", array($inputDocumentUid)));
|
|
|
|
|
throw new Exception(G::LoadTranslation("ID_CASES_INPUT_DOES_NOT_EXIST", array($inputDocumentUid)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$ws = new \WsBase();
|
|
|
|
|
$ws = new WsBase();
|
|
|
|
|
$ws->removeDocument($inputDocumentUid);
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
} catch (Exception $e) {
|
|
|
|
|
throw $e;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@@ -717,7 +767,8 @@ class InputDocument
|
|
|
|
|
* @param string $inputDocumentUid
|
|
|
|
|
* @param string $userUid
|
|
|
|
|
*
|
|
|
|
|
* return array Return an array with data of an InputDocument
|
|
|
|
|
* @return array Return an array with data of an InputDocument
|
|
|
|
|
* @throws Exception
|
|
|
|
|
*/
|
|
|
|
|
public function addCasesInputDocument($applicationUid, $taskUid, $appDocComment, $inputDocumentUid, $userUid, $runningWorkflow = true)
|
|
|
|
|
{
|
|
|
|
|
@@ -726,90 +777,90 @@ class InputDocument
|
|
|
|
|
$code = $_FILES['form']['error'];
|
|
|
|
|
switch ($code) {
|
|
|
|
|
case UPLOAD_ERR_INI_SIZE:
|
|
|
|
|
$message = \G::LoadTranslation( 'ID_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' );
|
|
|
|
|
$message = G::LoadTranslation( 'ID_UPLOAD_ERR_FORM_SIZE' );
|
|
|
|
|
break;
|
|
|
|
|
case UPLOAD_ERR_PARTIAL:
|
|
|
|
|
$message = \G::LoadTranslation( 'ID_UPLOAD_ERR_PARTIAL' );
|
|
|
|
|
$message = G::LoadTranslation( 'ID_UPLOAD_ERR_PARTIAL' );
|
|
|
|
|
break;
|
|
|
|
|
case UPLOAD_ERR_NO_FILE:
|
|
|
|
|
$message = \G::LoadTranslation( 'ID_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' );
|
|
|
|
|
$message = G::LoadTranslation( 'ID_UPLOAD_ERR_NO_TMP_DIR' );
|
|
|
|
|
break;
|
|
|
|
|
case UPLOAD_ERR_CANT_WRITE:
|
|
|
|
|
$message = \G::LoadTranslation( 'ID_UPLOAD_ERR_CANT_WRITE' );
|
|
|
|
|
$message = G::LoadTranslation( 'ID_UPLOAD_ERR_CANT_WRITE' );
|
|
|
|
|
break;
|
|
|
|
|
case UPLOAD_ERR_EXTENSION:
|
|
|
|
|
$message = \G::LoadTranslation( 'ID_UPLOAD_ERR_EXTENSION' );
|
|
|
|
|
$message = G::LoadTranslation( 'ID_UPLOAD_ERR_EXTENSION' );
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
$message = \G::LoadTranslation( 'ID_UPLOAD_ERR_UNKNOWN' );
|
|
|
|
|
$message = G::LoadTranslation( 'ID_UPLOAD_ERR_UNKNOWN' );
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
\G::SendMessageText( $message, "ERROR" );
|
|
|
|
|
G::SendMessageText( $message, "ERROR" );
|
|
|
|
|
$backUrlObj = explode( "sys" . SYS_SYS, $_SERVER['HTTP_REFERER'] );
|
|
|
|
|
\G::header( "location: " . "/sys" . SYS_SYS . $backUrlObj[1] );
|
|
|
|
|
G::header( "location: " . "/sys" . SYS_SYS . $backUrlObj[1] );
|
|
|
|
|
die();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$appDocUid = \G::generateUniqueID();
|
|
|
|
|
$appDocUid = G::generateUniqueID();
|
|
|
|
|
$docVersion = '';
|
|
|
|
|
$appDocType = 'INPUT';
|
|
|
|
|
$case = new \Cases();
|
|
|
|
|
$delIndex = \AppDelegation::getCurrentIndex($applicationUid);
|
|
|
|
|
$case = new Cases();
|
|
|
|
|
$delIndex = AppDelegation::getCurrentIndex($applicationUid);
|
|
|
|
|
|
|
|
|
|
if ($runningWorkflow) {
|
|
|
|
|
$case->thisIsTheCurrentUser($applicationUid, $delIndex, $userUid, 'REDIRECT', 'casesListExtJs');
|
|
|
|
|
} else {
|
|
|
|
|
$criteria = new \Criteria('workflow');
|
|
|
|
|
$criteria = new Criteria('workflow');
|
|
|
|
|
|
|
|
|
|
$criteria->add(\AppDelegationPeer::APP_UID, $applicationUid);
|
|
|
|
|
$criteria->add(\AppDelegationPeer::DEL_INDEX, $delIndex);
|
|
|
|
|
$criteria->add(\AppDelegationPeer::USR_UID, $userUid);
|
|
|
|
|
$criteria->add(AppDelegationPeer::APP_UID, $applicationUid);
|
|
|
|
|
$criteria->add(AppDelegationPeer::DEL_INDEX, $delIndex);
|
|
|
|
|
$criteria->add(AppDelegationPeer::USR_UID, $userUid);
|
|
|
|
|
|
|
|
|
|
$rsCriteria = \ProcessUserPeer::doSelectRS($criteria);
|
|
|
|
|
$rsCriteria = ProcessUserPeer::doSelectRS($criteria);
|
|
|
|
|
|
|
|
|
|
if (!$rsCriteria->next()) {
|
|
|
|
|
$case2 = new \ProcessMaker\BusinessModel\Cases();
|
|
|
|
|
$case2 = new BusinessModelCases();
|
|
|
|
|
|
|
|
|
|
$arrayApplicationData = $case2->getApplicationRecordByPk($applicationUid, [], false);
|
|
|
|
|
|
|
|
|
|
$msg = '';
|
|
|
|
|
|
|
|
|
|
$supervisor = new \ProcessMaker\BusinessModel\ProcessSupervisor();
|
|
|
|
|
$supervisor = new ProcessSupervisor();
|
|
|
|
|
$flagps = $supervisor->isUserProcessSupervisor($arrayApplicationData['PRO_UID'], $userUid);
|
|
|
|
|
|
|
|
|
|
if ($flagps == false) {
|
|
|
|
|
$msg = \G::LoadTranslation('ID_USER_NOT_IT_BELONGS_CASE_OR_NOT_SUPERVISOR');
|
|
|
|
|
$msg = G::LoadTranslation('ID_USER_NOT_IT_BELONGS_CASE_OR_NOT_SUPERVISOR');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($msg == '') {
|
|
|
|
|
$criteria = new \Criteria('workflow');
|
|
|
|
|
$criteria = new Criteria('workflow');
|
|
|
|
|
|
|
|
|
|
$criteria->add(\StepSupervisorPeer::PRO_UID, $arrayApplicationData['PRO_UID'], \Criteria::EQUAL);
|
|
|
|
|
$criteria->add(\StepSupervisorPeer::STEP_TYPE_OBJ, 'INPUT_DOCUMENT', \Criteria::EQUAL);
|
|
|
|
|
$criteria->add(\StepSupervisorPeer::STEP_UID_OBJ, $inputDocumentUid, \Criteria::EQUAL);
|
|
|
|
|
$criteria->add(StepSupervisorPeer::PRO_UID, $arrayApplicationData['PRO_UID'], Criteria::EQUAL);
|
|
|
|
|
$criteria->add(StepSupervisorPeer::STEP_TYPE_OBJ, 'INPUT_DOCUMENT', Criteria::EQUAL);
|
|
|
|
|
$criteria->add(StepSupervisorPeer::STEP_UID_OBJ, $inputDocumentUid, Criteria::EQUAL);
|
|
|
|
|
|
|
|
|
|
$rsCriteria = \StepSupervisorPeer::doSelectRS($criteria);
|
|
|
|
|
$rsCriteria = StepSupervisorPeer::doSelectRS($criteria);
|
|
|
|
|
|
|
|
|
|
if (!$rsCriteria->next()) {
|
|
|
|
|
$msg = \G::LoadTranslation('ID_USER_IS_SUPERVISOR_DOES_NOT_ASSOCIATED_INPUT_DOCUMENT');
|
|
|
|
|
$msg = G::LoadTranslation('ID_USER_IS_SUPERVISOR_DOES_NOT_ASSOCIATED_INPUT_DOCUMENT');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($msg != '') {
|
|
|
|
|
if ($runningWorkflow) {
|
|
|
|
|
\G::SendMessageText($msg, 'ERROR');
|
|
|
|
|
G::SendMessageText($msg, 'ERROR');
|
|
|
|
|
$backUrlObj = explode('sys' . SYS_SYS, $_SERVER['HTTP_REFERER']);
|
|
|
|
|
|
|
|
|
|
\G::header('location: ' . '/sys' . SYS_SYS . $backUrlObj[1]);
|
|
|
|
|
G::header('location: ' . '/sys' . SYS_SYS . $backUrlObj[1]);
|
|
|
|
|
exit(0);
|
|
|
|
|
} else {
|
|
|
|
|
throw new \Exception($msg);
|
|
|
|
|
throw new Exception($msg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@@ -817,19 +868,19 @@ class InputDocument
|
|
|
|
|
|
|
|
|
|
//Load the fields
|
|
|
|
|
$arrayField = $case->loadCase($applicationUid);
|
|
|
|
|
$arrayField["APP_DATA"] = array_merge($arrayField["APP_DATA"], \G::getSystemConstants());
|
|
|
|
|
$arrayField["APP_DATA"] = array_merge($arrayField["APP_DATA"], G::getSystemConstants());
|
|
|
|
|
//Validate Process Uid and Input Document Process Uid
|
|
|
|
|
$inputDocumentInstance = new \InputDocument();
|
|
|
|
|
$inputDocumentFields = $inputDocumentInstance->load($inputDocumentUid);
|
|
|
|
|
if ($arrayField['PRO_UID'] != $inputDocumentFields['PRO_UID']) {
|
|
|
|
|
throw new \Exception(\G::LoadTranslation("ID_INPUT_DOCUMENT_DOES_NOT_EXIST",
|
|
|
|
|
throw new Exception(G::LoadTranslation("ID_INPUT_DOCUMENT_DOES_NOT_EXIST",
|
|
|
|
|
array('UID=' . $inputDocumentUid, 'PRO_UID=' . $arrayField['PRO_UID'])));
|
|
|
|
|
}
|
|
|
|
|
//Triggers
|
|
|
|
|
$arrayTrigger = $case->loadTriggers($taskUid, "INPUT_DOCUMENT", $inputDocumentUid, "AFTER");
|
|
|
|
|
//Add Input Document
|
|
|
|
|
if (empty($_FILES)) {
|
|
|
|
|
throw new \Exception(\G::LoadTranslation("ID_CASES_INPUT_FILENAME_DOES_NOT_EXIST"));
|
|
|
|
|
throw new Exception(G::LoadTranslation("ID_CASES_INPUT_FILENAME_DOES_NOT_EXIST"));
|
|
|
|
|
}
|
|
|
|
|
if (!$_FILES["form"]["error"]) {
|
|
|
|
|
$_FILES["form"]["error"] = 0;
|
|
|
|
|
@@ -866,14 +917,14 @@ class InputDocument
|
|
|
|
|
$arrayData["TAS_UID"] = $taskUid;
|
|
|
|
|
$case->updateCase($applicationUid, $arrayData);
|
|
|
|
|
return($this->getCasesInputDocument($applicationUid, $userUid, $appDocUid));
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
} catch (Exception $e) {
|
|
|
|
|
throw $e;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param $files $_FILES request files
|
|
|
|
|
* @param $caseInstance \Cases object class.cases
|
|
|
|
|
* @param $caseInstance Cases object class.cases
|
|
|
|
|
* @param $aData array data case
|
|
|
|
|
* @param $userUid string user id
|
|
|
|
|
* @param $appUid string application id
|
|
|
|
|
@@ -941,10 +992,10 @@ class InputDocument
|
|
|
|
|
$aID = $oInputDocument->load($indocUid);
|
|
|
|
|
|
|
|
|
|
//Get the Custom Folder ID (create if necessary)
|
|
|
|
|
$oFolder = new \AppFolder();
|
|
|
|
|
$oFolder = new AppFolder();
|
|
|
|
|
|
|
|
|
|
//***Validating the file allowed extensions***
|
|
|
|
|
$res = \G::verifyInputDocExtension($aID['INP_DOC_TYPE_FILE'], $arrayFileName[$i], $arrayFileTmpName[$i]);
|
|
|
|
|
$res = G::verifyInputDocExtension($aID['INP_DOC_TYPE_FILE'], $arrayFileName[$i], $arrayFileTmpName[$i]);
|
|
|
|
|
if ($res->status == 0) {
|
|
|
|
|
//The value of the variable "_label" is cleared because the file load failed.
|
|
|
|
|
//The validation of the die command should be improved.
|
|
|
|
|
@@ -953,9 +1004,9 @@ class InputDocument
|
|
|
|
|
$caseInstance->updateCase($appUid, $aData);
|
|
|
|
|
}
|
|
|
|
|
$message = $res->message;
|
|
|
|
|
\G::SendMessageText($message, "ERROR");
|
|
|
|
|
G::SendMessageText($message, "ERROR");
|
|
|
|
|
$backUrlObj = explode("sys" . SYS_SYS, $_SERVER['HTTP_REFERER']);
|
|
|
|
|
\G::header("location: " . "/sys" . SYS_SYS . $backUrlObj[1]);
|
|
|
|
|
G::header("location: " . "/sys" . SYS_SYS . $backUrlObj[1]);
|
|
|
|
|
die();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -967,9 +1018,9 @@ class InputDocument
|
|
|
|
|
|
|
|
|
|
if ($inpDocMaxFilesize > 0 && $fileSizeByField > 0) {
|
|
|
|
|
if ($fileSizeByField > $inpDocMaxFilesize) {
|
|
|
|
|
\G::SendMessageText(\G::LoadTranslation("ID_SIZE_VERY_LARGE_PERMITTED"), "ERROR");
|
|
|
|
|
G::SendMessageText(G::LoadTranslation("ID_SIZE_VERY_LARGE_PERMITTED"), "ERROR");
|
|
|
|
|
$arrayAux1 = explode("sys" . SYS_SYS, $_SERVER["HTTP_REFERER"]);
|
|
|
|
|
\G::header("location: /sys" . SYS_SYS . $arrayAux1[1]);
|
|
|
|
|
G::header("location: /sys" . SYS_SYS . $arrayAux1[1]);
|
|
|
|
|
exit(0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@@ -980,31 +1031,31 @@ class InputDocument
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$sExtension = pathinfo($aFields["APP_DOC_FILENAME"]);
|
|
|
|
|
if (\Bootstrap::getDisablePhpUploadExecution() === 1 && $sExtension["extension"] === 'php') {
|
|
|
|
|
$message = \G::LoadTranslation('THE_UPLOAD_OF_PHP_FILES_WAS_DISABLED');
|
|
|
|
|
\Bootstrap::registerMonologPhpUploadExecution('phpUpload', 550, $message, $sFileName);
|
|
|
|
|
\G::SendMessageText($message, "ERROR");
|
|
|
|
|
if (Bootstrap::getDisablePhpUploadExecution() === 1 && $sExtension["extension"] === 'php') {
|
|
|
|
|
$message = G::LoadTranslation('THE_UPLOAD_OF_PHP_FILES_WAS_DISABLED');
|
|
|
|
|
Bootstrap::registerMonologPhpUploadExecution('phpUpload', 550, $message, 'processmaker.log');
|
|
|
|
|
G::SendMessageText($message, "ERROR");
|
|
|
|
|
$backUrlObj = explode("sys" . SYS_SYS, $_SERVER['HTTP_REFERER']);
|
|
|
|
|
\G::header("location: " . "/sys" . SYS_SYS . $backUrlObj[1]);
|
|
|
|
|
G::header("location: " . "/sys" . SYS_SYS . $backUrlObj[1]);
|
|
|
|
|
die();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$oAppDocument = new \AppDocument();
|
|
|
|
|
$oAppDocument = new AppDocument();
|
|
|
|
|
$oAppDocument->create($aFields);
|
|
|
|
|
|
|
|
|
|
$iDocVersion = $oAppDocument->getDocVersion();
|
|
|
|
|
$sAppDocUid = $oAppDocument->getAppDocUid();
|
|
|
|
|
$aInfo = pathinfo($oAppDocument->getAppDocFilename());
|
|
|
|
|
$sExtension = ((isset($aInfo["extension"])) ? $aInfo["extension"] : "");
|
|
|
|
|
$pathUID = \G::getPathFromUID($appUid);
|
|
|
|
|
$pathUID = G::getPathFromUID($appUid);
|
|
|
|
|
$sPathName = PATH_DOCUMENT . $pathUID . PATH_SEP;
|
|
|
|
|
$sFileName = $sAppDocUid . "_" . $iDocVersion . "." . $sExtension;
|
|
|
|
|
|
|
|
|
|
\G::uploadFile($arrayFileTmpName[$i], $sPathName, $sFileName);
|
|
|
|
|
G::uploadFile($arrayFileTmpName[$i], $sPathName, $sFileName);
|
|
|
|
|
|
|
|
|
|
//set variable for APP_DOC_UID
|
|
|
|
|
$aData["APP_DATA"][$oAppDocument->getAppDocFieldname()] = \G::json_encode([$oAppDocument->getAppDocUid()]);
|
|
|
|
|
$aData["APP_DATA"][$oAppDocument->getAppDocFieldname() . "_label"] = \G::json_encode([$oAppDocument->getAppDocFilename()]);
|
|
|
|
|
$aData["APP_DATA"][$oAppDocument->getAppDocFieldname()] = G::json_encode([$oAppDocument->getAppDocUid()]);
|
|
|
|
|
$aData["APP_DATA"][$oAppDocument->getAppDocFieldname() . "_label"] = G::json_encode([$oAppDocument->getAppDocFilename()]);
|
|
|
|
|
$caseInstance->updateCase($appUid, $aData);
|
|
|
|
|
|
|
|
|
|
//Plugin Hook PM_UPLOAD_DOCUMENT for upload document
|
|
|
|
|
@@ -1031,4 +1082,62 @@ class InputDocument
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get all versions related to the appDocUid
|
|
|
|
|
* @param string $appUid, Uid of the case
|
|
|
|
|
* @param string $appDocUid, Uid of the document
|
|
|
|
|
* @param string $docUid, Uid of the inputDocument
|
|
|
|
|
* @param string $userUid, Uid of user
|
|
|
|
|
* @param string $status, It can be ACTIVE, DELETED
|
|
|
|
|
* @param string $docType, It can be ATTACHED, INPUT
|
|
|
|
|
* @param string $docTags, It can be EXTERNAL, INPUT
|
|
|
|
|
*
|
|
|
|
|
* @return array $docVersion
|
|
|
|
|
* @throws Exception
|
|
|
|
|
*/
|
|
|
|
|
public function getAllVersionByDocUid ($appUid, $appDocUid, $docUid = '', $userUid = '', $status = 'ACTIVE', $docType = '', $docTags = '')
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$criteria = new Criteria('workflow');
|
|
|
|
|
$criteria->add(AppDocumentPeer::APP_UID, $appUid);
|
|
|
|
|
$criteria->add(AppDocumentPeer::APP_DOC_UID, $appDocUid);
|
|
|
|
|
$criteria->add(AppDocumentPeer::APP_DOC_STATUS, $status, Criteria::EQUAL);
|
|
|
|
|
if (!empty($docUid)) {
|
|
|
|
|
$criteria->add(AppDocumentPeer::DOC_UID, $docUid);
|
|
|
|
|
}
|
|
|
|
|
if (!empty($userUid)) {
|
|
|
|
|
$criteria->add(AppDocumentPeer::USR_UID, $userUid);
|
|
|
|
|
}
|
|
|
|
|
if (!empty($docType)) {
|
|
|
|
|
$criteria->add(AppDocumentPeer::APP_DOC_TYPE, $docType);
|
|
|
|
|
}
|
|
|
|
|
if (!empty($docTags)) {
|
|
|
|
|
$criteria->add(AppDocumentPeer::APP_DOC_TAGS, $docTags);
|
|
|
|
|
}
|
|
|
|
|
$criteria->addDescendingOrderByColumn(AppDocumentPeer::DOC_VERSION);
|
|
|
|
|
$dataset = AppDocumentPeer::doSelectRS($criteria);
|
|
|
|
|
$dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
|
|
|
|
$dataset->next();
|
|
|
|
|
$config = new Configurations();
|
|
|
|
|
$confEnvSetting = $config->getFormats();
|
|
|
|
|
$user = new Users();
|
|
|
|
|
|
|
|
|
|
$arrayInputDocument = array();
|
|
|
|
|
while ($row = $dataset->getRow()) {
|
|
|
|
|
//todo, we use this *** in others endpoint for mark that user not exist, but we need to change
|
|
|
|
|
$userInfo = '***';
|
|
|
|
|
if ($row["USR_UID"] !== '-1') {
|
|
|
|
|
$arrayUserData = $user->load($row["USR_UID"]);
|
|
|
|
|
$userInfo = $config->usersNameFormatBySetParameters($confEnvSetting["format"], $arrayUserData["USR_USERNAME"], $arrayUserData["USR_FIRSTNAME"], $arrayUserData["USR_LASTNAME"]);
|
|
|
|
|
}
|
|
|
|
|
$row["APP_DOC_CREATE_USER"] = $userInfo;
|
|
|
|
|
$arrayInputDocument[] = $this->getAppDocumentDataFromRecord($row);
|
|
|
|
|
$dataset->next();
|
|
|
|
|
}
|
|
|
|
|
return $arrayInputDocument;
|
|
|
|
|
} catch (Exception $e) {
|
|
|
|
|
throw $e;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|