validation

Action button
This commit is contained in:
Paula V. Quispe
2016-08-12 15:59:23 -04:00
parent c047b3fe42
commit 7363ae7e19
4 changed files with 87 additions and 19 deletions

View File

@@ -2878,10 +2878,6 @@ class wsBase
*/
$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 );

View File

@@ -738,6 +738,20 @@ class AppDelegation extends BaseAppDelegation
return $data['TAS_UID'];
}
public function getCurrentUsers($appUid, $index)
{
$oCriteria = new Criteria();
$oCriteria->addSelectColumn( AppDelegationPeer::USR_UID );
$oCriteria->add( AppDelegationPeer::APP_UID, $appUid );
$oCriteria->add( AppDelegationPeer::DEL_THREAD_STATUS, 'OPEN' );
$oCriteria->add( AppDelegationPeer::DEL_INDEX, $index );
$oRuleSet = AppDelegationPeer::doSelectRS( $oCriteria );
$oRuleSet->setFetchmode( ResultSet::FETCHMODE_ASSOC );
$oRuleSet->next();
$data = $oRuleSet->getRow();
return $data;
}
/**
* Verify if the current case is already routed.
*

View File

@@ -194,7 +194,9 @@ class Ajax
$options[] = Array('text' => G::LoadTranslation('ID_DELETE'), 'fn' => 'deleteCase');
if ($RBAC->userCanAccess('PM_REASSIGNCASE') == 1) {
$options[] = Array('text' => G::LoadTranslation('ID_REASSIGN'), 'fn' => 'getUsersToReassign');
if (!AppDelay::isPaused($_SESSION['APPLICATION'], $_SESSION['INDEX'])) {
$options[] = Array('text' => G::LoadTranslation('ID_REASSIGN'), 'fn' => 'getUsersToReassign');
}
}
break;
case 'TO_DO':
@@ -211,7 +213,9 @@ class Ajax
$options[] = Array('text' => G::LoadTranslation('ID_UNPAUSE'), 'fn' => 'unpauseCase');
}
if ($RBAC->userCanAccess('PM_REASSIGNCASE') == 1 || $RBAC->userCanAccess('PM_SUPERVISOR') == 1) {
$options[] = Array('text' => G::LoadTranslation('ID_REASSIGN'), 'fn' => 'getUsersToReassign');
if (!AppDelay::isPaused($_SESSION['APPLICATION'], $_SESSION['INDEX'])) {
$options[] = Array('text' => G::LoadTranslation('ID_REASSIGN'), 'fn' => 'getUsersToReassign');
}
}
break;
case 'CANCELLED':
@@ -597,10 +601,31 @@ class Ajax
$user = new Users();
$app = new Application();
$result = new stdclass();
$oAppDel = new AppDelegation();
$TO_USR_UID = $_POST['USR_UID'];
try {
$cases->reassignCase($_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['USER_LOGGED'], $TO_USR_UID);
//Current users of OPEN DEL_INDEX thread
if(isset($_SESSION['APPLICATION']) && isset($_SESSION['INDEX'])){
$aCurUser = $oAppDel->getCurrentUsers($_SESSION['APPLICATION'], $_SESSION['INDEX']);
}
$flagReassign = true;
if(!empty($aCurUser)){
foreach ($aCurUser as $key => $value) {
if($value === $TO_USR_UID){
$flagReassign = false;
}
}
} else {
//DEL_INDEX is CLOSED
throw new Exception(G::LoadTranslation('ID_REASSIGNMENT_ERROR'));
}
//If the currentUser is diferent to nextUser, create the thread
if($flagReassign){
$cases->reassignCase($_SESSION['APPLICATION'], $_SESSION['INDEX'], $_SESSION['USER_LOGGED'], $TO_USR_UID);
}
$caseData = $app->load($_SESSION['APPLICATION']);
$userData = $user->load($TO_USR_UID);
@@ -608,7 +633,7 @@ class Ajax
$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);
// Save the note reassign reason
if (isset($_POST['NOTE_REASON']) && $_POST['NOTE_REASON'] !== '') {
require_once ("classes/model/AppNotes.php");

View File

@@ -28,8 +28,7 @@ foreach ($items as $item) {
$dataUids = explode( "|", $item );
$appSelectedUids[] = $dataUids[0];
}
// var_dump($aData);
//var_dump($appSelectedUids);
$casesReassignedCount = 0;
$serverResponse = array ();
G::LoadClass( 'case' );
@@ -37,6 +36,7 @@ $oCases = new Cases();
require_once ('classes/model/Task.php');
require_once ('classes/model/AppCacheView.php');
$oAppCacheView = new AppCacheView();
$oAppDel = new AppDelegation();
$oCasesReassignList = $oAppCacheView->getToReassignListCriteria(null);
if (isset( $_POST['selected'] ) && $_POST['selected'] == 'true') {
$oCasesReassignList->add( AppCacheViewPeer::APP_UID, $appSelectedUids, Criteria::IN );
@@ -47,9 +47,7 @@ if (empty( $aData )) {
echo G::json_encode( $serverResponse );
die();
}
// $params = array ();
// $sql = BasePeer::createSelectSql($oCasesReassignList, $params);
// var_dump($sql);
if (is_array( $aData )) {
$currentCasesReassigned = 0;
require_once ("classes/model/AppNotes.php");
@@ -61,13 +59,31 @@ if (is_array( $aData )) {
$rs->setFetchmode( ResultSet::FETCHMODE_ASSOC );
$rs->next();
$row = $rs->getRow();
//$aCase = $oCases->loadCaseInCurrentDelegation( $data->APP_UID );
$oCases->reassignCase( $row['APP_UID'], $row['DEL_INDEX'], ($row['USR_UID'] != '' ? $row['USR_UID'] : $_SESSION['USER_LOGGED']), $data->APP_REASSIGN_USER_UID );
//Current users of OPEN DEL_INDEX thread
$aCurUser = $oAppDel->getCurrentUsers($row['APP_UID'], $row['DEL_INDEX']);
$flagReassign = true;
if(!empty($aCurUser)){
foreach ($aCurUser as $key => $value) {
if($value === $data->APP_REASSIGN_USER_UID){
$flagReassign = false;
}
}
} else {
//DEL_INDEX is CLOSED
throw new Exception(G::LoadTranslation('ID_REASSIGNMENT_ERROR'));
}
//If the currentUser is diferent to nextUser, create the thread
if($flagReassign){
$oCases->reassignCase( $row['APP_UID'], $row['DEL_INDEX'], ($row['USR_UID'] != '' ? $row['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
);
// Save the note reassign reason
if (isset($data->NOTE_REASON) && $data->NOTE_REASON !== '') {
$appNotes = new AppNotes();
@@ -86,11 +102,28 @@ if (is_array( $aData )) {
while (is_array( $row )) {
$APP_UID = $row['APP_UID'];
$aCase = $oCases->loadCaseInCurrentDelegation( $APP_UID );
$oCases->reassignCase( $aCase['APP_UID'], $aCase['DEL_INDEX'], ($aCase['USR_UID'] != '' ? $aCase['USR_UID'] : $_SESSION['USER_LOGGED']), $aData->APP_REASSIGN_USER_UID );
//Current users of OPEN DEL_INDEX thread
$aCurUser = $oAppDel->getCurrentUsers($APP_UID, $aCase['DEL_INDEX']);
$flagReassign = true;
if(!empty($aCurUser)){
foreach ($aCurUser as $key => $value) {
if($value === $aData->APP_REASSIGN_USER_UID){
$flagReassign = false;
}
}
} else {
//DEL_INDEX is CLOSED
throw new Exception(G::LoadTranslation('ID_REASSIGNMENT_ERROR'));
}
//If the currentUser is diferent to nextUser, create the thread
if($flagReassign){
$oCases->reassignCase( $aCase['APP_UID'], $aCase['DEL_INDEX'], ($aCase['USR_UID'] != '' ? $aCase['USR_UID'] : $_SESSION['USER_LOGGED']), $aData->APP_REASSIGN_USER_UID );
}
$currentCasesReassigned ++;
$casesReassignedCount ++;
// var_dump($aCase);
// echo ("<br>");
$rs->next();
$row = $rs->getRow();
}