/** * reassign Case * * @param string sessionId : The session ID (which was obtained during login) * @param string caseId : The case ID (which can be obtained with the caseList() function) * @param string delIndex : The delegation index number of the case (which can be obtained with the caseList() * function). * @param string userIdSource : The user who is currently assigned the case. * @param string userIdTarget : The target user who will be newly assigned to the case. * @return $result will return an object */ public function reassignCase ($sessionId, $caseId, $delIndex, $userIdSource, $userIdTarget) { $g = new G(); try { $g->sessionVarSave(); $_SESSION["APPLICATION"] = $caseId; $_SESSION["INDEX"] = $delIndex; $_SESSION["USER_LOGGED"] = $userIdSource; if ($userIdTarget == $userIdSource) { $result = new wsResponse( 30, G::loadTranslation( 'ID_TARGET_ORIGIN_USER_SAME' ) ); $g->sessionVarRestore(); return $result; } /** * ****************( 1 )***************** */ $oCriteria = new Criteria( 'workflow' ); $oCriteria->add( UsersPeer::USR_STATUS, 'ACTIVE' ); $oCriteria->add( UsersPeer::USR_UID, $userIdSource ); $oDataset = UsersPeer::doSelectRS( $oCriteria ); $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); $oDataset->next(); $aRow = $oDataset->getRow(); if (! is_array( $aRow )) { $result = new wsResponse( 31, G::loadTranslation( 'ID_INVALID_ORIGIN_USER' ) ); $g->sessionVarRestore(); return $result; } /** * ****************( 2 )***************** */ $oCase = new Cases(); $rows = $oCase->loadCase( $caseId ); if (! is_array( $aRow )) { $result = new wsResponse( 32, G::loadTranslation( 'ID_CASE_NOT_OPEN' ) ); $g->sessionVarRestore(); return $result; } /** * ****************( 3 )***************** */ $oCriteria = new Criteria( 'workflow' ); $aConditions = array (); // $aConditions[] = array(AppDelegationPeer::USR_UID, TaskUserPeer::USR_UID); // $aConditions[] = array(AppDelegationPeer::TAS_UID, TaskUserPeer::TAS_UID); // $oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN); //$oCriteria->addJoin(AppDelegationPeer::USR_UID, TaskUserPeer::USR_UID, Criteria::LEFT_JOIN); $oCriteria->add( AppDelegationPeer::APP_UID, $caseId ); $oCriteria->add( AppDelegationPeer::USR_UID, $userIdSource ); $oCriteria->add( AppDelegationPeer::DEL_INDEX, $delIndex ); $oCriteria->add( AppDelegationPeer::DEL_FINISH_DATE, null, Criteria::ISNULL ); $oDataset = AppDelegationPeer::doSelectRS( $oCriteria ); $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); $oDataset->next(); $aRow = $oDataset->getRow(); if (! is_array( $aRow )) { $result = new wsResponse( 33, G::loadTranslation( 'ID_INVALID_CASE_DELEGATION_INDEX' ) ); $g->sessionVarRestore(); return $result; } $tasUid = $aRow['TAS_UID']; $derivation = new Derivation(); $userList = $derivation->getAllUsersFromAnyTask($tasUid, true); if (! in_array( $userIdTarget, $userList )) { $result = new wsResponse( 34, G::loadTranslation( 'ID_TARGET_USER_DOES_NOT_HAVE_RIGHTS' ) ); $g->sessionVarRestore(); return $result; } /** * ****************( 4 )***************** */ $oCriteria = new Criteria( 'workflow' ); $oCriteria->add( UsersPeer::USR_STATUS, 'ACTIVE' ); $oCriteria->add( UsersPeer::USR_UID, $userIdTarget ); $oDataset = UsersPeer::doSelectRS( $oCriteria ); $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC ); $oDataset->next(); $aRow = $oDataset->getRow(); if (! is_array( $aRow )) { $result = new wsResponse( 35, G::loadTranslation( 'ID_TARGET_USER_DESTINATION_INVALID' ) ); $g->sessionVarRestore(); return $result; } /** * ****************( 5 )***************** */ $var = $oCase->reassignCase( $caseId, $delIndex, $userIdSource, $userIdTarget ); if (! $var) { $result = new wsResponse( 36, G::loadTranslation( 'ID_CASE_COULD_NOT_REASSIGNED' ) ); $g->sessionVarRestore(); return $result; } $result = new wsResponse( 0, G::loadTranslation( 'ID_COMMAND_EXECUTED_SUCCESSFULLY' ) ); $g->sessionVarRestore(); return $result; } catch (Exception $e) { $result[] = array ('guid' => $e->getMessage(),'name' => $e->getMessage() ); $g->sessionVarRestore(); return $result; } }
G::RenderPage('publish', 'raw'); break; /* @Author Erik Amaru Ortiz <*****@*****.**> */ /* @Author Erik Amaru Ortiz <*****@*****.**> */ case 'reassignByUser': G::LoadClass('case'); $oCases = new Cases(); $aCases = array(); if (isset($_POST['items']) && trim($_POST['items']) != '') { $sItems = $_POST['items']; $aItems = explode(',', $sItems); $FROM_USR_UID = $_POST['USR_UID']; foreach ($aItems as $item) { list($APP_UID, $USR_UID) = explode('|', $item); $aCase = $oCases->loadCaseInCurrentDelegation($APP_UID, true); $oCase->reassignCase($aCase['APP_UID'], $aCase['DEL_INDEX'], $FROM_USR_UID, $USR_UID); array_push($aCases, $aCase); } //G::pr($aCases); //require_once 'classes/model/Users.php'; $oUser = new Users(); $sText = ''; foreach ($aCases as $aCase) { $aCaseUpdated = $oCases->loadCaseInCurrentDelegation($aCase['APP_UID'], true); $aUser = $oUser->load($aCaseUpdated['USR_UID']); $sText .= $aCaseUpdated['APP_PRO_TITLE'] . ' - ' . ' Case: ' . $aCaseUpdated['APP_NUMBER'] . '# (' . $aCaseUpdated['APP_TAS_TITLE'] . ') <b> => Reassigned to => </b> <font color="blue">' . $aUser['USR_FIRSTNAME'] . ' ' . $aUser['USR_LASTNAME'] . ' [' . $aUser['USR_USERNAME'] . ']' . '</font><br />'; } $G_PUBLISH = new Publisher(); $aMessage['MESSAGE'] = $sText; $aMessage['URL'] = 'cases_ReassignByUser?REASSIGN_USER='******'USR_UID']; $G_PUBLISH->AddContent('xmlform', 'xmlform', 'cases/cases_ReassignShowInfo', '', $aMessage);
$task = new Task(); $tasks = $task->load($_SESSION['TASK']); $result->data = $case->getUsersToReassign($_SESSION['TASK'], $_SESSION['USER_LOGGED'], $tasks['PRO_UID']); print G::json_encode($result); } if ($actionAjax == 'reassignCase') { $APP_UID = $_REQUEST["APP_UID"]; $DEL_INDEX = $_REQUEST["DEL_INDEX"]; $_SESSION['APPLICATION'] = $APP_UID; $_SESSION['INDEX'] = $DEL_INDEX; $cases = new Cases(); $user = new Users(); $app = new Application(); $TO_USR_UID = $_POST['USR_UID']; try { $cases->reassignCase($_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['USER_LOGGED'], $TO_USR_UID); $caseData = $app->load($_SESSION['APPLICATION']); $userData = $user->load($TO_USR_UID); //print_r($caseData); $data['APP_NUMBER'] = $caseData['APP_NUMBER']; $data['USER'] = $userData['USR_LASTNAME'] . ' ' . $userData['USR_FIRSTNAME']; //TODO change with the farmated username from environment conf $result->status = 0; $result->msg = G::LoadTranslation('ID_REASSIGNMENT_SUCCESS', SYS_LANG, $data); } catch (Exception $e) { $result->status = 1; $result->msg = $e->getMessage(); } print G::json_encode($result); } if ($actionAjax == 'showHistoryMessage') {
public function reassignCase() { $cases = new Cases(); $user = new Users(); $app = new Application(); $TO_USR_UID = $_POST['USR_UID']; try { $cases->reassignCase($_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['USER_LOGGED'], $TO_USR_UID); $caseData = $app->load($_SESSION['APPLICATION']); $userData = $user->load($TO_USR_UID); //print_r($caseData); $data['APP_NUMBER'] = $caseData['APP_NUMBER']; $data['USER'] = $userData['USR_LASTNAME'] . ' ' . $userData['USR_FIRSTNAME']; //TODO change with the farmated username from environment conf $result->status = 0; $result->msg = G::LoadTranslation('ID_REASSIGNMENT_SUCCESS', SYS_LANG, $data); } catch (Exception $e) { $result->status = 1; $result->msg = $e->getMessage(); } print G::json_encode($result); }
* * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * For more information, contact Colosa Inc, 2566 Le Jeune Rd., * Coral Gables, FL, 33134, USA, or email info@colosa.com. * */ try { G::LoadClass('case'); $oCase = new Cases(); foreach ($_POST['USER'] as $sProcessUID => $sUserUID) { if ($sUserUID != '') { $oCriteria = new Criteria('workflow'); $oCriteria->addSelectColumn(AppDelegationPeer::APP_UID); $oCriteria->addSelectColumn(AppDelegationPeer::DEL_INDEX); $oCriteria->add(AppDelegationPeer::PRO_UID, $sProcessUID); $oCriteria->add(AppDelegationPeer::USR_UID, $_POST['USR_UID']); $oCriteria->add(AppDelegationPeer::DEL_FINISH_DATE, null, Criteria::ISNULL); $oDataset = AppDelegationPeer::doSelectRS($oCriteria); $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); while ($aRow = $oDataset->getRow()) { $oCase->reassignCase($aRow['APP_UID'], $aRow['DEL_INDEX'], $_SESSION['USER_LOGGED'], $sUserUID); $oDataset->next(); } } } } catch (Exception $oException) { die($oException->getMessage()); }
die; } // $params = array (); // $sql = BasePeer::createSelectSql($oCasesReassignList, $params); // var_dump($sql); if (is_array($aData)) { $currentCasesReassigned = 0; foreach ($aData as $data) { $oTmpReassignCriteria = $oCasesReassignList; $oTmpReassignCriteria->add(AppCacheViewPeer::TAS_UID, $data->TAS_UID); $rs = AppCacheViewPeer::doSelectRS($oTmpReassignCriteria); $rs->setFetchmode(ResultSet::FETCHMODE_ASSOC); $rs->next(); $row = $rs->getRow(); $aCase = $oCases->loadCaseInCurrentDelegation($data->APP_UID); $oCases->reassignCase($aCase['APP_UID'], $aCase['DEL_INDEX'], $aCase['USR_UID'] != '' ? $aCase['USR_UID'] : $_SESSION['USER_LOGGED'], $data->APP_REASSIGN_USER_UID); $currentCasesReassigned++; $casesReassignedCount++; $serverResponse[] = array('APP_REASSIGN_USER' => $data->APP_REASSIGN_USER, 'APP_TITLE' => $data->APP_TITLE, 'TAS_TITLE' => $data->APP_TAS_TITLE, 'REASSIGNED_CASES' => $currentCasesReassigned); } } else { $oTmpReassignCriteria = $oCasesReassignList; $oTmpReassignCriteria->add(AppCacheViewPeer::TAS_UID, $aData->TAS_UID); $rs = AppCacheViewPeer::doSelectRS($oTmpReassignCriteria); $rs->setFetchmode(ResultSet::FETCHMODE_ASSOC); $rs->next(); $row = $rs->getRow(); $currentCasesReassigned = 0; while (is_array($row)) { $APP_UID = $row['APP_UID']; $aCase = $oCases->loadCaseInCurrentDelegation($APP_UID);
G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels'); G::header('location: ../login/login'); die; break; } G::LoadClass('case'); $oCase = new Cases(); $aCases = array(); $aUsers = array(); $c = 0; if (isset($_POST['USERS'])) { if (is_array($_POST['USERS'])) { foreach ($_POST['USERS'] as $sKey => $sUser) { if ($sUser != '') { $c++; $oCase->reassignCase($_POST['APPLICATIONS'][$sKey], $_POST['INDEXES'][$sKey], $_POST['USR_UID'], $sUser); $aCases[] = $_POST['APPLICATIONS'][$sKey]; $aUsers[] = $sUser; } } } } G::LoadClass('case'); $oCase = new Cases(); require_once 'classes/model/Users.php'; $oUser = new Users(); $sText = ''; foreach ($aCases as $sKey => $sCase) { $aCase = $oCase->loadCase($sCase); $aUser = $oUser->load($aUsers[$sKey]); $sText .= $aCase['TITLE'] . ' => ' . $aUser['USR_FIRSTNAME'] . ' ' . $aUser['USR_LASTNAME'] . ' (' . $aUser['USR_USERNAME'] . ')' . '<br />';
function reassignCase($params) { $cases = new Cases(); $cases->reassignCase($_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['USER_LOGGED'], $_POST['USR_UID'], $_POST['THETYPE']); $this->success = true; }
case -2: G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels'); G::header('location: ../login/login'); die; break; case -1: G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels'); G::header('location: ../login/login'); die; break; } //print_r($_POST); die; G::LoadClass('case'); $oCase = new Cases(); if ($_POST['USERS'] != '') { $oCase->reassignCase($_POST['APP_UID'], $_POST['DEL_INDEX'], $_SESSION['USER_LOGGED'], $_POST['USERS']); } require_once 'classes/model/Users.php'; $oUser = new Users(); $aUser = $oUser->load($_POST['USERS']); $Fields = array(); $Fields['USERS'] = $aUser['USR_FIRSTNAME'] . ' ' . $aUser['USR_LASTNAME'] . ' (' . $aUser['USR_USERNAME'] . ')'; G::LoadClass('case'); $oCases = new Cases(); $aCases = $oCases->loadCase($_POST['APP_UID'], $_POST['DEL_INDEX']); $Fields['APP_NUMBER'] = $aCases['APP_NUMBER']; $G_MAIN_MENU = 'processmaker'; $G_SUB_MENU = 'cases'; $G_ID_MENU_SELECTED = 'CASES'; $G_ID_SUB_MENU_SELECTED = 'CASES_TO_REASSIGN'; $G_PUBLISH = new Publisher();