$arrayTrigger = $case->loadTriggers($_SESSION["TASK"], "INPUT_DOCUMENT", $inputDocumentUid, "AFTER"); //Trigger debug routines //Cleaning debug variables $_SESSION["TRIGGER_DEBUG"]["ERRORS"] = array(); $_SESSION["TRIGGER_DEBUG"]["DATA"] = array(); $_SESSION["TRIGGER_DEBUG"]["TRIGGERS_NAMES"] = array(); $_SESSION["TRIGGER_DEBUG"]["TRIGGERS_VALUES"] = array(); $_SESSION["TRIGGER_DEBUG"]["NUM_TRIGGERS"] = count($arrayTrigger); $_SESSION["TRIGGER_DEBUG"]["TIME"] = "AFTER"; if ($_SESSION["TRIGGER_DEBUG"]["NUM_TRIGGERS"] > 0) { $_SESSION["TRIGGER_DEBUG"]["TRIGGERS_NAMES"] = $case->getTriggerNames($arrayTrigger); $_SESSION["TRIGGER_DEBUG"]["TRIGGERS_VALUES"] = $arrayTrigger; } //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); //go to the next step
/** * Get data of Cases InputDocument * * @param string $applicationUid * @param string $taskUid * @param string $appDocComment * @param string $inputDocumentUid * @param string $userUid * * return array Return an array with data of an InputDocument */ public function addCasesInputDocument($applicationUid, $taskUid, $appDocComment, $inputDocumentUid, $userUid) { try { if ((isset( $_FILES['form'] )) && ($_FILES['form']['error'] != 0)) { $code = $_FILES['form']['error']; 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"); $appDocUid = \G::generateUniqueID(); $docVersion = ''; $appDocType = 'INPUT'; $case = new \Cases(); $delIndex = \AppDelegation::getCurrentIndex($applicationUid); $case->thisIsTheCurrentUser($applicationUid, $delIndex, $userUid, "REDIRECT", "casesListExtJs"); //Load the fields $arrayField = $case->loadCase($applicationUid); $arrayField["APP_DATA"] = array_merge($arrayField["APP_DATA"], \G::getSystemConstants()); //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")); } if (!$_FILES["form"]["error"]) { $_FILES["form"]["error"] = 0; } if (isset($_FILES) && isset($_FILES["form"]) && count($_FILES["form"]) > 0) { $appDocUid = $case->addInputDocument($inputDocumentUid, $appDocUid, $docVersion, $appDocType, $appDocComment, '', $applicationUid, $delIndex, $taskUid, $userUid, "xmlform", $_FILES["form"]["name"], $_FILES["form"]["error"], $_FILES["form"]["tmp_name"]); } //Trigger - Execute after - Start $arrayField["APP_DATA"] = $case->executeTriggers ($taskUid, "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"] = $delIndex; $arrayData["TAS_UID"] = $taskUid; $case->updateCase($applicationUid, $arrayData); return($this->getCasesInputDocument($applicationUid, $userUid, $appDocUid)); } catch (\Exception $e) { throw $e; } }
/** * @method * * Add a input document. * * @name PMFAddInputDocument * @label PMF Add a input document * @link http://wiki.processmaker.com/index.php/ProcessMaker_Functions#PMFAddInputDocument.28.29 * * @param string(32) | $inputDocumentUid | ID of the input document | The unique ID of the input document. * @param string(32) | $appDocUid | ID of the application document | The unique ID of the application document; if action is set to null or empty (Add), then this parameter it set to null or empty. * @param int | $docVersion | Document version | Document version. * @param string | $appDocType = "INPUT" | Document type | Document type. * @param string | $appDocComment | Document comment | Document comment. * @param string | $inputDocumentAction | Action | Action, posible values: null or empty (Add), "R" (Replace), "NV" (New Version). * @param string(32) | $caseUid | ID of the case | The unique ID of the case. * @param int | $delIndex | Delegation index of the case | The delegation index of the current task in the case. * @param string(32) | $taskUid | ID of the task | The unique ID of the task. * @param string(32) | $userUid | ID user | The unique ID of the user who will add a input document. * @param string | $option = "file" | Option | Option, value: "file". * @param string | $file = "path_to_file/myfile.txt" | File, path to file | File, path to file. * @return string | $appDocUid | ID of the application document | Returns ID if it has added the input document successfully; otherwise, returns null or empty if an error occurred. * */ function PMFAddInputDocument($inputDocumentUid, $appDocUid, $docVersion, $appDocType = "INPUT", $appDocComment, $inputDocumentAction, $caseUid, $delIndex, $taskUid, $userUid, $option = "file", $file = "path_to_file/myfile.txt") { G::LoadClass("case"); $g = new G(); $g->sessionVarSave(); $_SESSION["APPLICATION"] = $caseUid; $_SESSION["INDEX"] = $delIndex; $_SESSION["TASK"] = $taskUid; $_SESSION["USER_LOGGED"] = $userUid; $case = new Cases(); $appDocUid = $case->addInputDocument($inputDocumentUid, $appDocUid, $docVersion, $appDocType, $appDocComment, $inputDocumentAction, $caseUid, $delIndex, $taskUid, $userUid, $option, $file); $g->sessionVarRestore(); return $appDocUid; }