Ejemplo n.º 1
0
 /**
  * Get the application delegation record from database
  *
  * @param string $arrayAppUid array of Application identifiers
  * @param string $action Action (todo, draft, paused, sent, selfservice, unassigned, search)
  * @param string $appStatus Status of Application
  * @return array of arrays with delegation information.
  */
 public function getListApplicationDelegationData($arrayAppUid, $action, $appStatus)
 {
     $c = new Criteria();
     $c->addSelectColumn(AppDelegationPeer::APP_UID);
     $c->addSelectColumn(AppDelegationPeer::DEL_INDEX);
     $c->addAsColumn('USR_NAME', 'u.USR_FIRSTNAME');
     $c->addAsColumn('USR_LAST', 'u.USR_LASTNAME');
     $c->addAsColumn('USR_PREV_NAME', 'uprev.USR_FIRSTNAME');
     $c->addAsColumn('USR_PREV_LAST', 'uprev.USR_LASTNAME');
     $c->addAsColumn('PREVIOUS_USR_UID', 'uprev.USR_UID');
     $c->addAsColumn('APP_TAS_TITLE', 'ctastitle.CON_VALUE');
     $c->addAsColumn('APP_THREAD_STATUS', 'at.APP_THREAD_STATUS');
     $c->addSelectColumn(AppDelegationPeer::APP_OVERDUE_PERCENTAGE);
     $c->addSelectColumn(AppDelegationPeer::DEL_DELAYED);
     $c->addSelectColumn(AppDelegationPeer::DEL_DELAY_DURATION);
     $c->addSelectColumn(AppDelegationPeer::DEL_DELEGATE_DATE);
     $c->addSelectColumn(AppDelegationPeer::DEL_DURATION);
     $c->addSelectColumn(AppDelegationPeer::DEL_FINISH_DATE);
     $c->addSelectColumn(AppDelegationPeer::DEL_INIT_DATE);
     $c->addSelectColumn(AppDelegationPeer::DEL_QUEUE_DURATION);
     $c->addSelectColumn(AppDelegationPeer::DEL_TASK_DUE_DATE);
     $c->addSelectColumn(AppDelegationPeer::DEL_THREAD_STATUS);
     $c->addSelectColumn(AppDelegationPeer::TAS_UID);
     $c->addAlias("u", "USERS");
     $c->addAlias("uprev", "USERS");
     $c->addAlias("adprev", "APP_DELEGATION");
     $c->addAlias("ctastitle", "CONTENT");
     $c->addAlias("at", "APP_THREAD");
     $arrayCondition = array();
     $arrayCondition[] = array(AppDelegationPeer::APP_UID, ApplicationPeer::APP_UID);
     $c->addJoinMC($arrayCondition, Criteria::LEFT_JOIN);
     $arrayCondition = array();
     $arrayCondition[] = array(AppDelegationPeer::USR_UID, "u.USR_UID");
     $c->addJoinMC($arrayCondition, Criteria::LEFT_JOIN);
     $arrayCondition = array();
     $arrayCondition[] = array(AppDelegationPeer::APP_UID, "adprev.APP_UID");
     $arrayCondition[] = array(AppDelegationPeer::DEL_PREVIOUS, "adprev.DEL_INDEX");
     $c->addJoinMC($arrayCondition, Criteria::LEFT_JOIN);
     $arrayCondition = array();
     $arrayCondition[] = array(AppDelegationPeer::TAS_UID, "ctastitle.CON_ID");
     $c->addJoinMC($arrayCondition, Criteria::LEFT_JOIN);
     $arrayCondition = array();
     $arrayCondition[] = array("adprev.USR_UID", "uprev.USR_UID");
     $c->addJoinMC($arrayCondition, Criteria::LEFT_JOIN);
     $arrayCondition = array();
     $arrayCondition[] = array(AppDelegationPeer::APP_UID, "at.APP_UID");
     $arrayCondition[] = array(AppDelegationPeer::DEL_THREAD, "at.APP_THREAD_INDEX");
     $c->addJoinMC($arrayCondition, Criteria::LEFT_JOIN);
     $c->add(AppDelegationPeer::APP_UID, $arrayAppUid, Criteria::IN);
     //$c->add (AppDelegationPeer::DEL_INDEX, $delIndex);
     switch ($action) {
         case "sent":
             if (!empty($appStatus)) {
                 $c->add(ApplicationPeer::APP_STATUS, $appStatus);
             }
             break;
         default:
             $appCacheView = new AppCacheView();
             //Paused
             $sqlAppDelay = $appCacheView->getAppDelaySql(AppDelegationPeer::APP_UID, AppDelegationPeer::DEL_INDEX);
             //Criterions
             $criterionToDo = $c->getNewCriterion(ApplicationPeer::APP_STATUS, "TO_DO", CRITERIA::EQUAL)->addAnd($c->getNewCriterion(AppDelegationPeer::DEL_FINISH_DATE, null, Criteria::ISNULL))->addAnd($c->getNewCriterion("at.APP_THREAD_STATUS", "OPEN"))->addAnd($c->getNewCriterion(AppDelegationPeer::DEL_THREAD_STATUS, "OPEN"));
             $criterionDraft = $c->getNewCriterion(ApplicationPeer::APP_STATUS, "DRAFT", CRITERIA::EQUAL)->addAnd($c->getNewCriterion("at.APP_THREAD_STATUS", "OPEN"))->addAnd($c->getNewCriterion(AppDelegationPeer::DEL_THREAD_STATUS, "OPEN"));
             $criterionPaused = $c->getNewCriterion(ApplicationPeer::APP_STATUS, "PAUSED")->addAnd($c->getNewCriterion(AppDelegationPeer::APP_UID, AppDelegationPeer::APP_UID . " IN ({$sqlAppDelay})", Criteria::CUSTOM));
             $criterionCancelled = $c->getNewCriterion(ApplicationPeer::APP_STATUS, "CANCELLED", CRITERIA::EQUAL)->addAnd($c->getNewCriterion(AppDelegationPeer::DEL_THREAD_STATUS, "CLOSED"));
             $criterionCompleted = $c->getNewCriterion(ApplicationPeer::APP_STATUS, "COMPLETED");
             switch ($appStatus) {
                 case "TO_DO":
                     //ToDo
                     $c->add($criterionToDo);
                     break;
                 case "DRAFT":
                     //Draft
                     $c->add($criterionDraft);
                     break;
                 case "PAUSED":
                     //Paused
                     $c->add($criterionPaused);
                     break;
                 case "CANCELLED":
                     //Cancelled
                     $c->add($criterionCancelled);
                     break;
                 case "COMPLETED":
                     //Completed
                     $c->add($criterionCompleted);
                     break;
                 default:
                     //All status
                     $c->add($criterionToDo)->addOr($criterionDraft)->addOr($criterionPaused)->addOr($criterionCancelled)->addOr($criterionCompleted);
                     break;
             }
             break;
     }
     $c->add('ctastitle.CON_CATEGORY', 'TAS_TITLE');
     $c->add('ctastitle.CON_LANG', 'en');
     $rs = AppDelegationPeer::doSelectRS($c);
     $rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
     // echo $c->toString();
     $rs->next();
     $row = $rs->getRow();
     $appDataRows = array();
     while (is_array($row)) {
         $appDataRows[] = $row;
         $rs->next();
         $row = $rs->getRow();
     }
     return $appDataRows;
 }