diff --git a/workflow/engine/classes/ArrayBasePeer.php b/workflow/engine/classes/ArrayBasePeer.php index e63d132eb..59711466f 100644 --- a/workflow/engine/classes/ArrayBasePeer.php +++ b/workflow/engine/classes/ArrayBasePeer.php @@ -471,26 +471,21 @@ abstract class ArrayBasePeer public static function doSelect(Criteria $criteria, $tableName, $con = null) { $dbMap = Propel::getDatabaseMap($criteria->getDbName()); - $stmt = null; - try { $params = array(); $sql = self::createSelectSql($criteria, $tableName, $params); $sql['params'] = $params; $stmt = $con->prepareStatement($sql); - //$stmt->setLimit($criteria->getLimit()); - $sql['limit'] = $criteria->getLimit(); - //$stmt->setOffset($criteria->getOffset()); - $sql['offset'] = $criteria->getOffset(); - //$rs = $stmt->executeQuery(ResultSet::FETCHMODE_NUM); + $sql['limit'] = (int) $criteria->getLimit(); + $sql['offset'] = (int) $criteria->getOffset(); $rs = $con->executeQuery($sql, ResultSet::FETCHMODE_NUM); } catch (Exception $e) { - if ($stmt) + if ($stmt) { $stmt->close(); + } throw new PropelException($e); } - return $rs; } diff --git a/workflow/engine/classes/Cases.php b/workflow/engine/classes/Cases.php index 3f51ae6ca..a132834d5 100644 --- a/workflow/engine/classes/Cases.php +++ b/workflow/engine/classes/Cases.php @@ -1,10 +1,12 @@ add(AppThreadPeer::APP_UID, $sAppUid); + $c->add(AppThreadPeer::APP_UID, $appUid); $c->add(AppThreadPeer::APP_THREAD_STATUS, 'OPEN'); $rowObj = AppThreadPeer::doSelect($c); foreach ($rowObj as $appThread) { @@ -1893,11 +1897,12 @@ class Cases throw (new PropelException('The row cannot be created!', new PropelException($msg))); } } - //update searchindex + + /** Update search index */ if ($this->appSolr != null) { - $this->appSolr->updateApplicationSearchIndex($sAppUid); + $this->appSolr->updateApplicationSearchIndex($appUid); } - } catch (exception $e) { + } catch (Exception $e) { throw ($e); } } @@ -1930,19 +1935,22 @@ class Cases /** * With this function we can change status to CLOSED in APP_DELEGATION * - * @name closeAllDelegations - * @param string $sAppUid - * @return + * @param string $appUid + * + * @return void + * @throws Exception */ - public function closeAllDelegations($sAppUid) + public function closeAllDelegations($appUid) { try { - $c = new Criteria(); - $c->add(AppDelegationPeer::APP_UID, $sAppUid); - $c->add(AppDelegationPeer::DEL_THREAD_STATUS, 'OPEN'); - $rowObj = AppDelegationPeer::doSelect($c); + $criteria = new Criteria(); + $criteria->add(AppDelegationPeer::APP_UID, $appUid); + $criteria->add(AppDelegationPeer::DEL_THREAD_STATUS, 'OPEN'); + $rowObj = AppDelegationPeer::doSelect($criteria); + $data = []; foreach ($rowObj as $appDel) { $appDel->setDelThreadStatus('CLOSED'); + $appDel->setDelFinishDate('now'); if ($appDel->Validate()) { $appDel->Save(); } else { @@ -1952,12 +1960,31 @@ class Cases } throw (new PropelException('The row cannot be created!', new PropelException($msg))); } + + /*----------------------------------********---------------------------------*/ + $delIndex = $appDel->getDelIndex(); + $inbox = new ListInbox(); + $inbox->remove($appUid, $delIndex); + $data['DEL_THREAD_STATUS'] = 'CLOSED'; + $data['APP_UID'] = $appUid; + $data['DEL_INDEX'] = $delIndex; + $data['USR_UID'] = $appDel->getUsrUid(); + $listParticipatedLast = new ListParticipatedLast(); + $listParticipatedLast->refresh($data); + /*----------------------------------********---------------------------------*/ + + /** This case is subProcess? */ + if (SubApplication::isCaseSubProcess($appUid)) { + $route = new Derivation(); + $route->verifyIsCaseChild($appUid, $delIndex); + } } - //update searchindex + + /** Update search index */ if ($this->appSolr != null) { - $this->appSolr->updateApplicationSearchIndex($sAppUid); + $this->appSolr->updateApplicationSearchIndex($appUid); } - } catch (exception $e) { + } catch (Exception $e) { throw ($e); } } @@ -1965,18 +1992,19 @@ class Cases /** * With this we can change the status to CLOSED in APP_DELEGATION * - * @name CloseCurrentDelegation - * @param string $sAppUid - * @param string $iDelIndex - * @return Fields + * @param string $appUid + * @param string $delIndex + * + * @return void + * @throws Exception */ - public function CloseCurrentDelegation($sAppUid, $iDelIndex) + public function CloseCurrentDelegation($appUid, $delIndex) { try { - $c = new Criteria(); - $c->add(AppDelegationPeer::APP_UID, $sAppUid); - $c->add(AppDelegationPeer::DEL_INDEX, $iDelIndex); - $rowObj = AppDelegationPeer::doSelect($c); + $criteria = new Criteria(); + $criteria->add(AppDelegationPeer::APP_UID, $appUid); + $criteria->add(AppDelegationPeer::DEL_INDEX, $delIndex); + $rowObj = AppDelegationPeer::doSelect($criteria); $user = ''; foreach ($rowObj as $appDel) { $appDel->setDelThreadStatus('CLOSED'); @@ -1992,17 +2020,30 @@ class Cases throw (new PropelException('The row cannot be created!', new PropelException($msg))); } } + /*----------------------------------********---------------------------------*/ $inbox = new ListInbox(); - $inbox->remove($sAppUid, $iDelIndex); + $data = []; + $inbox->remove($appUid, $delIndex); $data['DEL_THREAD_STATUS'] = 'CLOSED'; - $data['APP_UID'] = $sAppUid; - $data['DEL_INDEX'] = $iDelIndex; + $data['APP_UID'] = $appUid; + $data['DEL_INDEX'] = $delIndex; $data['USR_UID'] = $user; $listParticipatedLast = new ListParticipatedLast(); $listParticipatedLast->refresh($data); /*----------------------------------********---------------------------------*/ - } catch (exception $e) { + + /** This case is subProcess? */ + if (SubApplication::isCaseSubProcess($appUid)) { + $route = new Derivation(); + $route->verifyIsCaseChild($appUid, $delIndex); + } + + /** Update searchindex */ + if ($this->appSolr != null) { + $this->appSolr->updateApplicationSearchIndex($appUid); + } + } catch (Exception $e) { throw ($e); } } @@ -2548,10 +2589,11 @@ class Cases * Get the transfer History * * @name getTransferHistoryCriteria - * @param string $sAppUid - * @return array + * @param integer $appNumber + * + * @return object */ - public function getTransferHistoryCriteria($sAppUid) + public function getTransferHistoryCriteria($appNumber) { $c = new Criteria('workflow'); $c->addSelectColumn(UsersPeer::USR_FIRSTNAME); @@ -2561,41 +2603,52 @@ class Cases $c->addSelectColumn(AppDelegationPeer::TAS_UID); $c->addSelectColumn(AppDelegationPeer::APP_UID); $c->addSelectColumn(AppDelegationPeer::DEL_INDEX); - ///-- $c->addAsColumn('USR_NAME', "CONCAT(USR_LASTNAME, ' ', USR_FIRSTNAME)"); - $sDataBase = 'database_' . strtolower(DB_ADAPTER); - if (G::LoadSystemExist($sDataBase)) { - $oDataBase = new database(); - $c->addAsColumn('USR_NAME', $oDataBase->concatString("USR_LASTNAME", "' '", "USR_FIRSTNAME")); - $c->addAsColumn( - 'DEL_FINISH_DATE', $oDataBase->getCaseWhen("DEL_FINISH_DATE IS NULL", "'-'", AppDelegationPeer::DEL_FINISH_DATE) - ); - $c->addAsColumn( - 'APP_TYPE', $oDataBase->getCaseWhen("DEL_FINISH_DATE IS NULL", "'IN_PROGRESS'", AppDelayPeer::APP_TYPE) - ); - } $c->addSelectColumn(AppDelegationPeer::DEL_INIT_DATE); $c->addSelectColumn(AppDelayPeer::APP_ENABLE_ACTION_DATE); $c->addSelectColumn(AppDelayPeer::APP_DISABLE_ACTION_DATE); - $c->addSelectColumn(TaskPeer::TAS_TITLE); - //APP_DELEGATION LEFT JOIN USERS - $c->addJoin(AppDelegationPeer::USR_UID, UsersPeer::USR_UID, Criteria::LEFT_JOIN); - //APP_DELAY FOR MORE DESCRIPTION - //$c->addJoin(AppDelegationPeer::DEL_INDEX, AppDelayPeer::APP_DEL_INDEX, Criteria::LEFT_JOIN); - //$c->addJoin(AppDelegationPeer::APP_UID, AppDelayPeer::APP_UID, Criteria::LEFT_JOIN); + //We added this custom query for the case tracker + $c->addAsColumn( + 'TAS_TITLE', + 'CASE WHEN TASK.TAS_TITLE = "INTERMEDIATE-THROW-EMAIL-EVENT" THEN "' . G::LoadTranslation('ID_INTERMEDIATE_THROW_EMAIL_EVENT') . '" + WHEN TASK.TAS_TITLE = "INTERMEDIATE-THROW-MESSAGE-EVENT" THEN "' . G::LoadTranslation('ID_INTERMEDIATE_THROW_MESSAGE_EVENT') . '" + WHEN TASK.TAS_TITLE = "INTERMEDIATE-CATCH-MESSAGE-EVENT" THEN "' . G::LoadTranslation('ID_INTERMEDIATE_CATCH_MESSAGE_EVENT') . '" + WHEN TASK.TAS_TITLE = "INTERMEDIATE-CATCH-TIMER-EVENT" THEN "' . G::LoadTranslation('ID_INTERMEDIATE_CATCH_TIMER_EVENT') . '" + ELSE TASK.TAS_TITLE + END' + ); + + $dbAdapter = 'database_' . strtolower(DB_ADAPTER); + if (G::LoadSystemExist($dbAdapter)) { + $dataBase = new database(); + $c->addAsColumn( + 'USR_NAME', + $dataBase->concatString("USR_LASTNAME", "' '", "USR_FIRSTNAME") + ); + $c->addAsColumn( + 'DEL_FINISH_DATE', + $dataBase->getCaseWhen("DEL_FINISH_DATE IS NULL", "'-'", AppDelegationPeer::DEL_FINISH_DATE) + ); + $c->addAsColumn( + 'APP_TYPE', + $dataBase->getCaseWhen("DEL_FINISH_DATE IS NULL", "'IN_PROGRESS'", AppDelayPeer::APP_TYPE) + ); + } + + //Define the joins + $c->addJoin(AppDelegationPeer::USR_ID, UsersPeer::USR_ID, Criteria::LEFT_JOIN); + $c->addJoin(AppDelegationPeer::TAS_ID, TaskPeer::TAS_ID, Criteria::LEFT_JOIN); + $del = DBAdapter::getStringDelimiter(); - $app = array(); - $app[] = array(AppDelegationPeer::DEL_INDEX, AppDelayPeer::APP_DEL_INDEX); - $app[] = array(AppDelegationPeer::APP_UID, AppDelayPeer::APP_UID); + $app = []; + $app[] = [AppDelegationPeer::DEL_INDEX, AppDelayPeer::APP_DEL_INDEX]; + $app[] = [AppDelegationPeer::APP_NUMBER, AppDelayPeer::APP_NUMBER]; $c->addJoinMC($app, Criteria::LEFT_JOIN); - //LEFT JOIN TASK TAS_TITLE - $c->addJoin(AppDelegationPeer::TAS_UID, TaskPeer::TAS_UID, Criteria::LEFT_JOIN); + //Define the where + $c->add(AppDelegationPeer::APP_NUMBER, $appNumber); - //WHERE - $c->add(AppDelegationPeer::APP_UID, $sAppUid); - - //ORDER BY + //Order by $c->clearOrderByColumns(); $c->addAscendingOrderByColumn(AppDelegationPeer::DEL_DELEGATE_DATE); @@ -4144,216 +4197,207 @@ class Cases } /** - * cancel a case + * Cancel case without matter the threads + * if the force is true, we will cancel it does not matter the threads + * if the force is false, we will to cancel one thread * - * @name cancelCase - * @param string $sApplicationUID - * @param string $iIndex - * @param string $user_logged - * @return void - */ - public function cancelCase($sApplicationUID, $iIndex, $user_logged) + * @param string $appUid + * @param integer $delIndex + * @param string $usrUid + * + * @return boolean|string + */ + public function cancelCase($appUid, $delIndex = null, $usrUid = null) { - $this->getExecuteTriggerProcess($sApplicationUID, 'CANCELED'); + /** Execute a trigger when a case is cancelled */ + $this->getExecuteTriggerProcess($appUid, 'CANCELED'); - $oApplication = new Application(); - $aFields = $oApplication->load($sApplicationUID); + $caseFields = $this->loadCase($appUid); + $appStatusCurrent = $caseFields['APP_STATUS']; - $appData = self::unserializeData($aFields['APP_DATA']); - $appData = G::array_merges(G::getSystemConstants(), $appData); + /** Update the status CANCELLED in the tables related */ + $caseFields['APP_STATUS'] = Application::APP_STATUS_CANCELLED; + $this->updateCase($appUid, $caseFields); - $appStatusCurrent = $aFields['APP_STATUS']; - $oCriteria = new Criteria('workflow'); - $oCriteria->add(AppDelegationPeer::APP_UID, $sApplicationUID); - $oCriteria->add(AppDelegationPeer::DEL_FINISH_DATE, null, Criteria::ISNULL); - $resAppDel = AppDelegationPeer::doCount($oCriteria); - - $this->CloseCurrentDelegation($sApplicationUID, $iIndex); - if ($resAppDel == 1) { - $aFields['APP_STATUS'] = 'CANCELLED'; - $oApplication->update($aFields); - - require_once 'classes/model/AdditionalTables.php'; - $oReportTables = new ReportTables(); - $addtionalTables = new additionalTables(); - $oReportTables->updateTables($aFields['PRO_UID'], $aFields['APP_UID'], $aFields['APP_NUMBER'], $appData); - $addtionalTables->updateReportTables($aFields['PRO_UID'], $aFields['APP_UID'], $aFields['APP_NUMBER'], $appData, $aFields['APP_STATUS']); - } - $oAppDel = new AppDelegation(); - $oAppDel->Load($sApplicationUID, $iIndex); - $aAppDel = $oAppDel->toArray(BasePeer::TYPE_FIELDNAME); - $this->closeAppThread($sApplicationUID, $aAppDel['DEL_THREAD']); + /** Close the thread(s) in APP_DELEGATION and APP_THREAD */ + $indexesClosed = self::closeCaseThreads($appUid, $delIndex); + /** Create a register in APP_DELAY */ $delay = new AppDelay(); - $array['PRO_UID'] = $aFields['PRO_UID']; - $array['APP_UID'] = $sApplicationUID; - $c = new Criteria('workflow'); - $c->clearSelectColumns(); - $c->addSelectColumn(AppThreadPeer::APP_THREAD_INDEX); - $c->add(AppThreadPeer::APP_UID, $sApplicationUID); - $c->add(AppThreadPeer::DEL_INDEX, $iIndex); - $oDataset = AppThreadPeer::doSelectRS($c); - $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); - $oDataset->next(); - $aRow = $oDataset->getRow(); - $array['APP_THREAD_INDEX'] = $aRow['APP_THREAD_INDEX']; - $array['APP_DEL_INDEX'] = $iIndex; - $array['APP_TYPE'] = 'CANCEL'; + foreach ($indexesClosed as $value){ + $dataList = []; + $rowDelay = AppDelay::buildAppDelayRow( + $caseFields['PRO_UID'], + isset($caseFields['PRO_ID']) ? $caseFields['PRO_ID'] : 0, + $appUid, + $caseFields['APP_NUMBER'], + $value['DEL_THREAD'], + $value['DEL_INDEX'], + AppDelay::APP_TYPE_CANCEL, + Application::APP_STATUS_CANCELLED, + is_null($usrUid) ? '' : $usrUid + ); + $delay->create($rowDelay); - $c = new Criteria('workflow'); - $c->clearSelectColumns(); - $c->addSelectColumn(ApplicationPeer::APP_STATUS); - $c->add(ApplicationPeer::APP_UID, $sApplicationUID); - $oDataset = ApplicationPeer::doSelectRS($c); - $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); - $oDataset->next(); - $aRow1 = $oDataset->getRow(); - $array['APP_STATUS'] = $aRow1['APP_STATUS']; + /*----------------------------------********---------------------------------*/ + $dataList = [ + 'APP_UID' => $appUid, + 'DEL_INDEX' => $value['DEL_INDEX'], + 'USR_UID' => $rowDelay['APP_DELEGATION_USER'], + 'APP_STATUS_CURRENT' => $appStatusCurrent + ]; - $array['APP_DELEGATION_USER'] = $user_logged; - $array['APP_ENABLE_ACTION_USER'] = $user_logged; - $array['APP_ENABLE_ACTION_DATE'] = date('Y-m-d H:i:s'); - $array['APP_NUMBER'] = $oApplication->getAppNumber(); - $delay->create($array); + $dataList = array_merge($caseFields, $dataList); + $listCanceled = new ListCanceled(); + $listCanceled->create($dataList); + /*----------------------------------********---------------------------------*/ + } + } - //Before cancel a case verify if is a child case - $oCriteria2 = new Criteria('workflow'); - $oCriteria2->add(SubApplicationPeer::APP_UID, $sApplicationUID); - $oCriteria2->add(SubApplicationPeer::SA_STATUS, 'ACTIVE'); - if (SubApplicationPeer::doCount($oCriteria2) > 0) { - $oDerivation = new Derivation(); - $oDerivation->verifyIsCaseChild($sApplicationUID, $iIndex); + /** + * This function will be close the one or all threads + * + * @param string $appUid + * @param integer $delIndex, if is null we will to close all threads + * + * @return array + */ + private function closeCaseThreads($appUid, $delIndex = null) + { + $delegation = new AppDelegation(); + $result = []; + + /** Close all the threads in APP_DELEGATION and APP_THREAD */ + if (is_null($delIndex)) { + /*----------------------------------********---------------------------------*/ + $result = $delegation->LoadParallel($appUid); + $this->closeAllDelegations($appUid); + $this->closeAllThreads($appUid); + /*----------------------------------********---------------------------------*/ + + } else { + /** Close the specific delIndex in APP_DELEGATION and APP_THREAD */ + $this->CloseCurrentDelegation($appUid, $delIndex); + $resultDelegation = $delegation->Load($appUid, $delIndex); + $this->closeAppThread($appUid, $resultDelegation['DEL_THREAD']); + $result[] = $resultDelegation; } - //update searchindex - if ($this->appSolr != null) { - $this->appSolr->updateApplicationSearchIndex($sApplicationUID); - } - /*----------------------------------********---------------------------------*/ - $data = array( - 'APP_UID' => $sApplicationUID, - 'DEL_INDEX' => $iIndex, - 'USR_UID' => $user_logged, - 'APP_STATUS_CURRENT' => $appStatusCurrent - ); - $data = array_merge($aFields, $data); - $oListCanceled = new ListCanceled(); - $oListCanceled->create($data); - /*----------------------------------********---------------------------------*/ + return $result; } /** * Un cancel case * - * @param string $caseUID - * @param string $userUID - * @return int + * @param string $appUid + * @param string $usrUid + * + * @return void + * @throws Exception */ - public function unCancelCase($appUID, $userUID) + public function unCancelCase($appUid, $usrUid) { try { - $oUser = new \ProcessMaker\BusinessModel\User(); - if (!$oUser->checkPermission($userUID, 'PM_UNCANCELCASE')) { + $user = new BusinessModelUser(); + /** Review if the user has the permission PM_UNCANCELCASE */ + if (!$user->checkPermission($usrUid, 'PM_UNCANCELCASE')) { throw new Exception(G::LoadTranslation('ID_YOU_DO_NOT_HAVE_PERMISSION')); } - $application = new Application(); - $rowApplication = $application->load($appUID); - if ($rowApplication["APP_STATUS"] !== "CANCELLED") { - throw new Exception(G::LoadTranslation('ID_THE_APPLICATION_IS_NOT_CANCELED', [$appUID])); + $caseFields = $this->loadCase($appUid); + /** Review if the case has the status CANCELLED */ + if ($caseFields["APP_STATUS"] !== Application::APP_STATUS_CANCELLED) { + throw new Exception(G::LoadTranslation('ID_THE_APPLICATION_IS_NOT_CANCELED', [$appUid])); } - $criteriaAppDelay = new Criteria('workflow'); - $criteriaAppDelay->add(AppDelayPeer::APP_UID, $appUID); - $criteriaAppDelay->add(AppDelayPeer::APP_STATUS, 'CANCELLED'); - $criteriaAppDelay->add(AppDelayPeer::PRO_UID, $rowApplication['PRO_UID']); - $criteriaAppDelay->addDescendingOrderByColumn(AppDelayPeer::APP_ENABLE_ACTION_DATE); - $resultSetAppDelay = AppDelayPeer::doSelectRS($criteriaAppDelay); - $resultSetAppDelay->setFetchmode(ResultSet::FETCHMODE_ASSOC); - $resultSetAppDelay->next(); - $rowAppDelay = $resultSetAppDelay->getRow(); - if (!isset($rowAppDelay['APP_STATUS'])) { - throw new Exception(G::LoadTranslation('ID_THREAD_STATUS_DOES_NOT_EXIST_FOR_THE_APPLICATION.', [$appUID])); - } + //Load the USR_ID + $u = new Users(); + $userId = $u->load($usrUid)['USR_ID']; - //Application - $rowApplication['APP_STATUS'] = 'TO_DO'; - $rowApplication['APP_UPDATE_DATE'] = date('Y-m-d H:i:s'); - $application->update($rowApplication); - - //AppDelegation - $appDelegation = new AppDelegation(); - $rowAppDelegation = $appDelegation->Load($appUID, $rowAppDelay['APP_DEL_INDEX']); - - $appDelegation = new AppDelegation(); - $delIndex = $appDelegation->createAppDelegation($rowAppDelegation['PRO_UID'], $rowAppDelegation['APP_UID'], $rowAppDelegation['TAS_UID'], $userUID, $rowAppDelay['APP_THREAD_INDEX']); - - //AppThread - $dataAppThread = [ - 'APP_UID' => $rowApplication['APP_UID'], - 'APP_THREAD_INDEX' => $rowAppDelay['APP_THREAD_INDEX'], - 'APP_THREAD_STATUS' => 'OPEN', - 'DEL_INDEX' => $delIndex - ]; - $appThread = new AppThread(); - $appThread->update($dataAppThread); - - //AppDelay - $dataAppDelay = [ - 'PRO_UID' => $rowApplication['PRO_UID'], - 'APP_UID' => $rowApplication['APP_UID'], - 'APP_THREAD_INDEX' => $rowAppDelay['APP_THREAD_INDEX'], - 'APP_DELINDEX' => $delIndex, - 'APP_TYPE' => 'UNCANCEL', - 'APP_STATUS' => $rowApplication['APP_STATUS'], - 'APP_NEXT_TASK' => 0, - 'APP_DELEGATION_USER' => $userUID, - 'APP_ENABLE_ACTION_USER' => $userUID, - 'APP_ENABLE_ACTION_DATE' => date('Y-m-d H:i:s'), - 'APP_DISABLE_ACTION_USER' => 0 - ]; + //Get the list of thread that close with the CancelCase $appDelay = new AppDelay(); - $appDelay->create($dataAppDelay); + $threadsCanceled = $appDelay->getThreadByStatus($appUid, Application::APP_STATUS_CANCELLED); - //ListCanceled - $criteriaListCanceled = new Criteria("workflow"); - $criteriaListCanceled->add(ListCanceledPeer::APP_UID, $appUID); - $resultSetListCanceled = ListCanceledPeer::doSelectRS($criteriaListCanceled); - $resultSetListCanceled->setFetchmode(ResultSet::FETCHMODE_ASSOC); - $resultSetListCanceled->next(); - $rowListCanceled = $resultSetListCanceled->getRow(); - ListCanceledPeer::doDelete($criteriaListCanceled); + //Get all the threads in the AppDelay + foreach ($threadsCanceled as $row){ + //Load the thread CLOSED + $appDelegation = new AppDelegation(); + $delegationClosed = $appDelegation->Load($appUid, $row['APP_DEL_INDEX']); + //Create an appDelegation for each thread + $appDelegation = new AppDelegation(); + $delIndex = $appDelegation->createAppDelegation( + $delegationClosed['PRO_UID'], + $delegationClosed['APP_UID'], + $delegationClosed['TAS_UID'], + $usrUid, + $delegationClosed['DEL_THREAD'], + 3, + false, + $delegationClosed['DEL_PREVIOUS'], + null, + false, + false, + 0, + $delegationClosed['APP_NUMBER'], + $delegationClosed['TAS_ID'], + $userId, + $delegationClosed['PRO_ID'] + ); - //ListInbox - $rowListCanceled['DEL_PREVIOUS_USR_USERNAME'] = $rowListCanceled['DEL_CURRENT_USR_USERNAME']; - $rowListCanceled['DEL_PREVIOUS_USR_FIRSTNAME'] = $rowListCanceled['DEL_CURRENT_USR_FIRSTNAME']; - $rowListCanceled['DEL_PREVIOUS_USR_LASTNAME'] = $rowListCanceled['DEL_CURRENT_USR_LASTNAME']; - $rowListCanceled['APP_STATUS'] = 'TO_DO'; - $rowListCanceled['APP_UPDATE_DATE'] = date('Y-m-d H:i:s'); - $rowListCanceled['DEL_RISK_DATE'] = date('Y-m-d H:i:s'); - $rowListCanceled['DEL_INDEX'] = $delIndex; - unset($rowListCanceled['DEL_CURRENT_USR_USERNAME']); - unset($rowListCanceled['DEL_CURRENT_USR_FIRSTNAME']); - unset($rowListCanceled['DEL_CURRENT_USR_LASTNAME']); - unset($rowListCanceled['APP_CANCELED_DATE']); + //Update the appThread + $dataAppThread = [ + 'APP_UID' => $row['APP_UID'], + 'APP_THREAD_INDEX' => $delegationClosed['DEL_THREAD'], + 'APP_THREAD_STATUS' => 'OPEN', + 'DEL_INDEX' => $delIndex + ]; + $appThread = new AppThread(); + $res = $appThread->update($dataAppThread); - $this->putCaseInInboxList($rowListCanceled, $userUID); + //New register in AppDelay + $newAppDelay = AppDelay::buildAppDelayRow( + $row['PRO_UID'], + $delegationClosed['PRO_ID'], + $row['APP_UID'], + $delegationClosed['APP_NUMBER'], + $row['APP_THREAD_INDEX'], + $delIndex, + AppDelay::APP_TYPE_UNCANCEL, + Application::APP_STATUS_TODO, + $usrUid, + $userId + ); + $appDelay->create($newAppDelay); - //ListParticipatedLast - $criteriaListParticipatedLast = new Criteria("workflow"); - $criteriaListParticipatedLast->add(ListParticipatedLastPeer::APP_UID, $appUID); - $resultSetListParticipatedLast = ListParticipatedLastPeer::doSelectRS($criteriaListParticipatedLast); - $resultSetListParticipatedLast->setFetchmode(ResultSet::FETCHMODE_ASSOC); - $resultSetListParticipatedLast->next(); - $rowListParticipatedLast = $resultSetListParticipatedLast->getRow(); - $rowListParticipatedLast['APP_STATUS'] = 'TO_DO'; - $rowListParticipatedLast['DEL_THREAD_STATUS'] = 'OPEN'; - $rowListParticipatedLast['DEL_INIT_DATE'] = null; - $listParticipatedLast = new ListParticipatedLast(); - $listParticipatedLast->update($rowListParticipatedLast); - } catch (Exception $oException) { - throw $oException; + //New register in the listInbox + $newDelegation = array_merge($newAppDelay, $delegationClosed); + $newDelegation['USR_UID'] = $usrUid; + $newDelegation['DEL_INDEX'] = $delIndex; + $newDelegation['APP_STATUS'] = Application::APP_STATUS_TODO; + $inbox = new ListInbox(); + //Get the previous user + //When the status of the case is DRAFT we does not have a previous thread + $previousUser = ''; + if ($delegationClosed['DEL_PREVIOUS'] != 0){ + $appDelegation = new AppDelegation(); + $delegationPrevious = $appDelegation->Load($appUid, $delegationClosed['DEL_PREVIOUS']); + $previousUser = $delegationPrevious['USR_UID']; + } + + $inbox->newRow($newDelegation, $previousUser); + } + + //Update the status of the case + $caseFields['APP_STATUS'] = Application::APP_STATUS_TODO; + $this->updateCase($appUid, $caseFields); + + //Remove the case from the list Canceled + $listCanceled = new ListCanceled(); + $listCanceled->removeAll($appUid); + + } catch (Exception $exception) { + throw $exception; } } diff --git a/workflow/engine/classes/PmDynaform.php b/workflow/engine/classes/PmDynaform.php index 438cf2a37..6accc2093 100644 --- a/workflow/engine/classes/PmDynaform.php +++ b/workflow/engine/classes/PmDynaform.php @@ -252,6 +252,11 @@ class PmDynaform $dtFields = $json->queryInputData; } else { $dtFields = $this->getValuesDependentFields($json); + foreach ($dtFields as $keyF => $valueF) { + if (isset($this->fields["APP_DATA"][$keyF])) { + $dtFields[$keyF] = $this->fields["APP_DATA"][$keyF]; + } + } } $sql = G::replaceDataField($json->sql, $dtFields); if ($value === "suggest") { diff --git a/workflow/engine/classes/WorkspaceTools.php b/workflow/engine/classes/WorkspaceTools.php index 63999ed0e..8a56249d6 100644 --- a/workflow/engine/classes/WorkspaceTools.php +++ b/workflow/engine/classes/WorkspaceTools.php @@ -3960,7 +3960,7 @@ class WorkspaceTools WHERE AM.TAS_ID = 0 AND AM.PRO_ID = 0 AND AM.APP_NUMBER != 0 AND AM.DEL_INDEX != 0"); $con->commit(); - // Populating APP_MESSAGE.PRO_ID when does not exits DEL_INDEX + // Populating APP_MESSAGE.PRO_ID CLI::logging("-> Populating APP_MESSAGE.PRO_ID\n"); $con->begin(); $stmt = $con->createStatement(); @@ -3976,7 +3976,7 @@ class WorkspaceTools WHERE AM.PRO_ID = 0 AND AM.APP_NUMBER != 0"); $con->commit(); - // Populating APP_MESSAGE.PRO_ID + // Populating APP_MESSAGE.APP_MSG_STATUS_ID CLI::logging("-> Populating APP_MESSAGE.APP_MSG_STATUS_ID \n"); $con->begin(); $rs = $stmt->executeQuery("UPDATE APP_MESSAGE @@ -3989,8 +3989,8 @@ class WorkspaceTools APP_MSG_STATUS_ID = 0"); $con->commit(); - // Populating APP_MESSAGE.PRO_ID - CLI::logging("-> Populating APP_MESSAGE.APP_MSG_STATUS_ID \n"); + // Populating APP_MESSAGE.APP_MSG_TYPE_ID + CLI::logging("-> Populating APP_MESSAGE.APP_MSG_TYPE_ID \n"); $con->begin(); $rs = $stmt->executeQuery("UPDATE APP_MESSAGE SET APP_MSG_TYPE_ID = (case @@ -4003,6 +4003,28 @@ class WorkspaceTools APP_MSG_TYPE_ID = 0"); $con->commit(); + // Populating TAS.TAS_TITLE with BPMN_EVENT.EVN_NAME + /*----------------------------------********---------------------------------*/ + CLI::logging("-> Populating TASK.TAS_TITLE with BPMN_EVENT.EVN_NAME\n"); + $con->begin(); + $rs = $stmt->executeQuery("UPDATE TASK + INNER JOIN ( + SELECT ELEMENT_TASK_RELATION.TAS_UID, BPMN_EVENT.EVN_NAME + FROM ELEMENT_TASK_RELATION + JOIN BPMN_EVENT ON (BPMN_EVENT.EVN_UID = ELEMENT_TASK_RELATION.ELEMENT_UID) + ) AS EVENT + ON (TASK.TAS_UID = EVENT.TAS_UID) + SET TASK.TAS_TITLE = EVENT.EVN_NAME + WHERE TASK.TAS_TITLE IN ( + 'INTERMEDIATE-THROW-MESSAGE-EVENT', + 'INTERMEDIATE-THROW-EMAIL-EVENT', + 'INTERMEDIATE-CATCH-TIMER-EVENT', + 'INTERMEDIATE-CATCH-MESSAGE-EVENT' + ) + AND EVENT.EVN_NAME != ''"); + $con->commit(); + /*----------------------------------********---------------------------------*/ + CLI::logging("-> Migrating And Populating Indexing for avoiding the use of table APP_CACHE_VIEW Done \n"); // Populating PRO_ID, USR_ID diff --git a/workflow/engine/classes/WsBase.php b/workflow/engine/classes/WsBase.php index 7924d8120..1fa01e505 100644 --- a/workflow/engine/classes/WsBase.php +++ b/workflow/engine/classes/WsBase.php @@ -2479,6 +2479,7 @@ class WsBase ); //Execute triggers after routing + $appFields = $oCase->loadCase($caseId); $varTriggers .= $this->executeTriggerFromDerivate( $caseId, $appFields["APP_DATA"], @@ -2941,7 +2942,6 @@ class WsBase } $result = new WsResponse(0, G::loadTranslation('ID_COMMAND_EXECUTED_SUCCESSFULLY')); - $g->sessionVarRestore(); return $result; @@ -3068,14 +3068,7 @@ class WsBase $case->removeCase($caseUid); //Response - $res = new WsResponse(0, G::LoadTranslation("ID_COMMAND_EXECUTED_SUCCESSFULLY")); - - $result = array( - "status_code" => $res->status_code, - "message" => $res->message, - "timestamp" => $res->timestamp - ); - + $result = self::messageExecuteSuccessfully(); $g->sessionVarRestore(); return $result; @@ -3095,7 +3088,7 @@ class WsBase * @param int delIndex : Delegation index of the case. * @param string userUid : The unique ID of the user who will cancel the case. * - * @return $result will return an object + * @return array | object */ public function cancelCase($caseUid, $delIndex, $userUid) { @@ -3109,62 +3102,68 @@ class WsBase $_SESSION["USER_LOGGED"] = $userUid; if (empty($caseUid)) { - $result = new WsResponse(100, G::LoadTranslation("ID_REQUIRED_FIELD") . " caseUid"); - $g->sessionVarRestore(); - return $result; - } - - if (empty($delIndex)) { - $result = new WsResponse(100, G::LoadTranslation("ID_REQUIRED_FIELD") . " delIndex"); - - $g->sessionVarRestore(); - - return $result; - } - - if (empty($userUid)) { - $result = new WsResponse(100, G::LoadTranslation("ID_REQUIRED_FIELD") . " userUid"); - - $g->sessionVarRestore(); - - return $result; - } - - $oApplication = new Application(); - $aFields = $oApplication->load($caseUid); - if ($aFields['APP_STATUS'] == 'DRAFT') { - $result = new WsResponse(100, G::LoadTranslation("ID_CASE_IN_STATUS") . " DRAFT"); - $g->sessionVarRestore(); - return $result; - } - $oAppThread = new AppThread(); - $cant = $oAppThread->countStatus($caseUid, 'OPEN'); - if ($cant > 1) { - $result = new WsResponse(100, G::LoadTranslation("ID_CASE_CANCELLED_PARALLEL")); - $g->sessionVarRestore(); - return $result; + return self::messageRequiredField('caseUid'); } $case = new Cases(); - $case->cancelCase($caseUid, $delIndex, $userUid); + $statusCase = $case->loadCase($caseUid)['APP_STATUS']; + if ($statusCase !== 'TO_DO') { + $g->sessionVarRestore(); - //Response - $res = new WsResponse(0, G::LoadTranslation("ID_COMMAND_EXECUTED_SUCCESSFULLY")); + return self::messageIllegalValues('ID_CASE_IN_STATUS', ' ' . $statusCase); + } - $result = array( - "status_code" => $res->status_code, - "message" => $res->message, - "timestamp" => $res->timestamp - ); + /** If those parameters are null we will to force the cancelCase */ + if (is_null($delIndex) && is_null($userUid)) { + /*----------------------------------********---------------------------------*/ + $case->cancelCase($caseUid, null, null); + $result = self::messageExecuteSuccessfully(); + $g->sessionVarRestore(); + return $result; + /*----------------------------------********---------------------------------*/ + } + + /** We will to continue with review the threads */ + if (empty($delIndex)) { + $g->sessionVarRestore(); + + return self::messageRequiredField('delIndex'); + } + + $delegation = new AppDelegation(); + $indexOpen = $delegation->LoadParallel($caseUid, $delIndex); + if (empty($indexOpen)) { + $g->sessionVarRestore(); + + return self::messageIllegalValues('ID_CASE_DELEGATION_ALREADY_CLOSED'); + } + + if (empty($userUid)) { + $g->sessionVarRestore(); + + return self::messageRequiredField('userUid'); + } + + if (AppThread::countStatus($caseUid, 'OPEN') > 1) { + $g->sessionVarRestore(); + + return self::messageIllegalValues("ID_CASE_CANCELLED_PARALLEL"); + } + + + /** Cancel case */ + $case->cancelCase($caseUid, (int)$delIndex, $userUid); + + //Define the result of the cancelCase + $result = self::messageExecuteSuccessfully(); $g->sessionVarRestore(); return $result; } catch (Exception $e) { $result = new WsResponse(100, $e->getMessage()); - $g->sessionVarRestore(); return $result; @@ -3230,15 +3229,9 @@ class WsBase $case->pauseCase($caseUid, $delIndex, $userUid, $unpauseDate); //Response - $res = new WsResponse(0, G::LoadTranslation("ID_COMMAND_EXECUTED_SUCCESSFULLY")); - - $result = array( - "status_code" => $res->status_code, - "message" => $res->message, - "timestamp" => $res->timestamp - ); - + $result = self::messageExecuteSuccessfully(); $g->sessionVarRestore(); + return $result; } catch (Exception $e) { $result = new WsResponse(100, $e->getMessage()); @@ -3297,14 +3290,7 @@ class WsBase $case->unpauseCase($caseUid, $delIndex, $userUid); //Response - $res = new WsResponse(0, G::LoadTranslation("ID_COMMAND_EXECUTED_SUCCESSFULLY")); - - $result = array( - "status_code" => $res->status_code, - "message" => $res->message, - "timestamp" => $res->timestamp - ); - + $result = self::messageExecuteSuccessfully(); $g->sessionVarRestore(); return $result; @@ -3411,4 +3397,52 @@ class WsBase return $result; } } + + /** + * Define the message for the required fields + * + * @param string $field + * @param integer code + * + * @return object + */ + private function messageRequiredField($field, $code = 100) + { + $result = new WsResponse($code, G::LoadTranslation("ID_REQUIRED_FIELD") . ' ' . $field); + + return $result; + } + + /** + * Define the message for the required fields + * + * @param string $translationId + * @param string $field + * @param integer code + * + * @return object + */ + private function messageIllegalValues($translationId, $field = '', $code = 100) + { + $result = new WsResponse($code, G::LoadTranslation($translationId) . $field); + + return $result; + } + + /** + * Define the result when it's execute successfully + * + * @return object + */ + private function messageExecuteSuccessfully() + { + $res = new WsResponse(0, G::LoadTranslation("ID_COMMAND_EXECUTED_SUCCESSFULLY")); + $result = [ + "status_code" => $res->status_code, + "message" => $res->message, + "timestamp" => $res->timestamp + ]; + + return $result; + } } diff --git a/workflow/engine/classes/class.pmFunctions.php b/workflow/engine/classes/class.pmFunctions.php index 67b9410c3..ac52fbd93 100644 --- a/workflow/engine/classes/class.pmFunctions.php +++ b/workflow/engine/classes/class.pmFunctions.php @@ -2766,7 +2766,8 @@ function PMFDeleteCase ($caseUid) function PMFCancelCase ($caseUid, $delIndex, $userUid) { $ws = new WsBase(); - $result = $ws->cancelCase( $caseUid, $delIndex, $userUid ); + $result = $ws->cancelCase($caseUid, $delIndex, $userUid); + $result = (object)$result; if ($result->status_code == 0) { if (isset($_SESSION['APPLICATION']) && isset($_SESSION['INDEX'])) { @@ -2775,10 +2776,17 @@ function PMFCancelCase ($caseUid, $delIndex, $userUid) G::header('Location: ../cases/casesListExtJsRedirector'); die(); } else { - die(G::LoadTranslation('ID_PM_FUNCTION_CHANGE_CASE', SYS_LANG, array('PMFCancelCase', G::LoadTranslation('ID_CANCELLED')))); + die( + G::LoadTranslation( + 'ID_PM_FUNCTION_CHANGE_CASE', + SYS_LANG, + ['PMFCancelCase', G::LoadTranslation('ID_CANCELLED')] + ) + ); } } } + return 1; } else { return 0; diff --git a/workflow/engine/classes/model/AppDelay.php b/workflow/engine/classes/model/AppDelay.php index d2aa9dc85..f8445c2e6 100644 --- a/workflow/engine/classes/model/AppDelay.php +++ b/workflow/engine/classes/model/AppDelay.php @@ -1,12 +1,4 @@ fromArray($aData, BasePeer::TYPE_FIELDNAME); - if ($oAppDelay->validate()) { - $oConnection->begin(); - $iResult = $oAppDelay->save(); - $oConnection->commit(); - return $aData['APP_DELAY_UID']; + $appDelay = new AppDelay(); + $appDelay->fromArray($data, BasePeer::TYPE_FIELDNAME); + if ($appDelay->validate()) { + $connection->begin(); + $result = $appDelay->save(); + $connection->commit(); + + return $data['APP_DELAY_UID']; } else { - $sMessage = ''; - $aValidationFailures = $oAppDelay->getValidationFailures(); - foreach ($aValidationFailures as $oValidationFailure) { - $sMessage .= $oValidationFailure->getMessage() . '
'; + $message = ''; + $validationFailures = $appDelay->getValidationFailures(); + foreach ($validationFailures as $validationFailure) { + $message .= $validationFailure->getMessage() . '
'; } - throw(new Exception('The registry cannot be created!
'.$sMessage)); + throw(new Exception('The registry cannot be created!
' . $message)); } - } catch (Exception $oError) { - $oConnection->rollback(); - throw($oError); + } catch (Exception $error) { + $connection->rollback(); + throw($error); } } /** * Update the application delay registry - * @param array $aData + * + * @param array $data + * * @return string + * @throws Exception **/ - public function update($aData) + public function update($data) { - $oConnection = Propel::getConnection(AppDelayPeer::DATABASE_NAME); + $connection = Propel::getConnection(AppDelayPeer::DATABASE_NAME); try { - $oAppDelay = AppDelayPeer::retrieveByPK($aData['APP_DELAY_UID']); - if (!is_null($oAppDelay)) { - $oAppDelay->fromArray($aData, BasePeer::TYPE_FIELDNAME); - if ($oAppDelay->validate()) { - $oConnection->begin(); - $iResult = $oAppDelay->save(); - $oConnection->commit(); - return $iResult; + $appDelay = AppDelayPeer::retrieveByPK($data['APP_DELAY_UID']); + if (!is_null($appDelay)) { + $appDelay->fromArray($data, BasePeer::TYPE_FIELDNAME); + if ($appDelay->validate()) { + $connection->begin(); + $result = $appDelay->save(); + $connection->commit(); + return $result; } else { - $sMessage = ''; - $aValidationFailures = $oAppDelay->getValidationFailures(); - foreach ($aValidationFailures as $oValidationFailure) { - $sMessage .= $oValidationFailure->getMessage() . '
'; + $message = ''; + $validationFailures = $appDelay->getValidationFailures(); + foreach ($validationFailures as $validationFailure) { + $message .= $validationFailure->getMessage() . '
'; } - throw(new Exception('The registry cannot be updated!
'.$sMessage)); + throw(new Exception('The registry cannot be updated!
'.$message)); } } else { throw(new Exception('This row doesn\'t exist!')); } - } catch (Exception $oError) { - $oConnection->rollback(); - throw($oError); + } catch (Exception $error) { + $connection->rollback(); + throw($error); } } + /** + * Review if the application in a specific index is paused + * + * @param string $appUid + * @param integer $delIndex + * + * @return boolean + */ public function isPaused($appUid, $delIndex) { - $oCriteria = new Criteria('workflow'); - $oCriteria->add(AppDelayPeer::APP_UID, $appUid); - $oCriteria->add(AppDelayPeer::APP_DEL_INDEX, $delIndex); - $oCriteria->add(AppDelayPeer::APP_TYPE, 'PAUSE'); - $oCriteria->add( - $oCriteria->getNewCriterion(AppDelayPeer::APP_DISABLE_ACTION_USER, 0, Criteria::EQUAL)->addOr( - $oCriteria->getNewCriterion(AppDelayPeer::APP_DISABLE_ACTION_USER, null, Criteria::ISNULL)) + $criteria = new Criteria('workflow'); + $criteria->add(AppDelayPeer::APP_UID, $appUid); + $criteria->add(AppDelayPeer::APP_DEL_INDEX, $delIndex); + $criteria->add(AppDelayPeer::APP_TYPE, AppDelay::APP_TYPE_PAUSE); + $criteria->add( + $criteria->getNewCriterion(AppDelayPeer::APP_DISABLE_ACTION_USER, 0, Criteria::EQUAL)->addOr( + $criteria->getNewCriterion(AppDelayPeer::APP_DISABLE_ACTION_USER, null, Criteria::ISNULL)) ); - $oDataset = AppDelayPeer::doSelectRS($oCriteria); - $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); - $oDataset->next(); - $aRow = $oDataset->getRow(); + $dataset = AppDelayPeer::doSelectRS($criteria); + $dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); + $dataset->next(); + $row = $dataset->getRow(); - if ($aRow) { + if ($row) { return true; } else { return false; @@ -117,20 +128,116 @@ class AppDelay extends BaseAppDelay * Verify if the case is Paused or cancelled * * @param $appUid string - * @return $oDataset array + * + * @return array|null */ public function getCasesCancelOrPaused($appUid) { - $oCriteria = new Criteria( 'workflow' ); - $oCriteria->addSelectColumn( AppDelayPeer::APP_UID ); - $oCriteria->addSelectColumn( AppDelayPeer::APP_DEL_INDEX ); - $oCriteria->add( AppDelayPeer::APP_UID, $appUid ); - $oCriteria->add( $oCriteria->getNewCriterion( AppDelayPeer::APP_TYPE, 'PAUSE' )->addOr( $oCriteria->getNewCriterion( AppDelayPeer::APP_TYPE, 'CANCEL' ) ) ); - $oCriteria->addAscendingOrderByColumn( AppDelayPeer::APP_ENABLE_ACTION_DATE ); - $oDataset = AppDelayPeer::doSelectRS( $oCriteria ); - $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); - $oDataset->next(); - return $oDataset->getRow(); + $criteria = new Criteria('workflow'); + $criteria->addSelectColumn(AppDelayPeer::APP_UID); + $criteria->addSelectColumn(AppDelayPeer::APP_DEL_INDEX); + $criteria->add(AppDelayPeer::APP_UID, $appUid); + $criteria->add( + $criteria->getNewCriterion(AppDelayPeer::APP_TYPE, AppDelay::APP_TYPE_PAUSE)->addOr( + $criteria->getNewCriterion(AppDelayPeer::APP_TYPE, AppDelay::APP_TYPE_CANCEL) + ) + ); + $criteria->addAscendingOrderByColumn(AppDelayPeer::APP_ENABLE_ACTION_DATE); + $dataset = AppDelayPeer::doSelectRS($criteria); + $dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); + $dataset->next(); + + return $dataset->getRow(); + } + + /** + * Build the row for the appDelay to be inserted + * + * @param string $proUid + * @param integer $proId + * @param string $appUid + * @param integer $appNumber + * @param integer $appThreadIndex + * @param integer $delIndex + * @param string $appType + * @param string $appStatus + * @param string $usrUid + * @param integer $usrId + * + * @return array + */ + public static function buildAppDelayRow( + $proUid = '', + $proId = 0, + $appUid = '', + $appNumber = 0, + $appThreadIndex = 0, + $delIndex = 0, + $appType = 'CANCEL', + $appStatus = 'CANCELLED', + $usrUid = '', + $usrId = 0 + ) { + $row = []; + $row['PRO_UID'] = $proUid; + $row['APP_UID'] = $appUid; + $row['APP_NUMBER'] = $appNumber; + $row['APP_THREAD_INDEX'] = $appThreadIndex; + $row['APP_DEL_INDEX'] = $delIndex; + $row['APP_TYPE'] = $appType; + $row['APP_STATUS'] = $appStatus; + $row['APP_ENABLE_ACTION_DATE'] = date('Y-m-d H:i:s'); + + //Load the PRO_ID if does not exit + if (empty($proId) || $proId === 0) { + $u = new Process(); + $proId = $u->load($proUid)['PRO_ID']; + } + + $row['PRO_ID'] = $proId; + //Define the user that execute the insert + if (empty($usrUid)) { + global $RBAC; + $usrUid = $RBAC->aUserInfo['USER_INFO']['USR_UID']; + $u = new Users(); + $usrId = $u->load($usrUid)['USR_ID']; + } + $row['APP_DELEGATION_USER'] = $usrUid; + $row['APP_ENABLE_ACTION_USER'] = $usrUid; + $row['APP_DELEGATION_USER_ID'] = $usrId; + + return $row; + } + + /** + * Return all threads with the status canceled + * + * @param string $appUid + * @param string $status + * + * @return array + * @throws Exception + */ + public function getThreadByStatus($appUid, $status) + { + try { + $criteria = new Criteria('workflow'); + $criteria->add(AppDelayPeer::APP_UID, $appUid); + $criteria->add(AppDelayPeer::APP_STATUS, $status); + $criteria->addDescendingOrderByColumn(AppDelayPeer::APP_ENABLE_ACTION_DATE); + $dataset = AppDelayPeer::doSelectRS($criteria); + $dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); + $dataset->next(); + $result = []; + while ($row = $dataset->getRow()) { + $result[] = $row; + $dataset->next(); + } + + return $result; + } catch (Exception $error) { + throw $error; + } } } diff --git a/workflow/engine/classes/model/AppDelegation.php b/workflow/engine/classes/model/AppDelegation.php index 89e9d892a..d47790a7e 100644 --- a/workflow/engine/classes/model/AppDelegation.php +++ b/workflow/engine/classes/model/AppDelegation.php @@ -331,16 +331,17 @@ class AppDelegation extends BaseAppDelegation } } - /* Load the Application Delegation row specified in [app_id] column value. + /** + * Load the Application Delegation row specified in [app_id] column value. + * + * @param string $appUid the uid of the application + * @param integer $index the index of the delegation * - * @param string $AppUid the uid of the application - * @param string $index the index of the delegation * @return array $Fields the fields */ - - public function LoadParallel($AppUid, $index = "") + public function LoadParallel($appUid, $index = 0) { - $aCases = array(); + $cases = []; $c = new Criteria('workflow'); $c->addSelectColumn(AppDelegationPeer::APP_UID); @@ -348,41 +349,33 @@ class AppDelegation extends BaseAppDelegation $c->addSelectColumn(AppDelegationPeer::PRO_UID); $c->addSelectColumn(AppDelegationPeer::TAS_UID); $c->addSelectColumn(AppDelegationPeer::USR_UID); + $c->addSelectColumn(AppDelegationPeer::DEL_THREAD); $c->addSelectColumn(AppDelegationPeer::DEL_DELEGATE_DATE); $c->addSelectColumn(AppDelegationPeer::DEL_INIT_DATE); $c->addSelectColumn(AppDelegationPeer::DEL_TASK_DUE_DATE); $c->addSelectColumn(AppDelegationPeer::DEL_FINISH_DATE); $c->addSelectColumn(AppDelegationPeer::DEL_PREVIOUS); - $c->add(AppDelegationPeer::DEL_THREAD_STATUS, 'OPEN'); - $c->add(AppDelegationPeer::APP_UID, $AppUid); - if (!empty($index)) { + $c->add(AppDelegationPeer::APP_UID, $appUid); + + if ($index > 0) { $c->add(AppDelegationPeer::DEL_INDEX, $index); } + $c->addDescendingOrderByColumn(AppDelegationPeer::DEL_INDEX); $rs = AppDelegationPeer::doSelectRS($c); - $row= $rs->setFetchmode(ResultSet::FETCHMODE_ASSOC); + $row = $rs->setFetchmode(ResultSet::FETCHMODE_ASSOC); $rs->next(); $row = $rs->getRow(); while (is_array($row)) { - $case = array(); - $case['TAS_UID'] = $row['TAS_UID']; - $case['USR_UID'] = $row['USR_UID']; - $case['DEL_INDEX'] = $row['DEL_INDEX']; - $case['TAS_UID'] = $row['TAS_UID']; - $case['DEL_DELEGATE_DATE'] = $row['DEL_DELEGATE_DATE']; - $case['DEL_INIT_DATE'] = $row['DEL_INIT_DATE']; - $case['DEL_TASK_DUE_DATE'] = $row['DEL_TASK_DUE_DATE']; - $case['DEL_FINISH_DATE'] = $row['DEL_FINISH_DATE']; - $case['DEL_PREVIOUS'] = $row['DEL_PREVIOUS']; - $aCases[] = $case; + $cases[] = $row; $rs->next(); $row = $rs->getRow(); } - return $aCases; + return $cases; } /** @@ -1006,5 +999,51 @@ class AppDelegation extends BaseAppDelegation return $proId; } + /** + * Get the last index by a specific status + * + * @param integer $appNumber + * @param string $status + * + * @return integer + */ + public static function getLastIndexByStatus($appNumber, $status = 'OPEN') + { + $delIndex = 0; + $criteria = new Criteria(); + $criteria->add(AppDelegationPeer::APP_NUMBER, $appNumber); + $criteria->add(AppDelegationPeer::DEL_THREAD_STATUS, $status); + $criteria->addDescendingOrderByColumn(AppDelegationPeer::DEL_INDEX); + $dataset = AppDelegationPeer::doSelectOne($criteria); + if (!is_null($dataset)) { + $delIndex = $dataset->getDelIndex(); + } + return $delIndex; + } + + /** + * Get the last index assigned to the user by a specific status + * + * @param integer $appNumber + * @param integer $usrId + * @param string $status + * + * @return integer + */ + public static function getLastIndexByUserAndStatus($appNumber, $usrId, $status = 'OPEN') + { + $delIndex = 0; + $criteria = new Criteria(); + $criteria->add(AppDelegationPeer::APP_NUMBER, $appNumber); + $criteria->add(AppDelegationPeer::USR_ID, $usrId); + $criteria->add(AppDelegationPeer::DEL_THREAD_STATUS, $status); + $criteria->addDescendingOrderByColumn(AppDelegationPeer::DEL_INDEX); + $dataset = AppDelegationPeer::doSelectOne($criteria); + if (!is_null($dataset)) { + $delIndex = $dataset->getDelIndex(); + } + + return $delIndex; + } } diff --git a/workflow/engine/classes/model/AppThread.php b/workflow/engine/classes/model/AppThread.php index fe9cf57ae..94fc2d7ee 100644 --- a/workflow/engine/classes/model/AppThread.php +++ b/workflow/engine/classes/model/AppThread.php @@ -115,13 +115,23 @@ class AppThread extends BaseAppThread } } - public function countStatus($appUid, $status='OPEN'){ + /** + * Count the open threads + * + * @param string $appUid + * @param string $status + * + * @return integer + */ + public static function countStatus($appUid, $status = 'OPEN') + { $c = new Criteria('workflow'); $c->clearSelectColumns(); - $c->addSelectColumn( AppThreadPeer::APP_THREAD_PARENT ); - $c->add(AppThreadPeer::APP_UID, $appUid ); - $c->add(AppThreadPeer::APP_THREAD_STATUS , $status ); + $c->addSelectColumn(AppThreadPeer::APP_THREAD_PARENT); + $c->add(AppThreadPeer::APP_UID, $appUid); + $c->add(AppThreadPeer::APP_THREAD_STATUS, $status); $cant = AppThreadPeer::doCount($c); + return $cant; } } diff --git a/workflow/engine/classes/model/Application.php b/workflow/engine/classes/model/Application.php index aca145a31..47742d219 100644 --- a/workflow/engine/classes/model/Application.php +++ b/workflow/engine/classes/model/Application.php @@ -46,9 +46,11 @@ class Application extends BaseApplication * This value goes in the content table * @var string */ + const APP_STATUS_CANCELLED = 'CANCELLED'; + const APP_STATUS_TODO = 'TO_DO'; + public static $app_status_values = ['DRAFT' => 1, 'TO_DO' => 2, 'COMPLETED' => 3, 'CANCELLED' => 4]; protected $app_title_content = ''; protected $app_description_content = ''; - public static $app_status_values = ['DRAFT' => 1, 'TO_DO' => 2, 'COMPLETED' => 3, 'CANCELLED' => 4]; /** * Get the [app_title_content] column value. diff --git a/workflow/engine/classes/model/ListCanceled.php b/workflow/engine/classes/model/ListCanceled.php index 317f6feb8..7796b74cb 100644 --- a/workflow/engine/classes/model/ListCanceled.php +++ b/workflow/engine/classes/model/ListCanceled.php @@ -2,29 +2,17 @@ require_once 'classes/model/om/BaseListCanceled.php'; - -/** - * Skeleton subclass for representing a row from the 'LIST_CANCELED' table. - * - * - * - * You should add additional methods to this class to meet the - * application requirements. This class will only be generated as - * long as it does not already exist in the output directory. - * - * @package classes.model - */ -// @codingStandardsIgnoreStart class ListCanceled extends BaseListCanceled implements ListInterface { use ListBaseTrait; - // @codingStandardsIgnoreEnd /** * Create List Canceled Table * - * @param type $data - * @return type + * @param array $data + * + * @return void + * @throws Exception * */ public function create($data) @@ -182,16 +170,17 @@ class ListCanceled extends BaseListCanceled implements ListInterface /** * Remove List Canceled * - * @param type $seqName - * @return type - * @throws type + * @param string $appUid + * + * @return void + * @throws Exception * */ - public function remove($app_uid) + public function remove($appUid) { $con = Propel::getConnection(ListCanceledPeer::DATABASE_NAME); try { - $this->setAppUid($app_uid); + $this->setAppUid($appUid); $con->begin(); $this->delete(); $con->commit(); @@ -201,6 +190,25 @@ class ListCanceled extends BaseListCanceled implements ListInterface } } + /** + * Remove all records related to the APP_UID + * + * @param string $appUid + * + * @return void + * @throws Exception + */ + public function removeAll($appUid) + { + try { + $criteria = new Criteria("workflow"); + $criteria->add(ListCanceledPeer::APP_UID, $appUid); + ListCanceledPeer::doDelete($criteria); + } catch (Exception $e) { + throw $e; + } + } + public function loadFilters(&$criteria, $filters) { $filter = isset($filters['filter']) ? $filters['filter'] : ""; @@ -351,4 +359,5 @@ class ListCanceled extends BaseListCanceled implements ListInterface return $this->getCountListFromPeer (ListCanceledPeer::class, $usrUid, $filters); } + } // ListCanceled diff --git a/workflow/engine/classes/model/SubApplication.php b/workflow/engine/classes/model/SubApplication.php index 50d824472..5043fe883 100644 --- a/workflow/engine/classes/model/SubApplication.php +++ b/workflow/engine/classes/model/SubApplication.php @@ -111,5 +111,22 @@ class SubApplication extends BaseSubApplication } return false; } + + /** + * Verify if is a case related to the subProcess + * + * @param string $appUid + * + * @return boolean + */ + public static function isCaseSubProcess($appUid) + { + $criteria = new Criteria('workflow'); + $criteria->add(SubApplicationPeer::APP_UID, $appUid); + $criteria->add(SubApplicationPeer::SA_STATUS, 'ACTIVE'); + $dataset = SubApplicationPeer::doSelectOne($criteria); + + return !is_null($dataset); + } } diff --git a/workflow/engine/classes/model/Task.php b/workflow/engine/classes/model/Task.php index 75b613cd5..f6ddfc66b 100644 --- a/workflow/engine/classes/model/Task.php +++ b/workflow/engine/classes/model/Task.php @@ -16,12 +16,19 @@ */ class Task extends BaseTask { + const tas_type_events = [ + 'INTERMEDIATE-THROW-MESSAGE-EVENT', + 'INTERMEDIATE-THROW-EMAIL-EVENT', + 'INTERMEDIATE-CATCH-TIMER-EVENT', + 'INTERMEDIATE-CATCH-MESSAGE-EVENT' + ]; /** * This value goes in the content table * @var string */ protected $tas_title_content = ''; + /** * Get the tas_title column value. * @return string diff --git a/workflow/engine/classes/model/map/ListCanceledMapBuilder.php b/workflow/engine/classes/model/map/ListCanceledMapBuilder.php index 27c1b357b..944cb4c1c 100644 --- a/workflow/engine/classes/model/map/ListCanceledMapBuilder.php +++ b/workflow/engine/classes/model/map/ListCanceledMapBuilder.php @@ -67,6 +67,8 @@ class ListCanceledMapBuilder $tMap->addPrimaryKey('APP_UID', 'AppUid', 'string', CreoleTypes::VARCHAR, true, 32); + $tMap->addPrimaryKey('DEL_INDEX', 'DelIndex', 'int', CreoleTypes::INTEGER, true, null); + $tMap->addColumn('USR_UID', 'UsrUid', 'string', CreoleTypes::VARCHAR, true, 32); $tMap->addColumn('TAS_UID', 'TasUid', 'string', CreoleTypes::VARCHAR, true, 32); @@ -83,8 +85,6 @@ class ListCanceledMapBuilder $tMap->addColumn('APP_CANCELED_DATE', 'AppCanceledDate', 'int', CreoleTypes::TIMESTAMP, false, null); - $tMap->addColumn('DEL_INDEX', 'DelIndex', 'int', CreoleTypes::INTEGER, true, null); - $tMap->addColumn('DEL_PREVIOUS_USR_UID', 'DelPreviousUsrUid', 'string', CreoleTypes::VARCHAR, false, 32); $tMap->addColumn('DEL_CURRENT_USR_USERNAME', 'DelCurrentUsrUsername', 'string', CreoleTypes::VARCHAR, false, 100); diff --git a/workflow/engine/classes/model/om/BaseListCanceled.php b/workflow/engine/classes/model/om/BaseListCanceled.php index 255a578cf..cd7557417 100644 --- a/workflow/engine/classes/model/om/BaseListCanceled.php +++ b/workflow/engine/classes/model/om/BaseListCanceled.php @@ -33,6 +33,12 @@ abstract class BaseListCanceled extends BaseObject implements Persistent */ protected $app_uid = ''; + /** + * The value for the del_index field. + * @var int + */ + protected $del_index = 0; + /** * The value for the usr_uid field. * @var string @@ -81,12 +87,6 @@ abstract class BaseListCanceled extends BaseObject implements Persistent */ protected $app_canceled_date; - /** - * The value for the del_index field. - * @var int - */ - protected $del_index = 0; - /** * The value for the del_previous_usr_uid field. * @var string @@ -178,6 +178,17 @@ abstract class BaseListCanceled extends BaseObject implements Persistent return $this->app_uid; } + /** + * Get the [del_index] column value. + * + * @return int + */ + public function getDelIndex() + { + + return $this->del_index; + } + /** * Get the [usr_uid] column value. * @@ -287,17 +298,6 @@ abstract class BaseListCanceled extends BaseObject implements Persistent } } - /** - * Get the [del_index] column value. - * - * @return int - */ - public function getDelIndex() - { - - return $this->del_index; - } - /** * Get the [del_previous_usr_uid] column value. * @@ -504,6 +504,28 @@ abstract class BaseListCanceled extends BaseObject implements Persistent } // setAppUid() + /** + * Set the value of [del_index] column. + * + * @param int $v new value + * @return void + */ + public function setDelIndex($v) + { + + // Since the native PHP type for this column is integer, + // we will cast the input value to an int (if it is not). + if ($v !== null && !is_int($v) && is_numeric($v)) { + $v = (int) $v; + } + + if ($this->del_index !== $v || $v === 0) { + $this->del_index = $v; + $this->modifiedColumns[] = ListCanceledPeer::DEL_INDEX; + } + + } // setDelIndex() + /** * Set the value of [usr_uid] column. * @@ -687,28 +709,6 @@ abstract class BaseListCanceled extends BaseObject implements Persistent } // setAppCanceledDate() - /** - * Set the value of [del_index] column. - * - * @param int $v new value - * @return void - */ - public function setDelIndex($v) - { - - // Since the native PHP type for this column is integer, - // we will cast the input value to an int (if it is not). - if ($v !== null && !is_int($v) && is_numeric($v)) { - $v = (int) $v; - } - - if ($this->del_index !== $v || $v === 0) { - $this->del_index = $v; - $this->modifiedColumns[] = ListCanceledPeer::DEL_INDEX; - } - - } // setDelIndex() - /** * Set the value of [del_previous_usr_uid] column. * @@ -991,23 +991,23 @@ abstract class BaseListCanceled extends BaseObject implements Persistent $this->app_uid = $rs->getString($startcol + 0); - $this->usr_uid = $rs->getString($startcol + 1); + $this->del_index = $rs->getInt($startcol + 1); - $this->tas_uid = $rs->getString($startcol + 2); + $this->usr_uid = $rs->getString($startcol + 2); - $this->pro_uid = $rs->getString($startcol + 3); + $this->tas_uid = $rs->getString($startcol + 3); - $this->app_number = $rs->getInt($startcol + 4); + $this->pro_uid = $rs->getString($startcol + 4); - $this->app_title = $rs->getString($startcol + 5); + $this->app_number = $rs->getInt($startcol + 5); - $this->app_pro_title = $rs->getString($startcol + 6); + $this->app_title = $rs->getString($startcol + 6); - $this->app_tas_title = $rs->getString($startcol + 7); + $this->app_pro_title = $rs->getString($startcol + 7); - $this->app_canceled_date = $rs->getTimestamp($startcol + 8, null); + $this->app_tas_title = $rs->getString($startcol + 8); - $this->del_index = $rs->getInt($startcol + 9); + $this->app_canceled_date = $rs->getTimestamp($startcol + 9, null); $this->del_previous_usr_uid = $rs->getString($startcol + 10); @@ -1244,31 +1244,31 @@ abstract class BaseListCanceled extends BaseObject implements Persistent return $this->getAppUid(); break; case 1: - return $this->getUsrUid(); + return $this->getDelIndex(); break; case 2: - return $this->getTasUid(); + return $this->getUsrUid(); break; case 3: - return $this->getProUid(); + return $this->getTasUid(); break; case 4: - return $this->getAppNumber(); + return $this->getProUid(); break; case 5: - return $this->getAppTitle(); + return $this->getAppNumber(); break; case 6: - return $this->getAppProTitle(); + return $this->getAppTitle(); break; case 7: - return $this->getAppTasTitle(); + return $this->getAppProTitle(); break; case 8: - return $this->getAppCanceledDate(); + return $this->getAppTasTitle(); break; case 9: - return $this->getDelIndex(); + return $this->getAppCanceledDate(); break; case 10: return $this->getDelPreviousUsrUid(); @@ -1324,15 +1324,15 @@ abstract class BaseListCanceled extends BaseObject implements Persistent $keys = ListCanceledPeer::getFieldNames($keyType); $result = array( $keys[0] => $this->getAppUid(), - $keys[1] => $this->getUsrUid(), - $keys[2] => $this->getTasUid(), - $keys[3] => $this->getProUid(), - $keys[4] => $this->getAppNumber(), - $keys[5] => $this->getAppTitle(), - $keys[6] => $this->getAppProTitle(), - $keys[7] => $this->getAppTasTitle(), - $keys[8] => $this->getAppCanceledDate(), - $keys[9] => $this->getDelIndex(), + $keys[1] => $this->getDelIndex(), + $keys[2] => $this->getUsrUid(), + $keys[3] => $this->getTasUid(), + $keys[4] => $this->getProUid(), + $keys[5] => $this->getAppNumber(), + $keys[6] => $this->getAppTitle(), + $keys[7] => $this->getAppProTitle(), + $keys[8] => $this->getAppTasTitle(), + $keys[9] => $this->getAppCanceledDate(), $keys[10] => $this->getDelPreviousUsrUid(), $keys[11] => $this->getDelCurrentUsrUsername(), $keys[12] => $this->getDelCurrentUsrFirstname(), @@ -1379,31 +1379,31 @@ abstract class BaseListCanceled extends BaseObject implements Persistent $this->setAppUid($value); break; case 1: - $this->setUsrUid($value); + $this->setDelIndex($value); break; case 2: - $this->setTasUid($value); + $this->setUsrUid($value); break; case 3: - $this->setProUid($value); + $this->setTasUid($value); break; case 4: - $this->setAppNumber($value); + $this->setProUid($value); break; case 5: - $this->setAppTitle($value); + $this->setAppNumber($value); break; case 6: - $this->setAppProTitle($value); + $this->setAppTitle($value); break; case 7: - $this->setAppTasTitle($value); + $this->setAppProTitle($value); break; case 8: - $this->setAppCanceledDate($value); + $this->setAppTasTitle($value); break; case 9: - $this->setDelIndex($value); + $this->setAppCanceledDate($value); break; case 10: $this->setDelPreviousUsrUid($value); @@ -1466,39 +1466,39 @@ abstract class BaseListCanceled extends BaseObject implements Persistent } if (array_key_exists($keys[1], $arr)) { - $this->setUsrUid($arr[$keys[1]]); + $this->setDelIndex($arr[$keys[1]]); } if (array_key_exists($keys[2], $arr)) { - $this->setTasUid($arr[$keys[2]]); + $this->setUsrUid($arr[$keys[2]]); } if (array_key_exists($keys[3], $arr)) { - $this->setProUid($arr[$keys[3]]); + $this->setTasUid($arr[$keys[3]]); } if (array_key_exists($keys[4], $arr)) { - $this->setAppNumber($arr[$keys[4]]); + $this->setProUid($arr[$keys[4]]); } if (array_key_exists($keys[5], $arr)) { - $this->setAppTitle($arr[$keys[5]]); + $this->setAppNumber($arr[$keys[5]]); } if (array_key_exists($keys[6], $arr)) { - $this->setAppProTitle($arr[$keys[6]]); + $this->setAppTitle($arr[$keys[6]]); } if (array_key_exists($keys[7], $arr)) { - $this->setAppTasTitle($arr[$keys[7]]); + $this->setAppProTitle($arr[$keys[7]]); } if (array_key_exists($keys[8], $arr)) { - $this->setAppCanceledDate($arr[$keys[8]]); + $this->setAppTasTitle($arr[$keys[8]]); } if (array_key_exists($keys[9], $arr)) { - $this->setDelIndex($arr[$keys[9]]); + $this->setAppCanceledDate($arr[$keys[9]]); } if (array_key_exists($keys[10], $arr)) { @@ -1560,6 +1560,10 @@ abstract class BaseListCanceled extends BaseObject implements Persistent $criteria->add(ListCanceledPeer::APP_UID, $this->app_uid); } + if ($this->isColumnModified(ListCanceledPeer::DEL_INDEX)) { + $criteria->add(ListCanceledPeer::DEL_INDEX, $this->del_index); + } + if ($this->isColumnModified(ListCanceledPeer::USR_UID)) { $criteria->add(ListCanceledPeer::USR_UID, $this->usr_uid); } @@ -1592,10 +1596,6 @@ abstract class BaseListCanceled extends BaseObject implements Persistent $criteria->add(ListCanceledPeer::APP_CANCELED_DATE, $this->app_canceled_date); } - if ($this->isColumnModified(ListCanceledPeer::DEL_INDEX)) { - $criteria->add(ListCanceledPeer::DEL_INDEX, $this->del_index); - } - if ($this->isColumnModified(ListCanceledPeer::DEL_PREVIOUS_USR_UID)) { $criteria->add(ListCanceledPeer::DEL_PREVIOUS_USR_UID, $this->del_previous_usr_uid); } @@ -1657,28 +1657,40 @@ abstract class BaseListCanceled extends BaseObject implements Persistent $criteria = new Criteria(ListCanceledPeer::DATABASE_NAME); $criteria->add(ListCanceledPeer::APP_UID, $this->app_uid); + $criteria->add(ListCanceledPeer::DEL_INDEX, $this->del_index); return $criteria; } /** - * Returns the primary key for this object (row). - * @return string + * Returns the composite primary key for this object. + * The array elements will be in same order as specified in XML. + * @return array */ public function getPrimaryKey() { - return $this->getAppUid(); + $pks = array(); + + $pks[0] = $this->getAppUid(); + + $pks[1] = $this->getDelIndex(); + + return $pks; } /** - * Generic method to set the primary key (app_uid column). + * Set the [composite] primary key. * - * @param string $key Primary key. + * @param array $keys The elements of the composite key (order must match the order in XML file). * @return void */ - public function setPrimaryKey($key) + public function setPrimaryKey($keys) { - $this->setAppUid($key); + + $this->setAppUid($keys[0]); + + $this->setDelIndex($keys[1]); + } /** @@ -1710,8 +1722,6 @@ abstract class BaseListCanceled extends BaseObject implements Persistent $copyObj->setAppCanceledDate($this->app_canceled_date); - $copyObj->setDelIndex($this->del_index); - $copyObj->setDelPreviousUsrUid($this->del_previous_usr_uid); $copyObj->setDelCurrentUsrUsername($this->del_current_usr_username); @@ -1739,6 +1749,8 @@ abstract class BaseListCanceled extends BaseObject implements Persistent $copyObj->setAppUid(''); // this is a pkey column, so set to default value + $copyObj->setDelIndex('0'); // this is a pkey column, so set to default value + } /** diff --git a/workflow/engine/classes/model/om/BaseListCanceledPeer.php b/workflow/engine/classes/model/om/BaseListCanceledPeer.php index 777713c3a..aeed53bad 100644 --- a/workflow/engine/classes/model/om/BaseListCanceledPeer.php +++ b/workflow/engine/classes/model/om/BaseListCanceledPeer.php @@ -34,6 +34,9 @@ abstract class BaseListCanceledPeer /** the column name for the APP_UID field */ const APP_UID = 'LIST_CANCELED.APP_UID'; + /** the column name for the DEL_INDEX field */ + const DEL_INDEX = 'LIST_CANCELED.DEL_INDEX'; + /** the column name for the USR_UID field */ const USR_UID = 'LIST_CANCELED.USR_UID'; @@ -58,9 +61,6 @@ abstract class BaseListCanceledPeer /** the column name for the APP_CANCELED_DATE field */ const APP_CANCELED_DATE = 'LIST_CANCELED.APP_CANCELED_DATE'; - /** the column name for the DEL_INDEX field */ - const DEL_INDEX = 'LIST_CANCELED.DEL_INDEX'; - /** the column name for the DEL_PREVIOUS_USR_UID field */ const DEL_PREVIOUS_USR_UID = 'LIST_CANCELED.DEL_PREVIOUS_USR_UID'; @@ -105,9 +105,9 @@ abstract class BaseListCanceledPeer * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ private static $fieldNames = array ( - BasePeer::TYPE_PHPNAME => array ('AppUid', 'UsrUid', 'TasUid', 'ProUid', 'AppNumber', 'AppTitle', 'AppProTitle', 'AppTasTitle', 'AppCanceledDate', 'DelIndex', 'DelPreviousUsrUid', 'DelCurrentUsrUsername', 'DelCurrentUsrFirstname', 'DelCurrentUsrLastname', 'DelDelegateDate', 'DelInitDate', 'DelDueDate', 'DelPriority', 'ProId', 'UsrId', 'TasId', ), - BasePeer::TYPE_COLNAME => array (ListCanceledPeer::APP_UID, ListCanceledPeer::USR_UID, ListCanceledPeer::TAS_UID, ListCanceledPeer::PRO_UID, ListCanceledPeer::APP_NUMBER, ListCanceledPeer::APP_TITLE, ListCanceledPeer::APP_PRO_TITLE, ListCanceledPeer::APP_TAS_TITLE, ListCanceledPeer::APP_CANCELED_DATE, ListCanceledPeer::DEL_INDEX, ListCanceledPeer::DEL_PREVIOUS_USR_UID, ListCanceledPeer::DEL_CURRENT_USR_USERNAME, ListCanceledPeer::DEL_CURRENT_USR_FIRSTNAME, ListCanceledPeer::DEL_CURRENT_USR_LASTNAME, ListCanceledPeer::DEL_DELEGATE_DATE, ListCanceledPeer::DEL_INIT_DATE, ListCanceledPeer::DEL_DUE_DATE, ListCanceledPeer::DEL_PRIORITY, ListCanceledPeer::PRO_ID, ListCanceledPeer::USR_ID, ListCanceledPeer::TAS_ID, ), - BasePeer::TYPE_FIELDNAME => array ('APP_UID', 'USR_UID', 'TAS_UID', 'PRO_UID', 'APP_NUMBER', 'APP_TITLE', 'APP_PRO_TITLE', 'APP_TAS_TITLE', 'APP_CANCELED_DATE', 'DEL_INDEX', 'DEL_PREVIOUS_USR_UID', 'DEL_CURRENT_USR_USERNAME', 'DEL_CURRENT_USR_FIRSTNAME', 'DEL_CURRENT_USR_LASTNAME', 'DEL_DELEGATE_DATE', 'DEL_INIT_DATE', 'DEL_DUE_DATE', 'DEL_PRIORITY', 'PRO_ID', 'USR_ID', 'TAS_ID', ), + BasePeer::TYPE_PHPNAME => array ('AppUid', 'DelIndex', 'UsrUid', 'TasUid', 'ProUid', 'AppNumber', 'AppTitle', 'AppProTitle', 'AppTasTitle', 'AppCanceledDate', 'DelPreviousUsrUid', 'DelCurrentUsrUsername', 'DelCurrentUsrFirstname', 'DelCurrentUsrLastname', 'DelDelegateDate', 'DelInitDate', 'DelDueDate', 'DelPriority', 'ProId', 'UsrId', 'TasId', ), + BasePeer::TYPE_COLNAME => array (ListCanceledPeer::APP_UID, ListCanceledPeer::DEL_INDEX, ListCanceledPeer::USR_UID, ListCanceledPeer::TAS_UID, ListCanceledPeer::PRO_UID, ListCanceledPeer::APP_NUMBER, ListCanceledPeer::APP_TITLE, ListCanceledPeer::APP_PRO_TITLE, ListCanceledPeer::APP_TAS_TITLE, ListCanceledPeer::APP_CANCELED_DATE, ListCanceledPeer::DEL_PREVIOUS_USR_UID, ListCanceledPeer::DEL_CURRENT_USR_USERNAME, ListCanceledPeer::DEL_CURRENT_USR_FIRSTNAME, ListCanceledPeer::DEL_CURRENT_USR_LASTNAME, ListCanceledPeer::DEL_DELEGATE_DATE, ListCanceledPeer::DEL_INIT_DATE, ListCanceledPeer::DEL_DUE_DATE, ListCanceledPeer::DEL_PRIORITY, ListCanceledPeer::PRO_ID, ListCanceledPeer::USR_ID, ListCanceledPeer::TAS_ID, ), + BasePeer::TYPE_FIELDNAME => array ('APP_UID', 'DEL_INDEX', 'USR_UID', 'TAS_UID', 'PRO_UID', 'APP_NUMBER', 'APP_TITLE', 'APP_PRO_TITLE', 'APP_TAS_TITLE', 'APP_CANCELED_DATE', 'DEL_PREVIOUS_USR_UID', 'DEL_CURRENT_USR_USERNAME', 'DEL_CURRENT_USR_FIRSTNAME', 'DEL_CURRENT_USR_LASTNAME', 'DEL_DELEGATE_DATE', 'DEL_INIT_DATE', 'DEL_DUE_DATE', 'DEL_PRIORITY', 'PRO_ID', 'USR_ID', 'TAS_ID', ), BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, ) ); @@ -118,9 +118,9 @@ abstract class BaseListCanceledPeer * e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 */ private static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('AppUid' => 0, 'UsrUid' => 1, 'TasUid' => 2, 'ProUid' => 3, 'AppNumber' => 4, 'AppTitle' => 5, 'AppProTitle' => 6, 'AppTasTitle' => 7, 'AppCanceledDate' => 8, 'DelIndex' => 9, 'DelPreviousUsrUid' => 10, 'DelCurrentUsrUsername' => 11, 'DelCurrentUsrFirstname' => 12, 'DelCurrentUsrLastname' => 13, 'DelDelegateDate' => 14, 'DelInitDate' => 15, 'DelDueDate' => 16, 'DelPriority' => 17, 'ProId' => 18, 'UsrId' => 19, 'TasId' => 20, ), - BasePeer::TYPE_COLNAME => array (ListCanceledPeer::APP_UID => 0, ListCanceledPeer::USR_UID => 1, ListCanceledPeer::TAS_UID => 2, ListCanceledPeer::PRO_UID => 3, ListCanceledPeer::APP_NUMBER => 4, ListCanceledPeer::APP_TITLE => 5, ListCanceledPeer::APP_PRO_TITLE => 6, ListCanceledPeer::APP_TAS_TITLE => 7, ListCanceledPeer::APP_CANCELED_DATE => 8, ListCanceledPeer::DEL_INDEX => 9, ListCanceledPeer::DEL_PREVIOUS_USR_UID => 10, ListCanceledPeer::DEL_CURRENT_USR_USERNAME => 11, ListCanceledPeer::DEL_CURRENT_USR_FIRSTNAME => 12, ListCanceledPeer::DEL_CURRENT_USR_LASTNAME => 13, ListCanceledPeer::DEL_DELEGATE_DATE => 14, ListCanceledPeer::DEL_INIT_DATE => 15, ListCanceledPeer::DEL_DUE_DATE => 16, ListCanceledPeer::DEL_PRIORITY => 17, ListCanceledPeer::PRO_ID => 18, ListCanceledPeer::USR_ID => 19, ListCanceledPeer::TAS_ID => 20, ), - BasePeer::TYPE_FIELDNAME => array ('APP_UID' => 0, 'USR_UID' => 1, 'TAS_UID' => 2, 'PRO_UID' => 3, 'APP_NUMBER' => 4, 'APP_TITLE' => 5, 'APP_PRO_TITLE' => 6, 'APP_TAS_TITLE' => 7, 'APP_CANCELED_DATE' => 8, 'DEL_INDEX' => 9, 'DEL_PREVIOUS_USR_UID' => 10, 'DEL_CURRENT_USR_USERNAME' => 11, 'DEL_CURRENT_USR_FIRSTNAME' => 12, 'DEL_CURRENT_USR_LASTNAME' => 13, 'DEL_DELEGATE_DATE' => 14, 'DEL_INIT_DATE' => 15, 'DEL_DUE_DATE' => 16, 'DEL_PRIORITY' => 17, 'PRO_ID' => 18, 'USR_ID' => 19, 'TAS_ID' => 20, ), + BasePeer::TYPE_PHPNAME => array ('AppUid' => 0, 'DelIndex' => 1, 'UsrUid' => 2, 'TasUid' => 3, 'ProUid' => 4, 'AppNumber' => 5, 'AppTitle' => 6, 'AppProTitle' => 7, 'AppTasTitle' => 8, 'AppCanceledDate' => 9, 'DelPreviousUsrUid' => 10, 'DelCurrentUsrUsername' => 11, 'DelCurrentUsrFirstname' => 12, 'DelCurrentUsrLastname' => 13, 'DelDelegateDate' => 14, 'DelInitDate' => 15, 'DelDueDate' => 16, 'DelPriority' => 17, 'ProId' => 18, 'UsrId' => 19, 'TasId' => 20, ), + BasePeer::TYPE_COLNAME => array (ListCanceledPeer::APP_UID => 0, ListCanceledPeer::DEL_INDEX => 1, ListCanceledPeer::USR_UID => 2, ListCanceledPeer::TAS_UID => 3, ListCanceledPeer::PRO_UID => 4, ListCanceledPeer::APP_NUMBER => 5, ListCanceledPeer::APP_TITLE => 6, ListCanceledPeer::APP_PRO_TITLE => 7, ListCanceledPeer::APP_TAS_TITLE => 8, ListCanceledPeer::APP_CANCELED_DATE => 9, ListCanceledPeer::DEL_PREVIOUS_USR_UID => 10, ListCanceledPeer::DEL_CURRENT_USR_USERNAME => 11, ListCanceledPeer::DEL_CURRENT_USR_FIRSTNAME => 12, ListCanceledPeer::DEL_CURRENT_USR_LASTNAME => 13, ListCanceledPeer::DEL_DELEGATE_DATE => 14, ListCanceledPeer::DEL_INIT_DATE => 15, ListCanceledPeer::DEL_DUE_DATE => 16, ListCanceledPeer::DEL_PRIORITY => 17, ListCanceledPeer::PRO_ID => 18, ListCanceledPeer::USR_ID => 19, ListCanceledPeer::TAS_ID => 20, ), + BasePeer::TYPE_FIELDNAME => array ('APP_UID' => 0, 'DEL_INDEX' => 1, 'USR_UID' => 2, 'TAS_UID' => 3, 'PRO_UID' => 4, 'APP_NUMBER' => 5, 'APP_TITLE' => 6, 'APP_PRO_TITLE' => 7, 'APP_TAS_TITLE' => 8, 'APP_CANCELED_DATE' => 9, 'DEL_PREVIOUS_USR_UID' => 10, 'DEL_CURRENT_USR_USERNAME' => 11, 'DEL_CURRENT_USR_FIRSTNAME' => 12, 'DEL_CURRENT_USR_LASTNAME' => 13, 'DEL_DELEGATE_DATE' => 14, 'DEL_INIT_DATE' => 15, 'DEL_DUE_DATE' => 16, 'DEL_PRIORITY' => 17, 'PRO_ID' => 18, 'USR_ID' => 19, 'TAS_ID' => 20, ), BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, ) ); @@ -224,6 +224,8 @@ abstract class BaseListCanceledPeer $criteria->addSelectColumn(ListCanceledPeer::APP_UID); + $criteria->addSelectColumn(ListCanceledPeer::DEL_INDEX); + $criteria->addSelectColumn(ListCanceledPeer::USR_UID); $criteria->addSelectColumn(ListCanceledPeer::TAS_UID); @@ -240,8 +242,6 @@ abstract class BaseListCanceledPeer $criteria->addSelectColumn(ListCanceledPeer::APP_CANCELED_DATE); - $criteria->addSelectColumn(ListCanceledPeer::DEL_INDEX); - $criteria->addSelectColumn(ListCanceledPeer::DEL_PREVIOUS_USR_UID); $criteria->addSelectColumn(ListCanceledPeer::DEL_CURRENT_USR_USERNAME); @@ -479,6 +479,9 @@ abstract class BaseListCanceledPeer $comparison = $criteria->getComparison(ListCanceledPeer::APP_UID); $selectCriteria->add(ListCanceledPeer::APP_UID, $criteria->remove(ListCanceledPeer::APP_UID), $comparison); + $comparison = $criteria->getComparison(ListCanceledPeer::DEL_INDEX); + $selectCriteria->add(ListCanceledPeer::DEL_INDEX, $criteria->remove(ListCanceledPeer::DEL_INDEX), $comparison); + } else { $criteria = $values->buildCriteria(); // gets full criteria $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) @@ -540,7 +543,22 @@ abstract class BaseListCanceledPeer } else { // it must be the primary key $criteria = new Criteria(self::DATABASE_NAME); - $criteria->add(ListCanceledPeer::APP_UID, (array) $values, Criteria::IN); + // primary key is composite; we therefore, expect + // the primary key passed to be an array of pkey + // values + if (count($values) == count($values, COUNT_RECURSIVE)) { + // array is not multi-dimensional + $values = array($values); + } + $vals = array(); + foreach ($values as $value) { + + $vals[0][] = $value[0]; + $vals[1][] = $value[1]; + } + + $criteria->add(ListCanceledPeer::APP_UID, $vals[0], Criteria::IN); + $criteria->add(ListCanceledPeer::DEL_INDEX, $vals[1], Criteria::IN); } // Set the correct dbName @@ -600,51 +618,23 @@ abstract class BaseListCanceledPeer } /** - * Retrieve a single object by pkey. - * - * @param mixed $pk the primary key. - * @param Connection $con the connection to use + * Retrieve object using using composite pkey values. + * @param string $app_uid + * @param int $del_index + * @param Connection $con * @return ListCanceled */ - public static function retrieveByPK($pk, $con = null) + public static function retrieveByPK($app_uid, $del_index, $con = null) { if ($con === null) { $con = Propel::getConnection(self::DATABASE_NAME); } - - $criteria = new Criteria(ListCanceledPeer::DATABASE_NAME); - - $criteria->add(ListCanceledPeer::APP_UID, $pk); - - + $criteria = new Criteria(); + $criteria->add(ListCanceledPeer::APP_UID, $app_uid); + $criteria->add(ListCanceledPeer::DEL_INDEX, $del_index); $v = ListCanceledPeer::doSelect($criteria, $con); - return !empty($v) > 0 ? $v[0] : null; - } - - /** - * Retrieve multiple objects by pkey. - * - * @param array $pks List of primary keys - * @param Connection $con the connection to use - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function retrieveByPKs($pks, $con = null) - { - if ($con === null) { - $con = Propel::getConnection(self::DATABASE_NAME); - } - - $objs = null; - if (empty($pks)) { - $objs = array(); - } else { - $criteria = new Criteria(); - $criteria->add(ListCanceledPeer::APP_UID, $pks, Criteria::IN); - $objs = ListCanceledPeer::doSelect($criteria, $con); - } - return $objs; + return !empty($v) ? $v[0] : null; } } diff --git a/workflow/engine/config/schema.xml b/workflow/engine/config/schema.xml index 94ba93a4b..58631dda1 100644 --- a/workflow/engine/config/schema.xml +++ b/workflow/engine/config/schema.xml @@ -4621,6 +4621,7 @@ + @@ -4629,7 +4630,6 @@ - diff --git a/workflow/engine/content/translations/english/processmaker.en.po b/workflow/engine/content/translations/english/processmaker.en.po index 062c0aed6..7051b76ac 100644 --- a/workflow/engine/content/translations/english/processmaker.en.po +++ b/workflow/engine/content/translations/english/processmaker.en.po @@ -9929,6 +9929,18 @@ msgstr "Insufficient privileges to execute this function" msgid "INT" msgstr "INT" +# TRANSLATION +# LABEL/ID_INTERMEDIATE_CATCH_MESSAGE_EVENT +#: LABEL/ID_INTERMEDIATE_CATCH_MESSAGE_EVENT +msgid "Untitled - Intermediate Send Message Event" +msgstr "Untitled - Intermediate Send Message Event" + +# TRANSLATION +# LABEL/ID_INTERMEDIATE_CATCH_TIMER_EVENT +#: LABEL/ID_INTERMEDIATE_CATCH_TIMER_EVENT +msgid "Untitled - Intermediate Timer Event" +msgstr "Untitled - Intermediate Timer Event" + # TRANSLATION # LABEL/ID_INTERMEDIATE_MESSAGE_EVENT #: LABEL/ID_INTERMEDIATE_MESSAGE_EVENT @@ -9953,6 +9965,18 @@ msgstr "Intermediate Timer Event (Multiple Event)" msgid "[LABEL/ID_INTERMEDIATE_TIMER_EVENTS] Intermediate Timer Event (Multiple Event)" msgstr "Intermediate Timer Event (Multiple Event)" +# TRANSLATION +# LABEL/ID_INTERMEDIATE_THROW_EMAIL_EVENT +#: LABEL/ID_INTERMEDIATE_THROW_EMAIL_EVENT +msgid "Untitled - Intermediate Email Event" +msgstr "Untitled - Intermediate Email Event" + +# TRANSLATION +# LABEL/ID_INTERMEDIATE_THROW_MESSAGE_EVENT +#: LABEL/ID_INTERMEDIATE_THROW_MESSAGE_EVENT +msgid "Untitled - Intermediate Receive Message Event" +msgstr "Untitled - Intermediate Receive Message Event" + # TRANSLATION # LABEL/ID_INTERNATIONAL #: LABEL/ID_INTERNATIONAL diff --git a/workflow/engine/controllers/InstallerModule.php b/workflow/engine/controllers/InstallerModule.php index 509e9382a..043dc7252 100644 --- a/workflow/engine/controllers/InstallerModule.php +++ b/workflow/engine/controllers/InstallerModule.php @@ -206,7 +206,7 @@ class InstallerModule extends Controller $info->memory = new stdclass(); $info->php->version = $phpVer; - $info->php->result = version_compare($phpVer, '5.4', '>='); + $info->php->result = version_compare(phpversion(), '5.6', '>='); // MYSQL info and verification $info->mysql->result = false; diff --git a/workflow/engine/controllers/pmTablesProxy.php b/workflow/engine/controllers/pmTablesProxy.php index a0d1582fa..d9a802283 100644 --- a/workflow/engine/controllers/pmTablesProxy.php +++ b/workflow/engine/controllers/pmTablesProxy.php @@ -910,108 +910,103 @@ class pmTablesProxy extends HttpProxyController /** * Export PM tables - * - * @author : Erik Amaru Ortiz + * + * @param object $httpData + * @return object */ - public function export ($httpData) + public function export($httpData) { - require_once 'classes/model/AdditionalTables.php'; - $at = new AdditionalTables(); - $tablesToExport = G::json_decode( stripslashes( $httpData->rows ) ); + $additionalTables = new AdditionalTables(); + $tablesToExport = G::json_decode(stripslashes($httpData->rows)); try { $result = new stdClass(); - $net = new Net( G::getIpAddress() ); - - $META = " \n-----== ProcessMaker Open Source Private Tables ==-----\n" . " @Ver: 1.0 Oct-2009\n" . " @Processmaker version: " . System::getVersion() . "\n" . " -------------------------------------------------------\n" . " @Export Date: " . date( "l jS \of F Y h:i:s A" ) . "\n" . " @Server address: " . getenv( 'SERVER_NAME' ) . " (" . getenv( 'SERVER_ADDR' ) . ")\n" . " @Client address: " . $net->hostname . "\n" . " @Workspace: " . config("system.workspace") . "\n" . " @Export trace back:\n\n"; - - $EXPORT_TRACEBACK = Array (); - $c = 0; + $net = new Net(G::getIpAddress()); + $metaInfo = " \n-----== ProcessMaker Open Source Private Tables ==-----\n" . " @Ver: 1.0 Oct-2009\n" . " @Processmaker version: " . System::getVersion() . "\n" . " -------------------------------------------------------\n" . " @Export Date: " . date("l jS \of F Y h:i:s A") . "\n" . " @Server address: " . getenv('SERVER_NAME') . " (" . getenv('SERVER_ADDR') . ")\n" . " @Client address: " . $net->hostname . "\n" . " @Workspace: " . config("system.workspace") . "\n" . " @Export trace back:\n\n"; + $exportTraceback = []; + foreach ($tablesToExport as $table) { - $tableRecord = $at->load( $table->ADD_TAB_UID ); - $tableData = $at->getAllData( $table->ADD_TAB_UID, null, null, false ); - $table->ADD_TAB_NAME = $tableRecord['ADD_TAB_NAME']; - $rows = $tableData['rows']; - $count = $tableData['count']; + if ($table->_DATA) { + $tableRecord = $additionalTables->load($table->ADD_TAB_UID); + $tableData = $additionalTables->getAllData($table->ADD_TAB_UID, null, null, false); + $table->ADD_TAB_NAME = $tableRecord['ADD_TAB_NAME']; - array_push( $EXPORT_TRACEBACK, Array ('uid' => $table->ADD_TAB_UID,'name' => $table->ADD_TAB_NAME,'num_regs' => $tableData['count'],'schema' => $table->_SCHEMA ? 'yes' : 'no','data' => $table->_DATA ? 'yes' : 'no' - ) ); + array_push($exportTraceback, [ + 'uid' => $table->ADD_TAB_UID, + 'name' => $table->ADD_TAB_NAME, + 'num_regs' => $tableData['count'], + 'schema' => $table->_SCHEMA ? 'yes' : 'no', + 'data' => $table->_DATA ? 'yes' : 'no' + ]); + } } - $sTrace = "TABLE UID TABLE NAME\tREGS\tSCHEMA\tDATA\n"; - - foreach ($EXPORT_TRACEBACK as $row) { - $sTrace .= "{$row['uid']}\t{$row['name']}\t\t{$row['num_regs']}\t{$row['schema']}\t{$row['data']}\n"; + $trace = "TABLE UID TABLE NAME\tREGS\tSCHEMA\tDATA\n"; + foreach ($exportTraceback as $row) { + $trace .= "{$row['uid']}\t{$row['name']}\t\t{$row['num_regs']}\t{$row['schema']}\t{$row['data']}\n"; } + $metaInfo .= $trace; - $META .= $sTrace; - - ///////////////EXPORT PROCESS - $PUBLIC_ROOT_PATH = PATH_DATA . 'sites' . PATH_SEP . config("system.workspace") . PATH_SEP . 'public' . PATH_SEP; - - $filenameOnly = strtolower( 'SYS-' . config("system.workspace") . "_" . date( "Y-m-d" ) . '_' . date( "Hi" ) . ".pmt" ); - - $filename = $PUBLIC_ROOT_PATH . $filenameOnly; - $fp = fopen( $filename, "wb" ); - + //Export table + $publicPath = PATH_DATA . 'sites' . PATH_SEP . config("system.workspace") . PATH_SEP . 'public' . PATH_SEP; + $filenameOnly = strtolower('SYS-' . config("system.workspace") . "_" . date("Y-m-d") . '_' . date("Hi") . ".pmt"); + $filename = $publicPath . $filenameOnly; + $fp = fopen($filename, "wb"); $bytesSaved = 0; $bufferType = '@META'; - $fsData = sprintf( "%09d", strlen( $META ) ); - $fsbufferType = sprintf( "%09d", strlen( $bufferType ) ); - $bytesSaved += fwrite( $fp, $fsbufferType ); //writing the size of $oData - $bytesSaved += fwrite( $fp, $bufferType ); //writing the $oData - $bytesSaved += fwrite( $fp, $fsData ); //writing the size of $oData - $bytesSaved += fwrite( $fp, $META ); //writing the $oData + $fsData = sprintf("%09d", strlen($metaInfo)); + $fsbufferType = sprintf("%09d", strlen($bufferType)); + $bytesSaved += fwrite($fp, $fsbufferType); //writing the size of $oData + $bytesSaved += fwrite($fp, $bufferType); //writing the $oData + $bytesSaved += fwrite($fp, $fsData); //writing the size of $oData + $bytesSaved += fwrite($fp, $metaInfo); //writing the $oData foreach ($tablesToExport as $table) { if ($table->_SCHEMA) { - $oAdditionalTables = new AdditionalTables(); - $aData = $oAdditionalTables->load( $table->ADD_TAB_UID, true ); + //Export Schema + $pmTables = new AdditionalTables(); + $aData = $pmTables->load($table->ADD_TAB_UID, true); $bufferType = '@SCHEMA'; - $SDATA = serialize( $aData ); - $fsUid = sprintf( "%09d", strlen( $table->ADD_TAB_UID ) ); - $fsData = sprintf( "%09d", strlen( $SDATA ) ); - $fsbufferType = sprintf( "%09d", strlen( $bufferType ) ); - - $bytesSaved += fwrite( $fp, $fsbufferType ); //writing the size of $oData - $bytesSaved += fwrite( $fp, $bufferType ); //writing the $oData - $bytesSaved += fwrite( $fp, $fsUid ); //writing the size of xml file - $bytesSaved += fwrite( $fp, $table->ADD_TAB_UID ); //writing the xmlfile - $bytesSaved += fwrite( $fp, $fsData ); //writing the size of xml file - $bytesSaved += fwrite( $fp, $SDATA ); //writing the xmlfile + $dataTable = serialize($aData); + $fsUid = sprintf("%09d", strlen($table->ADD_TAB_UID)); + $fsData = sprintf("%09d", strlen($dataTable)); + $fsbufferType = sprintf("%09d", strlen($bufferType)); + $bytesSaved += fwrite($fp, $fsbufferType); //writing the size of $oData + $bytesSaved += fwrite($fp, $bufferType); //writing the $oData + $bytesSaved += fwrite($fp, $fsUid); //writing the size of xml file + $bytesSaved += fwrite($fp, $table->ADD_TAB_UID); //writing the xmlfile + $bytesSaved += fwrite($fp, $fsData); //writing the size of xml file + $bytesSaved += fwrite($fp, $dataTable); //writing the xmlfile } if ($table->_DATA) { - //export data - $oAdditionalTables = new additionalTables(); - $tableData = $oAdditionalTables->getAllData( $table->ADD_TAB_UID, null, null, false ); + //Export data + $pmTables = new additionalTables(); + $tableData = $pmTables->getAllData($table->ADD_TAB_UID, null, null, false); - $SDATA = serialize( $tableData['rows'] ); + $dataTable = serialize($tableData['rows']); $bufferType = '@DATA'; - - $fsbufferType = sprintf( "%09d", strlen( $bufferType ) ); - $fsTableName = sprintf( "%09d", strlen( $table->ADD_TAB_NAME ) ); - $fsData = sprintf( "%09d", strlen( $SDATA ) ); - - $bytesSaved += fwrite( $fp, $fsbufferType ); //writing type size - $bytesSaved += fwrite( $fp, $bufferType ); //writing type - $bytesSaved += fwrite( $fp, $fsTableName ); //writing the size of xml file - $bytesSaved += fwrite( $fp, $table->ADD_TAB_NAME ); //writing the xmlfile - $bytesSaved += fwrite( $fp, $fsData ); //writing the size of xml file - $bytesSaved += fwrite( $fp, $SDATA ); //writing the xmlfile + $fsbufferType = sprintf("%09d", strlen($bufferType)); + $fsTableName = sprintf("%09d", strlen($table->ADD_TAB_NAME)); + $fsData = sprintf("%09d", strlen($dataTable)); + $bytesSaved += fwrite($fp, $fsbufferType); //writing type size + $bytesSaved += fwrite($fp, $bufferType); //writing type + $bytesSaved += fwrite($fp, $fsTableName); //writing the size of xml file + $bytesSaved += fwrite($fp, $table->ADD_TAB_NAME); //writing the xmlfile + $bytesSaved += fwrite($fp, $fsData); //writing the size of xml file + $bytesSaved += fwrite($fp, $dataTable); //writing the xmlfile } - G::auditLog("ExportTable", $table->ADD_TAB_NAME." (".$table->ADD_TAB_UID.") "); + + G::auditLog("ExportTable", $table->ADD_TAB_NAME . " (" . $table->ADD_TAB_UID . ") "); } - fclose( $fp ); + fclose($fp); $filenameLink = "pmTables/streamExported?f=$filenameOnly"; - $size = round( ($bytesSaved / 1024), 2 ) . " Kb"; - $meta = "
" . $META . "
"; - $filename = $filenameOnly; + $size = round(($bytesSaved / 1024), 2) . " Kb"; $link = $filenameLink; $result->success = true; diff --git a/workflow/engine/data/mysql/insert.sql b/workflow/engine/data/mysql/insert.sql index 25c18def4..70c50d921 100644 --- a/workflow/engine/data/mysql/insert.sql +++ b/workflow/engine/data/mysql/insert.sql @@ -58486,10 +58486,14 @@ INSERT INTO TRANSLATION (TRN_CATEGORY,TRN_ID,TRN_LANG,TRN_VALUE,TRN_UPDATE_DATE ( 'LABEL','ID_INSTRUCTIONS_TEXT','en','To assign a case, first select the case in the list. Then enter a user name in the ''Search'' field and select a user to whom the case will be reassigned.','2014-10-21') , ( 'LABEL','ID_INSUFFICIENT_PRIVILEGES_FUNCTION','en','Insufficient privileges to execute this function','2014-01-15') , ( 'LABEL','ID_INT','en','INT','2014-01-15') , +( 'LABEL','ID_INTERMEDIATE_CATCH_MESSAGE_EVENT','en','Untitled - Intermediate Send Message Event','2018-05-23') , +( 'LABEL','ID_INTERMEDIATE_CATCH_TIMER_EVENT','en','Untitled - Intermediate Timer Event','2018-05-23') , ( 'LABEL','ID_INTERMEDIATE_MESSAGE_EVENT','en','Intermediate Message Events (Task Notifications)','2014-01-15') , ( 'LABEL','ID_INTERMEDIATE_MESSAGE_EVENTS','en','Intermediate Message Events (Task Notifications)','2014-01-15') , ( 'LABEL','ID_INTERMEDIATE_TIMER_EVENT','en','Intermediate Timer Event (Multiple Event)','2014-01-15') , ( 'LABEL','ID_INTERMEDIATE_TIMER_EVENTS','en','Intermediate Timer Event (Multiple Event)','2014-01-15') , +( 'LABEL','ID_INTERMEDIATE_THROW_EMAIL_EVENT','en','Untitled - Intermediate Email Event','2018-05-23') , +( 'LABEL','ID_INTERMEDIATE_THROW_MESSAGE_EVENT','en','Untitled - Intermediate Receive Message Event','2018-05-23') , ( 'LABEL','ID_INTERNATIONAL','en','International','2014-01-15') , ( 'LABEL','ID_INVALID_APPLICATION_ID_MSG','en','An invalid application ID was stored for the session.
This could have happened if you opened another case in a new tab or window.
Please {0} the case.','2014-10-21') , ( 'LABEL','ID_INVALID_APPLICATION_NUMBER','en','You have set a invalid Application Number','2014-01-15') , diff --git a/workflow/engine/data/mysql/schema.sql b/workflow/engine/data/mysql/schema.sql index ef578628c..93051a2a8 100644 --- a/workflow/engine/data/mysql/schema.sql +++ b/workflow/engine/data/mysql/schema.sql @@ -2575,6 +2575,7 @@ DROP TABLE IF EXISTS `LIST_CANCELED`; CREATE TABLE `LIST_CANCELED` ( `APP_UID` VARCHAR(32) default '' NOT NULL, + `DEL_INDEX` INTEGER default 0 NOT NULL, `USR_UID` VARCHAR(32) default '' NOT NULL, `TAS_UID` VARCHAR(32) default '' NOT NULL, `PRO_UID` VARCHAR(32) default '' NOT NULL, @@ -2583,7 +2584,6 @@ CREATE TABLE `LIST_CANCELED` `APP_PRO_TITLE` MEDIUMTEXT, `APP_TAS_TITLE` MEDIUMTEXT, `APP_CANCELED_DATE` DATETIME, - `DEL_INDEX` INTEGER default 0 NOT NULL, `DEL_PREVIOUS_USR_UID` VARCHAR(32) default '', `DEL_CURRENT_USR_USERNAME` VARCHAR(100) default '', `DEL_CURRENT_USR_FIRSTNAME` VARCHAR(50) default '', @@ -2595,7 +2595,7 @@ CREATE TABLE `LIST_CANCELED` `PRO_ID` INTEGER default 0, `USR_ID` INTEGER default 0, `TAS_ID` INTEGER default 0, - PRIMARY KEY (`APP_UID`), + PRIMARY KEY (`APP_UID`,`DEL_INDEX`), KEY `INDEX_PRO_ID`(`PRO_ID`), KEY `INDEX_USR_ID`(`USR_ID`), KEY `INDEX_TAS_ID`(`TAS_ID`), diff --git a/workflow/engine/methods/appFolder/appFolderAjax.php b/workflow/engine/methods/appFolder/appFolderAjax.php index fdaabe8b4..b75f038b5 100644 --- a/workflow/engine/methods/appFolder/appFolderAjax.php +++ b/workflow/engine/methods/appFolder/appFolderAjax.php @@ -1438,88 +1438,96 @@ function checkTree($uidOriginFolder, $uidNewFolder) } } +/** + * Upload documents + * + * @return void + */ function uploadExternalDocument() { - $response['action']=$_POST['action']. " - ".$_POST['option']; - $response['error']="error"; - $response['message']="error"; - $response['success']=false; + $response = []; + $response['action'] = $_POST['action'] . " - " . $_POST['option']; + $response['error'] = "error"; + $response['message'] = "error"; + $response['success'] = false; $overwrite = (isset($_REQUEST['overwrite_files'])) ? $_REQUEST['overwrite_files'] : false; if (isset($_POST["confirm"]) && $_POST["confirm"] == "true") { if (isset($_FILES['uploadedFile'])) { - $uploadedInstances=count($_FILES['uploadedFile']['name']); - $sw_error=false; - $sw_error_exists=isset($_FILES['uploadedFile']['error']); - $emptyInstances=0; - $quequeUpload=array(); + $uploadedInstances = count($_FILES['uploadedFile']['name']); + $sw_error = false; + $sw_error_exists = isset($_FILES['uploadedFile']['error']); + $emptyInstances = 0; + $quequeUpload = []; //overwrite files if ($overwrite) { - for ($i=0; $i<$uploadedInstances; $i++) { + for ($i = 0; $i < $uploadedInstances; $i++) { overwriteFile($_REQUEST['dir'], stripslashes($_FILES['uploadedFile']['name'][$i])); } } // upload files & check for errors - for ($i=0; $i<$uploadedInstances; $i++) { + $errors = []; + for ($i = 0; $i < $uploadedInstances; $i++) { $errors[$i] = null; $tmp = $_FILES['uploadedFile']['tmp_name'][$i]; $items[$i] = stripslashes($_FILES['uploadedFile']['name'][$i]); if ($sw_error_exists) { $up_err = $_FILES['uploadedFile']['error'][$i]; } else { - $up_err=(file_exists($tmp)?0:4); + $up_err = (file_exists($tmp) ? 0 : 4); } - if ($items[$i]=="" || $up_err==4) { + if ($items[$i] == "" || $up_err == 4) { $emptyInstances++; continue; } - if ($up_err==1 || $up_err==2) { - $errors[$i]='miscfilesize'; + if ($up_err == 1 || $up_err == 2) { + $errors[$i] = 'miscfilesize'; $sw_error = true; continue; } - if ($up_err==3) { - $errors[$i]='miscfilepart'; - $sw_error=true; + if ($up_err == 3) { + $errors[$i] = 'miscfilepart'; + $sw_error = true; continue; } if (!@is_uploaded_file($tmp)) { - $errors[$i]='uploadfile'; - $sw_error=true; + $errors[$i] = 'uploadfile'; + $sw_error = true; continue; } //The uplaoded files seems to be correct and ready to be uploaded. Add to the Queque - $fileInfo=array("tempName"=>$tmp,"fileName"=>$items[$i]); - $quequeUpload[]=$fileInfo; + $fileInfo = ["tempName" => $tmp, "fileName" => $items[$i]]; + $quequeUpload[] = $fileInfo; } } elseif (isset($_POST['selitems'])) { - $response=""; - $response['msg']= "correct reload"; - $response['success']=true; + $response['msg'] = "correct reload"; + $response['success'] = true; if (isset($_REQUEST['option']) && isset($_REQUEST['copyMove'])) { if ($_REQUEST['option'] == 'directory' && $_REQUEST['copyMove'] == 'all') { - $response['action'] = $_POST['action']. " - ".$_POST['option']; - $response['error'] = "Complete"; - $response['message']= str_replace("Execute", "", $_POST['action']). " ". "Complete"; - $response['success']= 'success'; - $response['node'] = ''; - $_POST ['node'] = ""; - $newFolderUid = checkTree($_REQUEST['dir'], ($_REQUEST['new_dir'] == 'root')? '/' : $_REQUEST['new_dir']); + $response['action'] = $_POST['action'] . " - " . $_POST['option']; + $response['error'] = "Complete"; + $response['message'] = str_replace("Execute", "", $_POST['action']) . " " . "Complete"; + $response['success'] = 'success'; + $response['node'] = ''; + $_POST ['node'] = ""; + $newFolderUid = checkTree( + $_REQUEST['dir'], + ($_REQUEST['new_dir'] == 'root') ? '/' : $_REQUEST['new_dir'] + ); } - $_POST['selitems'] = array(); + $_POST['selitems'] = []; } else { - $oAppDocument = new AppDocument(); + $appDocument = new AppDocument(); if (isset($_POST['selitems']) && is_array($_POST['selitems'])) { foreach ($_POST['selitems'] as $docId) { $arrayDocId = explode('_', $docId); - $docInfo=$oAppDocument->load($arrayDocId[0]); - $docInfo['FOLDER_UID'] = $_POST['new_dir']; + $docInfo = $appDocument->load($arrayDocId[0]); + $docInfo['FOLDER_UID'] = $_POST['new_dir']; $docInfo['APP_DOC_CREATE_DATE'] = date('Y-m-d H:i:s'); - $oAppDocument->update($docInfo); + $appDocument->update($docInfo); } } } } - //G::pr($quequeUpload); //Read. Instance Document classes if (!empty($quequeUpload)) { @@ -1535,148 +1543,144 @@ function uploadExternalDocument() exit(); } } - $docUid=$_POST['docUid']; - $appDocUid=isset($_POST['APP_DOC_UID'])?$_POST['APP_DOC_UID']:""; - $docVersion=isset($_POST['docVersion'])?$_POST['docVersion']:""; - $actionType=isset($_POST['actionType'])?$_POST['actionType']:""; - $folderId=$_POST['dir']==""?"/":$_POST['dir']; - $appId=$_POST['appId']; - $docType=isset($_POST['docType'])?$_GET['docType']:"INPUT"; + $docUid = $_POST['docUid']; + $appDocUid = isset($_POST['APP_DOC_UID']) ? $_POST['APP_DOC_UID'] : ""; + $docVersion = isset($_POST['docVersion']) ? $_POST['docVersion'] : ""; + $actionType = isset($_POST['actionType']) ? $_POST['actionType'] : ""; + $folderId = $_POST['dir'] == "" ? "/" : $_POST['dir']; + $appId = $_POST['appId']; + $docType = isset($_POST['docType']) ? $_GET['docType'] : "INPUT"; //save info - $oInputDocument = new InputDocument(); + $inputDocument = new InputDocument(); if ($docUid != -1) { - $aID = $oInputDocument->load($docUid); + $aID = $inputDocument->load($docUid); } else { - $oFolder=new AppFolder(); - $folderStructure=$oFolder->getFolderStructure($folderId); - $aID=array('INP_DOC_DESTINATION_PATH'=>$folderStructure['PATH']); + $folder = new AppFolder(); + $folderStructure = $folder->getFolderStructure($folderId); + $aID = ['INP_DOC_DESTINATION_PATH' => $folderStructure['PATH']]; } - //Get the Custom Folder ID (create if necessary) - $oFolder=new AppFolder(); - if ($docUid!=-1) { - //krumo("jhl"); - $folderId=$oFolder->createFromPath($aID['INP_DOC_DESTINATION_PATH'], $appId); + $folder = new AppFolder(); + if ($docUid != -1) { + $folderId = $folder->createFromPath($aID['INP_DOC_DESTINATION_PATH'], $appId); //Tags - $fileTags=$oFolder->parseTags($aID['INP_DOC_TAGS'], $appId); + $fileTags = $folder->parseTags($aID['INP_DOC_TAGS'], $appId); } else { - $folderId=$folderId; - $fileTags="EXTERNAL"; + $folderId = $folderId; + $fileTags = "EXTERNAL"; } foreach ($quequeUpload as $key => $fileObj) { - $oAppDocument = new AppDocument(); + $appDocument = new AppDocument(); switch ($actionType) { case "R": //replace - $aFields = array( - 'APP_DOC_UID' => $appDocUid, - 'APP_UID' => $appId, - 'DOC_VERSION' => $docVersion, - 'DEL_INDEX' => 1, - 'USR_UID' => $_SESSION['USER_LOGGED'], - 'DOC_UID' => $docUid, - 'APP_DOC_TYPE' => $docType, - 'APP_DOC_CREATE_DATE' => date('Y-m-d H:i:s'), - 'APP_DOC_COMMENT' => isset($_POST['form']['APP_DOC_COMMENT']) ? + $fields = [ + 'APP_DOC_UID' => $appDocUid, + 'APP_UID' => $appId, + 'DOC_VERSION' => $docVersion, + 'DEL_INDEX' => 1, + 'USR_UID' => $_SESSION['USER_LOGGED'], + 'DOC_UID' => $docUid, + 'APP_DOC_TYPE' => $docType, + 'APP_DOC_CREATE_DATE' => date('Y-m-d H:i:s'), + 'APP_DOC_COMMENT' => isset($_POST['form']['APP_DOC_COMMENT']) ? $_POST['form']['APP_DOC_COMMENT'] : '', - 'APP_DOC_TITLE' => '', - 'APP_DOC_FILENAME' => $fileObj['fileName'], - 'FOLDER_UID' => $folderId, - 'APP_DOC_TAGS' => $fileTags - ); - $oAppDocument->update($aFields); + 'APP_DOC_TITLE' => '', + 'APP_DOC_FILENAME' => $fileObj['fileName'], + 'FOLDER_UID' => $folderId, + 'APP_DOC_TAGS' => $fileTags + ]; + $appDocument->update($fields); break; case "NV": //New Version - $aFields = array( - 'APP_DOC_UID' => $appDocUid, - 'APP_UID' => $appId, - 'DEL_INDEX' => 1, - 'USR_UID' => $_SESSION['USER_LOGGED'], - 'DOC_UID' => $docUid, - 'APP_DOC_TYPE' => $docType, - 'APP_DOC_CREATE_DATE' => date('Y-m-d H:i:s'), - 'APP_DOC_COMMENT' => isset($_POST['form']['APP_DOC_COMMENT']) ? + $fields = [ + 'APP_DOC_UID' => $appDocUid, + 'APP_UID' => $appId, + 'DEL_INDEX' => 1, + 'USR_UID' => $_SESSION['USER_LOGGED'], + 'DOC_UID' => $docUid, + 'APP_DOC_TYPE' => $docType, + 'APP_DOC_CREATE_DATE' => date('Y-m-d H:i:s'), + 'APP_DOC_COMMENT' => isset($_POST['form']['APP_DOC_COMMENT']) ? $_POST['form']['APP_DOC_COMMENT'] : '', - 'APP_DOC_TITLE' => '', - 'APP_DOC_FILENAME' => $fileObj['fileName'], - 'FOLDER_UID' => $folderId, - 'APP_DOC_TAGS' => $fileTags - ); - $oAppDocument->create($aFields); + 'APP_DOC_TITLE' => '', + 'APP_DOC_FILENAME' => $fileObj['fileName'], + 'FOLDER_UID' => $folderId, + 'APP_DOC_TAGS' => $fileTags + ]; + $appDocument->create($fields); break; default: //New - $aFields = array( - 'APP_UID' => $appId, - 'DEL_INDEX' => isset($_SESSION['INDEX'])?$_SESSION['INDEX']:1, - 'USR_UID' => $_SESSION['USER_LOGGED'], - 'DOC_UID' => $docUid, - 'APP_DOC_TYPE' => $docType, - 'APP_DOC_CREATE_DATE' => date('Y-m-d H:i:s'), - 'APP_DOC_COMMENT' => isset($_POST['form']['APP_DOC_COMMENT']) ? + $fields = [ + 'APP_UID' => $appId, + 'DEL_INDEX' => isset($_SESSION['INDEX']) ? $_SESSION['INDEX'] : 1, + 'USR_UID' => $_SESSION['USER_LOGGED'], + 'DOC_UID' => $docUid, + 'APP_DOC_TYPE' => $docType, + 'APP_DOC_CREATE_DATE' => date('Y-m-d H:i:s'), + 'APP_DOC_COMMENT' => isset($_POST['form']['APP_DOC_COMMENT']) ? $_POST['form']['APP_DOC_COMMENT'] : '', - 'APP_DOC_TITLE' => '', - 'APP_DOC_FILENAME' => $fileObj['fileName'], - 'FOLDER_UID' => $folderId, - 'APP_DOC_TAGS' => $fileTags - ); - $oAppDocument->create($aFields); + 'APP_DOC_TITLE' => '', + 'APP_DOC_FILENAME' => $fileObj['fileName'], + 'FOLDER_UID' => $folderId, + 'APP_DOC_TAGS' => $fileTags + ]; + $appDocument->create($fields); break; } - $sAppDocUid = $oAppDocument->getAppDocUid(); - $iDocVersion = $oAppDocument->getDocVersion(); + $appDocUid = $appDocument->getAppDocUid(); + $docVersion = $appDocument->getDocVersion(); - $info = pathinfo($oAppDocument->getAppDocFilename()); + $info = pathinfo($appDocument->getAppDocFilename()); $ext = (isset($info['extension']) ? $info['extension'] : ''); //save the file //if (!empty($_FILES['form'])) { //if ($_FILES['form']['error']['APP_DOC_FILENAME'] == 0) { - $sPathName = PATH_DOCUMENT . G::getPathFromUID($appId) . PATH_SEP; - $file = G::getPathFromFileUID($appId, $sAppDocUid); - $sPathName .= $file[0]; - $sFileName = $file[1] . "_" . $iDocVersion . '.' . $ext; + $pathName = PATH_DOCUMENT . G::getPathFromUID($appId) . PATH_SEP; + $file = G::getPathFromFileUID($appId, $appDocUid); + $pathName .= $file[0]; + $sFileName = $file[1] . "_" . $docVersion . '.' . $ext; - G::uploadFile($fileObj['tempName'], $sPathName, $sFileName); //upload + G::uploadFile($fileObj['tempName'], $pathName, $sFileName); //upload //Plugin Hook PM_UPLOAD_DOCUMENT for upload document - $oPluginRegistry = PluginRegistry::loadSingleton(); - if ($oPluginRegistry->existsTrigger(PM_UPLOAD_DOCUMENT) && class_exists('uploadDocumentData')) { - $oData['APP_UID'] = $appId; + $pluginRegistry = PluginRegistry::loadSingleton(); + if ($pluginRegistry->existsTrigger(PM_UPLOAD_DOCUMENT) && class_exists('uploadDocumentData')) { + $oData['APP_UID'] = $appId; $documentData = new uploadDocumentData( $appId, $_SESSION['USER_LOGGED'], - $sPathName . $sFileName, + $pathName . $sFileName, $fileObj['fileName'], - $sAppDocUid + $appDocUid ); - //$oPluginRegistry->executeTriggers (PM_UPLOAD_DOCUMENT , $documentData); - //unlink ($sPathName . $sFileName); } //end plugin if ($sw_error) { // there were errors - $err_msg=""; - for ($i=0; $i<$uploadedInstances; $i++) { - if ($errors[$i]==null) { + $err_msg = ""; + for ($i = 0; $i < $uploadedInstances; $i++) { + if ($errors[$i] == null) { continue; } - $err_msg .= $items[$i]." : ".$errors[$i]."\n"; + $err_msg .= $items[$i] . " : " . $errors[$i] . "\n"; } - $response['error']=$err_msg; - $response['message']=$err_msg; - $response['success']=false; - } elseif ($emptyInstances==$uploadedInstances) { - $response['error']= G::LoadTranslation('ID_UPLOAD_LEAST_FILE'); - $response['message']= G::LoadTranslation('ID_UPLOAD_LEAST_FILE'); - $response['success']=false; + $response['error'] = $err_msg; + $response['message'] = $err_msg; + $response['success'] = false; + } elseif ($emptyInstances == $uploadedInstances) { + $response['error'] = G::LoadTranslation('ID_UPLOAD_LEAST_FILE'); + $response['message'] = G::LoadTranslation('ID_UPLOAD_LEAST_FILE'); + $response['success'] = false; } else { - $response['error']= G::LoadTranslation('ID_UPLOAD_COMPLETE'); - $response['message']="Upload complete"; - $response['success']=true; + $response['error'] = G::LoadTranslation('ID_UPLOAD_COMPLETE'); + $response['message'] = "Upload complete"; + $response['success'] = true; } } } diff --git a/workflow/engine/methods/cases/ajaxListener.php b/workflow/engine/methods/cases/ajaxListener.php index 70083e7c0..e43c6b05f 100644 --- a/workflow/engine/methods/cases/ajaxListener.php +++ b/workflow/engine/methods/cases/ajaxListener.php @@ -25,35 +25,38 @@ if (isset($_REQUEST['action']) && $_REQUEST['action'] == "verifySession") { print G::json_encode($response); die(); } else { + //When the user has session we will to validate the permissions over other actions /** Action: Reassign from openCase */ global $RBAC; - $proUid = $_SESSION['PROCESS']; - $appUid = $_SESSION['APPLICATION']; - $tasUid = $_SESSION['TASK']; + $proUid = isset($_SESSION['PROCESS']) ? $_SESSION['PROCESS'] : ''; + $appUid = isset($_SESSION['APPLICATION']) ? $_SESSION['APPLICATION'] : ''; + $tasUid = isset($_SESSION['TASK']) ? $_SESSION['TASK'] : ''; $response = new stdclass(); - $cases = new BmCases(); - $userAuthorization = $cases->userAuthorization( - $RBAC->aUserInfo['USER_INFO']['USR_UID'], - $proUid, - $appUid, - ['PM_REASSIGNCASE', 'PM_REASSIGNCASE_SUPERVISOR'], - ['REASSIGN_MY_CASES' => ''], - true, - $tasUid - ); + $userAuthorization = []; + if (!empty($proUid) && !empty($appUid)) { + $cases = new BmCases(); + $userAuthorization = $cases->userAuthorization( + $RBAC->aUserInfo['USER_INFO']['USR_UID'], + $proUid, + $appUid, + ['PM_REASSIGNCASE', 'PM_REASSIGNCASE_SUPERVISOR'], + ['REASSIGN_MY_CASES' => ''], + true, + $tasUid + ); - if ( - $userAuthorization['rolesPermissions']['PM_REASSIGNCASE'] || - ($userAuthorization['rolesPermissions']['PM_REASSIGNCASE_SUPERVISOR'] && $userAuthorization['supervisor']) || - in_array($appUid, $userAuthorization['objectPermissions']['REASSIGN_MY_CASES']) - ) { - $response->reassigncase = true; - $response->message = ''; - } else { - $response->reassigncase = false; - $response->message = G::LoadTranslation('ID_NOT_ABLE_REASSIGN'); + if ( + $userAuthorization['rolesPermissions']['PM_REASSIGNCASE'] || + ($userAuthorization['rolesPermissions']['PM_REASSIGNCASE_SUPERVISOR'] && $userAuthorization['supervisor']) || + in_array($appUid, $userAuthorization['objectPermissions']['REASSIGN_MY_CASES']) + ) { + $response->reassigncase = true; + $response->message = ''; + } } + $response->reassigncase = false; + $response->message = G::LoadTranslation('ID_NOT_ABLE_REASSIGN'); print G::json_encode($response); die(); diff --git a/workflow/engine/methods/cases/caseHistory_Ajax.php b/workflow/engine/methods/cases/caseHistory_Ajax.php index e3fc9d007..ae954d1ae 100644 --- a/workflow/engine/methods/cases/caseHistory_Ajax.php +++ b/workflow/engine/methods/cases/caseHistory_Ajax.php @@ -1,5 +1,6 @@ loadCase($appUid); + $criteria = Cases::getTransferHistoryCriteria($fields['APP_NUMBER']); $dataSet = GulliverBasePeer::doSelectRs($criteria); $totalCount = $dataSet->getRecordCount(); diff --git a/workflow/engine/methods/cases/cases_Derivate.php b/workflow/engine/methods/cases/cases_Derivate.php index 8fdfe11f2..ebc7909ff 100644 --- a/workflow/engine/methods/cases/cases_Derivate.php +++ b/workflow/engine/methods/cases/cases_Derivate.php @@ -3,6 +3,7 @@ * cases_Derivate.php * */ + if (!isset($_SESSION['USER_LOGGED'])) { G::SendTemporalMessage('ID_LOGIN_AGAIN', 'warning', 'labels'); die(' - diff --git a/workflow/engine/xmlform/login/TimeZoneAlert.xml b/workflow/engine/xmlform/login/TimeZoneAlert.xml index 635fe37c7..22913434a 100644 --- a/workflow/engine/xmlform/login/TimeZoneAlert.xml +++ b/workflow/engine/xmlform/login/TimeZoneAlert.xml @@ -1,11 +1,6 @@ - - - - - @@ -46,4 +41,3 @@ ]]> - diff --git a/workflow/public_html/sysGeneric.php b/workflow/public_html/sysGeneric.php index 10ceeb548..40ad96e81 100644 --- a/workflow/public_html/sysGeneric.php +++ b/workflow/public_html/sysGeneric.php @@ -1050,13 +1050,44 @@ if (!defined('EXECUTE_BY_CRON')) { } $_SESSION['phpLastFileFound'] = $_SERVER['REQUEST_URI']; + /*----------------------------------********---------------------------------*/ + // Check if the timezone for the user is valid + if (!empty($_SESSION['USER_LOGGED']) && isset($_SESSION['__TIME_ZONE_FAILED__']) && $_SESSION['__TIME_ZONE_FAILED__'] && + (SYS_COLLECTION != 'login' && SYS_TARGET != 'login')) { + $userTimeZone = $_SESSION['USR_TIME_ZONE']; + $browserTimeZone = $_SESSION['BROWSER_TIME_ZONE']; + + $dateTime = new \ProcessMaker\Util\DateTime(); + + $userTimeZoneOffset = $dateTime->getTimeZoneOffsetByTimeZoneId($userTimeZone); + $browserTimeZoneOffset = $dateTime->getTimeZoneOffsetByTimeZoneId($browserTimeZone); + + $userUtcOffset = $dateTime->getUtcOffsetByTimeZoneOffset($userTimeZoneOffset); + $browserUtcOffset = $dateTime->getUtcOffsetByTimeZoneOffset($browserTimeZoneOffset); + + $arrayTimeZoneId = $dateTime->getTimeZoneIdByTimeZoneOffset($browserTimeZoneOffset); + + array_unshift($arrayTimeZoneId, 'false'); + array_walk($arrayTimeZoneId, function (&$value, $key, $parameter) { $value = ['TZ_UID' => $value, 'TZ_NAME' => '(UTC ' . $parameter . ') ' . $value]; }, $browserUtcOffset); + + $_SESSION['_DBArray'] = ['TIME_ZONE' => $arrayTimeZoneId]; + + $arrayData = [ + 'USR_TIME_ZONE' => '(UTC ' . $userUtcOffset . ') ' . $userTimeZone, + 'BROWSER_TIME_ZONE' => $browserTimeZone + ]; + + global $G_PUBLISH; + $G_PUBLISH = new Publisher(); + $G_PUBLISH->AddContent('xmlform', 'xmlform', 'login' . PATH_SEP . 'TimeZoneAlert', '', $arrayData, SYS_URI . 'login/updateTimezone'); + G::RenderPage('publish'); + exit(0); + } + /*----------------------------------********---------------------------------*/ + // Initialization functions plugins $oPluginRegistry->init(); - /** - * New feature for Gulliver framework to support Controllers & HttpProxyController classes handling - * - * @author setHttpRequestData($_REQUEST);//NewRelic Snippet - By JHL