diff --git a/workflow/engine/classes/class.applications.php b/workflow/engine/classes/class.applications.php
index 93702e54b..4652ea969 100755
--- a/workflow/engine/classes/class.applications.php
+++ b/workflow/engine/classes/class.applications.php
@@ -18,7 +18,7 @@ class Applications
$sort = "APP_CACHE_VIEW.APP_NUMBER",
$category = null,
$configuration = true,
- $paged = false
+ $paged = true
) {
$callback = isset($callback)? $callback : "stcCallback1001";
$dir = isset($dir)? $dir : "DESC";
@@ -443,10 +443,14 @@ class Applications
}
//Add sortable options
- if ($sort != "") {
+ $sortBk = $sort;
+
+ if ($sortBk != "") {
+ $sort = "";
+
//Current delegation (*)
if (($action == "sent" || $action == "search" || $action == "simple_search" || $action == "to_revise" || $action == "to_reassign") && ($status != "TO_DO")) {
- switch ($sort) {
+ switch ($sortBk) {
case "APP_CACHE_VIEW.APP_CURRENT_USER":
$sort = "USRCR_" . $conf->userNameFormatGetFirstFieldByUsersTable();
break;
@@ -455,10 +459,12 @@ class Applications
break;
}
}
+
if (isset( $oAppCache->confCasesList['PMTable'] ) && ! empty( $oAppCache->confCasesList['PMTable'] ) && $tableNameAux != '') {
- $sortTable = explode(".", $sort);
+ $sortTable = explode(".", $sortBk);
$additionalTableUid = $oAppCache->confCasesList["PMTable"];
+
require_once 'classes/model/Fields.php';
$oCriteria = new Criteria('workflow');
@@ -489,6 +495,15 @@ class Applications
}
}
+ if ($sort == "") {
+ $sort = $sortBk;
+
+ if (!in_array($sortBk, $Criteria->getSelectColumns())) {
+ $sort = AppCacheViewPeer::APP_NUMBER; //DEFAULT VALUE
+ $dir = "DESC";
+ }
+ }
+
if ($dir == "DESC") {
$Criteria->addDescendingOrderByColumn($sort);
} else {
diff --git a/workflow/engine/methods/cases/cases_SaveDataSupervisor.php b/workflow/engine/methods/cases/cases_SaveDataSupervisor.php
index 54e42c063..29d6180c9 100755
--- a/workflow/engine/methods/cases/cases_SaveDataSupervisor.php
+++ b/workflow/engine/methods/cases/cases_SaveDataSupervisor.php
@@ -49,6 +49,149 @@ $aData['APP_STATUS'] = $Fields['APP_STATUS'];
$oCase->updateCase( $_SESSION['APPLICATION'], $aData );
G::SendTemporalMessage( 'ID_SAVED_SUCCESSFULLY', 'info' );
+//Save files
+if (isset( $_FILES["form"]["name"] ) && count( $_FILES["form"]["name"] ) > 0) {
+ $arrayField = array ();
+ $arrayFileName = array ();
+ $arrayFileTmpName = array ();
+ $arrayFileError = array ();
+ $i = 0;
+
+ foreach ($_FILES["form"]["name"] as $fieldIndex => $fieldValue) {
+ if (is_array( $fieldValue )) {
+ foreach ($fieldValue as $index => $value) {
+ if (is_array( $value )) {
+ foreach ($value as $grdFieldIndex => $grdFieldValue) {
+ $arrayField[$i]["grdName"] = $fieldIndex;
+ $arrayField[$i]["grdFieldName"] = $grdFieldIndex;
+ $arrayField[$i]["index"] = $index;
+
+ $arrayFileName[$i] = $_FILES["form"]["name"][$fieldIndex][$index][$grdFieldIndex];
+ $arrayFileTmpName[$i] = $_FILES["form"]["tmp_name"][$fieldIndex][$index][$grdFieldIndex];
+ $arrayFileError[$i] = $_FILES["form"]["error"][$fieldIndex][$index][$grdFieldIndex];
+ $i = $i + 1;
+ }
+ }
+ }
+ } else {
+ $arrayField[$i] = $fieldIndex;
+
+ $arrayFileName[$i] = $_FILES["form"]["name"][$fieldIndex];
+ $arrayFileTmpName[$i] = $_FILES["form"]["tmp_name"][$fieldIndex];
+ $arrayFileError[$i] = $_FILES["form"]["error"][$fieldIndex];
+ $i = $i + 1;
+ }
+ }
+ if (count( $arrayField ) > 0) {
+ for ($i = 0; $i <= count( $arrayField ) - 1; $i ++) {
+ if ($arrayFileError[$i] == 0) {
+ $indocUid = null;
+ $fieldName = null;
+ $fileSizeByField = 0;
+
+ if (is_array( $arrayField[$i] )) {
+ if (isset( $_POST["INPUTS"][$arrayField[$i]["grdName"]][$arrayField[$i]["grdFieldName"]] ) && ! empty( $_POST["INPUTS"][$arrayField[$i]["grdName"]][$arrayField[$i]["grdFieldName"]] )) {
+ $indocUid = $_POST["INPUTS"][$arrayField[$i]["grdName"]][$arrayField[$i]["grdFieldName"]];
+ }
+
+ $fieldName = $arrayField[$i]["grdName"] . "_" . $arrayField[$i]["index"] . "_" . $arrayField[$i]["grdFieldName"];
+
+ if (isset($_FILES["form"]["size"][$arrayField[$i]["grdName"]][$arrayField[$i]["index"]][$arrayField[$i]["grdFieldName"]])) {
+ $fileSizeByField = $_FILES["form"]["size"][$arrayField[$i]["grdName"]][$arrayField[$i]["index"]][$arrayField[$i]["grdFieldName"]];
+ }
+ } else {
+ if (isset( $_POST["INPUTS"][$arrayField[$i]] ) && ! empty( $_POST["INPUTS"][$arrayField[$i]] )) {
+ $indocUid = $_POST["INPUTS"][$arrayField[$i]];
+ }
+
+ $fieldName = $arrayField[$i];
+
+ if (isset($_FILES["form"]["size"][$fieldName])) {
+ $fileSizeByField = $_FILES["form"]["size"][$fieldName];
+ }
+ }
+
+ if ($indocUid != null) {
+ //require_once ("classes/model/AppFolder.php");
+ //require_once ("classes/model/InputDocument.php");
+
+ $oInputDocument = new InputDocument();
+ $aID = $oInputDocument->load( $indocUid );
+
+ //Get the Custom Folder ID (create if necessary)
+ $oFolder = new AppFolder();
+
+ //***Validating the file allowed extensions***
+ $res = G::verifyInputDocExtension($aID['INP_DOC_TYPE_FILE'], $arrayFileName[$i], $arrayFileTmpName[$i]);
+ if($res->status == 0){
+ $message = $res->message;
+ G::SendMessageText( $message, "ERROR" );
+ $backUrlObj = explode( "sys" . SYS_SYS, $_SERVER['HTTP_REFERER'] );
+ G::header( "location: " . "/sys" . SYS_SYS . $backUrlObj[1] );
+ die();
+ }
+
+ //--- Validate Filesize of $_FILE
+ $inpDocMaxFilesize = $aID["INP_DOC_MAX_FILESIZE"];
+ $inpDocMaxFilesizeUnit = $aID["INP_DOC_MAX_FILESIZE_UNIT"];
+
+ $inpDocMaxFilesize = $inpDocMaxFilesize * (($inpDocMaxFilesizeUnit == "MB")? 1024 *1024 : 1024); //Bytes
+
+ if ($inpDocMaxFilesize > 0 && $fileSizeByField > 0) {
+ if ($fileSizeByField > $inpDocMaxFilesize) {
+ 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]);
+ exit(0);
+ }
+ }
+
+ $aFields = array ("APP_UID" => $_SESSION["APPLICATION"],"DEL_INDEX" => $_SESSION["INDEX"],"USR_UID" => $_SESSION["USER_LOGGED"],"DOC_UID" => $indocUid,"APP_DOC_TYPE" => "INPUT","APP_DOC_CREATE_DATE" => date( "Y-m-d H:i:s" ),"APP_DOC_COMMENT" => "","APP_DOC_TITLE" => "","APP_DOC_FILENAME" => $arrayFileName[$i],"FOLDER_UID" => $oFolder->createFromPath( $aID["INP_DOC_DESTINATION_PATH"] ),"APP_DOC_TAGS" => $oFolder->parseTags( $aID["INP_DOC_TAGS"] ),"APP_DOC_FIELDNAME" => $fieldName);
+ } else {
+ $aFields = array ("APP_UID" => $_SESSION["APPLICATION"],"DEL_INDEX" => $_SESSION["INDEX"],"USR_UID" => $_SESSION["USER_LOGGED"],"DOC_UID" => - 1,"APP_DOC_TYPE" => "ATTACHED","APP_DOC_CREATE_DATE" => date( "Y-m-d H:i:s" ),"APP_DOC_COMMENT" => "","APP_DOC_TITLE" => "","APP_DOC_FILENAME" => $arrayFileName[$i],"APP_DOC_FIELDNAME" => $fieldName);
+ }
+
+ $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($_SESSION["APPLICATION"]);
+ $sPathName = PATH_DOCUMENT . $pathUID . PATH_SEP;
+ $sFileName = $sAppDocUid . "_" . $iDocVersion . "." . $sExtension;
+ G::uploadFile( $arrayFileTmpName[$i], $sPathName, $sFileName );
+
+ //Plugin Hook PM_UPLOAD_DOCUMENT for upload document
+ $oPluginRegistry = &PMPluginRegistry::getSingleton();
+
+ if ($oPluginRegistry->existsTrigger( PM_UPLOAD_DOCUMENT ) && class_exists( "uploadDocumentData" )) {
+ $triggerDetail = $oPluginRegistry->getTriggerInfo( PM_UPLOAD_DOCUMENT );
+ $documentData = new uploadDocumentData( $_SESSION["APPLICATION"], $_SESSION["USER_LOGGED"], $sPathName . $sFileName, $aFields["APP_DOC_FILENAME"], $sAppDocUid, $iDocVersion );
+ $uploadReturn = $oPluginRegistry->executeTriggers( PM_UPLOAD_DOCUMENT, $documentData );
+
+ if ($uploadReturn) {
+ $aFields["APP_DOC_PLUGIN"] = $triggerDetail->sNamespace;
+
+ if (! isset( $aFields["APP_DOC_UID"] )) {
+ $aFields["APP_DOC_UID"] = $sAppDocUid;
+ }
+
+ if (! isset( $aFields["DOC_VERSION"] )) {
+ $aFields["DOC_VERSION"] = $iDocVersion;
+ }
+
+ $oAppDocument->update( $aFields );
+
+ unlink( $sPathName . $sFileName );
+ }
+ }
+ }
+ }
+ }
+}
+
//go to the next step
$aNextStep = $oCase->getNextSupervisorStep( $_SESSION['PROCESS'], $_SESSION['STEP_POSITION'] );
$_SESSION['STEP_POSITION'] = $aNextStep['POSITION'];
diff --git a/workflow/engine/src/ProcessMaker/Services/Api/Cases.php b/workflow/engine/src/ProcessMaker/Services/Api/Cases.php
index 0763322f7..e27f6017a 100644
--- a/workflow/engine/src/ProcessMaker/Services/Api/Cases.php
+++ b/workflow/engine/src/ProcessMaker/Services/Api/Cases.php
@@ -458,7 +458,7 @@ class Cases extends Api
try {
$dataList['userId'] = $this->getUserId();
$dataList['action'] = 'paused';
- $dataList['paged'] = false;
+ $dataList["paged"] = true;
$dataList['start'] = $start;
$dataList['limit'] = $limit;
diff --git a/workflow/engine/xmlform/cases/cases_AttachInputDocumentGeneral.xml b/workflow/engine/xmlform/cases/cases_AttachInputDocumentGeneral.xml
index 8c4782a52..21bc9a536 100755
--- a/workflow/engine/xmlform/cases/cases_AttachInputDocumentGeneral.xml
+++ b/workflow/engine/xmlform/cases/cases_AttachInputDocumentGeneral.xml
@@ -10,7 +10,7 @@
- Max size accepted
+ Max. file size