示例#1
0
 public function getProUidSupervisor($userUid)
 {
     //finding cases PRO_UID where $userUid is supervising
     require_once 'classes/model/ProcessUser.php';
     require_once 'classes/model/GroupUser.php';
     $oCriteria = new Criteria('workflow');
     if (!empty($userUid)) {
         $oCriteria->add(ProcessUserPeer::USR_UID, $userUid);
     }
     $oCriteria->add(ProcessUserPeer::PU_TYPE, 'SUPERVISOR');
     $oDataset = ProcessUserPeer::doSelectRS($oCriteria);
     $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
     $oDataset->next();
     $aProcesses = array();
     while ($aRow = $oDataset->getRow()) {
         $aProcesses[] = $aRow['PRO_UID'];
         $oDataset->next();
     }
     $oCriteria = new Criteria('workflow');
     $oCriteria->addSelectColumn(ProcessUserPeer::PRO_UID);
     $oCriteria->add(ProcessUserPeer::PU_TYPE, 'GROUP_SUPERVISOR');
     $oCriteria->addJoin(ProcessUserPeer::USR_UID, GroupUserPeer::USR_UID, Criteria::LEFT_JOIN);
     if (!empty($userUid)) {
         $oCriteria->add(GroupUserPeer::USR_UID, $userUid);
     }
     $oDataset = ProcessUserPeer::doSelectRS($oCriteria);
     $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
     $oDataset->next();
     while ($aRow = $oDataset->getRow()) {
         $aProcesses[] = $aRow['PRO_UID'];
         $oDataset->next();
     }
     return $aProcesses;
 }
示例#2
0
    /**

     * Get "Process User" (Groups) records of a Process

     *

     * @param string $processUid Unique id of Process

     *

     * return array Return an array with all "Process User" (Groups)

     */

    public function getProcessUser($processUid)

    {

        try {

            $arrayProcessUser = array();



            //Get data

            $criteria = new Criteria("workflow");



            $criteria->add(ProcessUserPeer::PRO_UID, $processUid, Criteria::EQUAL);

            $criteria->add(ProcessUserPeer::PU_TYPE, "GROUP_SUPERVISOR", Criteria::EQUAL);



            $rsCriteria = ProcessUserPeer::doSelectRS($criteria);

            $rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);



            while ($rsCriteria->next()) {

                $row = $rsCriteria->getRow();



                //Verify group status

                $criteria2 = new Criteria("workflow");



                $criteria2->add(GroupwfPeer::GRP_UID, $row["USR_UID"], Criteria::EQUAL);

                $criteria2->add(GroupwfPeer::GRP_STATUS, "ACTIVE", Criteria::EQUAL);



                $rsCriteria2 = GroupwfPeer::doSelectRS($criteria2);



                if ($rsCriteria2->next()) {

                    $arrayProcessUser[] = $row;

                }

            }



            //Return

            return $arrayProcessUser;

        } catch (Exception $e) {

            throw $e;

        }

    }
示例#3
0
    public function getUsersToReassign($TAS_UID, $USR_UID, $PRO_UID=null)

    {

        G::LoadClass('groups');

        G::LoadClass('tasks');



        $oTasks = new Tasks();

        $aAux = $oTasks->getGroupsOfTask($TAS_UID, 1);

        $row = array();

        $groups = new Groups();

        foreach ($aAux as $aGroup) {

            $aUsers = $groups->getUsersOfGroup($aGroup['GRP_UID']);

            foreach ($aUsers as $aUser) {

                if ($aUser['USR_UID'] != $USR_UID) {

                    $row[] = $aUser['USR_UID'];

                }

            }

        }



        $aAux = $oTasks->getUsersOfTask($TAS_UID, 1);

        foreach ($aAux as $aUser) {

            if ($aUser['USR_UID'] != $USR_UID) {

                $row[] = $aUser['USR_UID'];

            }

        }



        // Group Ad Hoc

        $oTasks = new Tasks();

        $aAux = $oTasks->getGroupsOfTask($TAS_UID, 2);

        $groups = new Groups();

        foreach ($aAux as $aGroup) {

            $aUsers = $groups->getUsersOfGroup($aGroup['GRP_UID']);

            foreach ($aUsers as $aUser) {

                if ($aUser['USR_UID'] != $USR_UID) {

                    $row[] = $aUser['USR_UID'];

                }

            }

        }



        // User Ad Hoc

        $aAux = $oTasks->getUsersOfTask($TAS_UID, 2);

        foreach ($aAux as $aUser) {

            if ($aUser['USR_UID'] != $USR_UID) {

                $row[] = $aUser['USR_UID'];

            }

        }



        global $RBAC;

        //Adding the actual user if this has the PM_SUPERVISOR permission assigned.

        if ($RBAC->userCanAccess('PM_SUPERVISOR') == 1) {

            if(!in_array($RBAC->aUserInfo['USER_INFO']['USR_UID'], $row)) {

                $row[] = $RBAC->aUserInfo['USER_INFO']['USR_UID'];

            }

        }



        $c = new Criteria('workflow');

        $c->addSelectColumn(UsersPeer::USR_UID);

        $c->addSelectColumn(UsersPeer::USR_USERNAME);

        $c->addSelectColumn(UsersPeer::USR_FIRSTNAME);

        $c->addSelectColumn(UsersPeer::USR_LASTNAME);

        $c->add(UsersPeer::USR_UID, $row, Criteria::IN);



        $rs = UsersPeer::doSelectRs($c);

        $rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);



        $rows = Array();

        while ($rs->next()) {

            $rows[] = $rs->getRow();

        }



        if ($PRO_UID != null) {

            //Add supervisor

            // Users

            $oCriteria = new Criteria('workflow');

            $oCriteria->addSelectColumn(ProcessUserPeer::PU_UID);

            $oCriteria->addSelectColumn(ProcessUserPeer::USR_UID);

            $oCriteria->addSelectColumn(ProcessUserPeer::PRO_UID);

            $oCriteria->addSelectColumn(UsersPeer::USR_FIRSTNAME);

            $oCriteria->addSelectColumn(UsersPeer::USR_LASTNAME);

            $oCriteria->addSelectColumn(UsersPeer::USR_USERNAME);

            $oCriteria->addSelectColumn(UsersPeer::USR_EMAIL);

            $oCriteria->addJoin(ProcessUserPeer::USR_UID, UsersPeer::USR_UID, Criteria::LEFT_JOIN);

            $oCriteria->add(ProcessUserPeer::PU_TYPE, 'SUPERVISOR');

            $oCriteria->add(ProcessUserPeer::PRO_UID, $PRO_UID);

            $oCriteria->add(ProcessUserPeer::USR_UID, $USR_UID);

            $oCriteria->addAscendingOrderByColumn(UsersPeer::USR_FIRSTNAME);

            $oDataset = ProcessUserPeer::doSelectRS($oCriteria);

            $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);

            $flagSupervisors = false;



            if ($oDataset->next()) {

                if (!in_array($USR_UID,$row)) {

                        $rows[] = $oDataset->getRow();

                }

                $flagSupervisors = true;

            }



            if (!$flagSupervisors) {

                // Groups

                $oCriteria = new Criteria('workflow');

                $oCriteria->addSelectColumn(ProcessUserPeer::PU_UID);

                $oCriteria->addSelectColumn(ProcessUserPeer::USR_UID);

                $oCriteria->addSelectColumn(ProcessUserPeer::PRO_UID);



                $oCriteria->addSelectColumn(UsersPeer::USR_UID);

                $oCriteria->addSelectColumn(UsersPeer::USR_FIRSTNAME);

                $oCriteria->addSelectColumn(UsersPeer::USR_LASTNAME);

                $oCriteria->addSelectColumn(UsersPeer::USR_USERNAME);

                $oCriteria->addSelectColumn(UsersPeer::USR_EMAIL);



                $oCriteria->addJoin(ProcessUserPeer::USR_UID, GroupUserPeer::GRP_UID, Criteria::LEFT_JOIN);

                $oCriteria->addJoin(GroupUserPeer::USR_UID, UsersPeer::USR_UID, Criteria::LEFT_JOIN);



                $oCriteria->add(ProcessUserPeer::PU_TYPE, 'GROUP_SUPERVISOR');

                $oCriteria->add(ProcessUserPeer::PRO_UID, $PRO_UID);

                $oCriteria->add(GroupUserPeer::USR_UID, $USR_UID);



                $oDataset = ProcessUserPeer::doSelectRS($oCriteria);

                $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);



                if ($oDataset->next()) {

                    if (!in_array($USR_UID,$row)) {

                        $rows[] = $oDataset->getRow();

                    }

                }

            }

        }



        return $rows;

    }
 */
$G_MAIN_MENU = 'processmaker';
$G_SUB_MENU = 'cases';
$G_ID_MENU_SELECTED = 'CASES';
$G_ID_SUB_MENU_SELECTED = 'CASES_ADVANCEDSEARCH';
$G_PUBLISH = new Publisher();
global $RBAC;
$permisse = $RBAC->userCanAccess('PM_ALLCASES');
$userlogged = $_SESSION['USER_LOGGED'];
require_once "classes/model/ProcessUser.php";
$oCriteria = new Criteria('workflow');
$oCriteria->addSelectColumn(ProcessUserPeer::PU_UID);
$oCriteria->addSelectColumn(ProcessUserPeer::PRO_UID);
$oCriteria->add(ProcessUserPeer::USR_UID, $userlogged);
$oCriteria->add(ProcessUserPeer::PU_TYPE, "SUPERVISOR");
$oDataset = ProcessUserPeer::doSelectRS($oCriteria);
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$oDataset->next();
$aSupervisor = array();
while ($aRow = $oDataset->getRow()) {
    $aSupervisor[] = $aRow['PRO_UID'];
    $oDataset->next();
}
G::LoadClass('case');
$oCases = new Cases();
if (isset($_POST['form'])) {
    $fields['CASE_NUMBER'] = $_POST['form']['CASE_NUMBER'];
    $fields['PROCESS'] = $_POST['form']['PROCESS'];
    $fields['TASKS'] = $_POST['form']['TASKS'];
    $fields['CURRENT_USER'] = $_POST['form']['CURRENT_USER'];
    $fields['SENT_BY'] = $_POST['form']['SENT_BY'];
 /**
  * listExtNoProcessesUser for Extjs
  *
  * @param string $sProcessUID
  * @return array(aAvailableUser) $aAvailableUser
  */
 public function listExtNoProcessesUser($sProcessUID)
 {
     G::LoadSystem('rbac');
     $memcache =& PMmemcached::getSingleton(SYS_SYS);
     $oCriteria = new Criteria('workflow');
     $oCriteria->addSelectColumn(ProcessUserPeer::USR_UID);
     $oCriteria->add(ProcessUserPeer::PRO_UID, $sProcessUID);
     $oCriteria->add(ProcessUserPeer::PU_TYPE, 'SUPERVISOR');
     $oDataset = ProcessUserPeer::doSelectRS($oCriteria);
     $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
     $oDataset->next();
     $aUIDS = array();
     while ($aRow = $oDataset->getRow()) {
         $aUIDS[] = $aRow['USR_UID'];
         $oDataset->next();
     }
     $sDelimiter = DBAdapter::getStringDelimiter();
     $oCriteria = new Criteria('workflow');
     $oCriteria->addSelectColumn(UsersPeer::USR_UID);
     $oCriteria->add(UsersPeer::USR_UID, $aUIDS, Criteria::NOT_IN);
     $oDataset = UsersPeer::doSelectRS($oCriteria);
     $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
     $oDataset->next();
     $aUIDS = array();
     $oRBAC = RBAC::getSingleton();
     while ($aRow = $oDataset->getRow()) {
         $memKey = 'rbacSession' . session_id();
         if (($oRBAC->aUserInfo = $memcache->get($memKey)) === false) {
             $oRBAC->loadUserRolePermission($oRBAC->sSystem, $aRow['USR_UID']);
             $memcache->set($memKey, $oRBAC->aUserInfo, PMmemcached::EIGHT_HOURS);
         }
         $aPermissions = $oRBAC->aUserInfo[$oRBAC->sSystem]['PERMISSIONS'];
         $bInclude = false;
         foreach ($aPermissions as $aPermission) {
             if ($aPermission['PER_CODE'] == 'PM_SUPERVISOR') {
                 $bInclude = true;
             }
         }
         if ($bInclude) {
             $aUIDS[] = $aRow['USR_UID'];
         }
         $oDataset->next();
     }
     $oCriteria = new Criteria('workflow');
     $oCriteria->addSelectColumn(UsersPeer::USR_UID);
     $oCriteria->addSelectColumn(UsersPeer::USR_FIRSTNAME);
     $oCriteria->addSelectColumn(UsersPeer::USR_LASTNAME);
     $oCriteria->add(UsersPeer::USR_UID, $aUIDS, Criteria::IN);
     $oDataset = UsersPeer::doSelectRS($oCriteria);
     $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
     $oDataset->next();
     $aAvailableUser = '';
     while ($aRow = $oDataset->getRow()) {
         $aAvailableUser[] = array('USR_UID' => $aRow['USR_UID'], 'USR_FIRSTNAME' => $aRow['USR_FIRSTNAME'], 'USR_LASTNAME' => $aRow['USR_LASTNAME']);
         $oDataset->next();
     }
     return $aAvailableUser;
 }
示例#6
0
 /**
  * Get Object Permission Rows from a Process
  *
  * @param string $sProUid
  * @return $aDynaform array
  */
 public function getGroupwfSupervisor($sProUid, &$oData)
 {
     try {
         $oCriteria = new Criteria('workflow');
         $oCriteria->add(ProcessUserPeer::PRO_UID, $sProUid);
         $oCriteria->add(ProcessUserPeer::PU_TYPE, 'GROUP_SUPERVISOR');
         $oDataset = ProcessUserPeer::doSelectRS($oCriteria);
         $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
         $oDataset->next();
         while ($aRow = $oDataset->getRow()) {
             $oGroupwf = new Groupwf();
             $oData->groupwfs[] = $oGroupwf->Load($aRow['USR_UID']);
             $oDataset->next();
         }
         return true;
     } catch (Exception $oError) {
         throw $oError;
     }
 }
示例#7
0
 /**
  * Get the condition for Cases List
  *
  * @name getConditionCasesList
  * @param string $sTypeList
  * @param string $sUIDUserLogged
  * @param string $ClearSession
  * @param string $aAdditionalFilter
  * @return array
  */
 public function getConditionCasesList($sTypeList = 'all', $sUIDUserLogged = '', $ClearSession = true, $aAdditionalFilter = null)
 {
     $c = new Criteria('workflow');
     $c->clearSelectColumns();
     $c->addSelectColumn(ApplicationPeer::APP_UID);
     $c->addSelectColumn(ApplicationPeer::APP_NUMBER);
     $c->addSelectColumn(ApplicationPeer::APP_UPDATE_DATE);
     $c->addSelectColumn(ApplicationPeer::PRO_UID);
     $c->addSelectColumn(ApplicationPeer::APP_INIT_USER);
     $c->addSelectColumn(AppDelegationPeer::DEL_PRIORITY);
     //$c->addSelectColumn(AppDelegationPeer::DEL_TASK_DUE_DATE);
     $c->addAsColumn('DEL_TASK_DUE_DATE', " IF (" . AppDelegationPeer::DEL_TASK_DUE_DATE . " <= NOW(), CONCAT('<span style=\\'color:red\\';>', " . AppDelegationPeer::DEL_TASK_DUE_DATE . ", '</span>'), " . AppDelegationPeer::DEL_TASK_DUE_DATE . ") ");
     global $RBAC;
     //seems the PM_SUPERVISOR can delete a completed case
     if ($sTypeList == "completed" && $RBAC->userCanAccess('PM_SUPERVISOR') == 1) {
         $c->addAsColumn("DEL_LINK", "CONCAT('" . G::LoadTranslation('ID_DELETE') . "')");
     }
     $c->addSelectColumn(AppDelegationPeer::DEL_INDEX);
     $c->addSelectColumn(AppDelegationPeer::TAS_UID);
     $c->addSelectColumn(AppDelegationPeer::DEL_INIT_DATE);
     $c->addSelectColumn(AppDelegationPeer::DEL_FINISH_DATE);
     $c->addSelectColumn(UsersPeer::USR_UID);
     $c->addAsColumn('APP_CURRENT_USER', "CONCAT(USERS.USR_LASTNAME, ' ', USERS.USR_FIRSTNAME)");
     $c->addSelectColumn(ApplicationPeer::APP_STATUS);
     $c->addAsColumn('APP_TITLE', 'APP_TITLE.CON_VALUE');
     $c->addAsColumn('APP_PRO_TITLE', 'PRO_TITLE.CON_VALUE');
     $c->addAsColumn('APP_TAS_TITLE', 'TAS_TITLE.CON_VALUE');
     //$c->addAsColumn('APP_DEL_PREVIOUS_USER', 'APP_LAST_USER.USR_USERNAME');
     $c->addAsColumn('APP_DEL_PREVIOUS_USER', "CONCAT(APP_LAST_USER.USR_LASTNAME,\n            ' ',\n            APP_LAST_USER.USR_FIRSTNAME)");
     $c->addAlias("APP_TITLE", 'CONTENT');
     $c->addAlias("PRO_TITLE", 'CONTENT');
     $c->addAlias("TAS_TITLE", 'CONTENT');
     $c->addAlias("APP_PREV_DEL", 'APP_DELEGATION');
     $c->addAlias("APP_LAST_USER", 'USERS');
     $c->addJoin(ApplicationPeer::APP_UID, AppDelegationPeer::APP_UID, Criteria::LEFT_JOIN);
     $c->addJoin(AppDelegationPeer::TAS_UID, TaskPeer::TAS_UID, Criteria::LEFT_JOIN);
     $appThreadConds[] = array(ApplicationPeer::APP_UID, AppThreadPeer::APP_UID);
     $appThreadConds[] = array(AppDelegationPeer::DEL_INDEX, AppThreadPeer::DEL_INDEX);
     $c->addJoinMC($appThreadConds, Criteria::LEFT_JOIN);
     $c->addJoin(AppDelegationPeer::USR_UID, UsersPeer::USR_UID, Criteria::LEFT_JOIN);
     $del = DBAdapter::getStringDelimiter();
     $appTitleConds = array();
     $appTitleConds[] = array(ApplicationPeer::APP_UID, 'APP_TITLE.CON_ID');
     $appTitleConds[] = array('APP_TITLE.CON_CATEGORY', $del . 'APP_TITLE' . $del);
     $appTitleConds[] = array('APP_TITLE.CON_LANG', $del . SYS_LANG . $del);
     $c->addJoinMC($appTitleConds, Criteria::LEFT_JOIN);
     $proTitleConds = array();
     $proTitleConds[] = array(ApplicationPeer::PRO_UID, 'PRO_TITLE.CON_ID');
     $proTitleConds[] = array('PRO_TITLE.CON_CATEGORY', $del . 'PRO_TITLE' . $del);
     $proTitleConds[] = array('PRO_TITLE.CON_LANG', $del . SYS_LANG . $del);
     $c->addJoinMC($proTitleConds, Criteria::LEFT_JOIN);
     $tasTitleConds = array();
     $tasTitleConds[] = array(AppDelegationPeer::TAS_UID, 'TAS_TITLE.CON_ID');
     $tasTitleConds[] = array('TAS_TITLE.CON_CATEGORY', $del . 'TAS_TITLE' . $del);
     $tasTitleConds[] = array('TAS_TITLE.CON_LANG', $del . SYS_LANG . $del);
     $c->addJoinMC($tasTitleConds, Criteria::LEFT_JOIN);
     $prevConds = array();
     $prevConds[] = array(ApplicationPeer::APP_UID, 'APP_PREV_DEL.APP_UID');
     $prevConds[] = array('APP_PREV_DEL.DEL_INDEX', AppDelegationPeer::DEL_PREVIOUS);
     $c->addJoinMC($prevConds, Criteria::LEFT_JOIN);
     $usrConds = array();
     $usrConds[] = array('APP_PREV_DEL.USR_UID', 'APP_LAST_USER.USR_UID');
     $c->addJoinMC($usrConds, Criteria::LEFT_JOIN);
     $c->add(TaskPeer::TAS_TYPE, 'SUBPROCESS', Criteria::NOT_EQUAL);
     //gral, to_revise, to_reassign dont have userid in the query
     if ($sTypeList != 'gral' && $sTypeList != 'to_revise' && $sTypeList != 'to_reassign' && $sTypeList != 'my_started' && $sTypeList != 'sent') {
         $c->add(UsersPeer::USR_UID, $sUIDUserLogged);
     }
     /**
      * Additional filters
      * By Erik <*****@*****.**>
      */
     if (isset($aAdditionalFilter) && is_array($aAdditionalFilter)) {
         foreach ($aAdditionalFilter as $sFilter => $sValue) {
             switch ($sFilter) {
                 case 'PRO_UID':
                     if ($sValue != "0") {
                         $c->add(ApplicationPeer::PRO_UID, $sValue, Criteria::EQUAL);
                     }
                     break;
                 case 'READ':
                     $c->add(AppDelegationPeer::DEL_INIT_DATE, null, Criteria::ISNOTNULL);
                     break;
                 case 'UNREAD':
                     $c->add(AppDelegationPeer::DEL_INIT_DATE, null, Criteria::ISNULL);
                     break;
             }
         }
     }
     $filesList = array('to_do' => 'cases/cases_ListTodo', 'draft' => 'cases/cases_ListDraft', 'paused' => 'cases/cases_ListOnHold', 'cancelled' => 'cases/cases_ListCancelled', 'completed' => 'cases/cases_ListCompleted', 'sent' => 'cases/cases_ListSent', 'selfservice' => 'cases/cases_ListSelfService', 'all' => 'cases/cases_ListAll', 'to_revise' => 'cases/cases_ListToRevise', 'to_reassign' => 'cases/cases_ListAll_Reassign', 'my_started' => 'cases/cases_ListStarted', 'Alldelete' => 'cases/cases_ListAllDelete');
     switch ($sTypeList) {
         case 'all':
             $c->add($c->getNewCriterion(AppThreadPeer::APP_THREAD_STATUS, 'OPEN')->addOr($c->getNewCriterion(ApplicationPeer::APP_STATUS, 'COMPLETED')->addAnd($c->getNewCriterion(AppDelegationPeer::DEL_PREVIOUS, 0))));
             $c->addDescendingOrderByColumn(ApplicationPeer::APP_NUMBER);
             break;
         case 'my_started':
             $oCriteria = new Criteria('workflow');
             $oCriteria->addSelectColumn(AppDelayPeer::APP_UID);
             $oCriteria->add($oCriteria->getNewCriterion(AppDelayPeer::APP_DISABLE_ACTION_USER, null, Criteria::ISNULL)->addOr($oCriteria->getNewCriterion(AppDelayPeer::APP_DISABLE_ACTION_USER, 0)));
             //$oCriteria->add(AppDelayPeer::APP_DISABLE_ACTION_USER, null, Criteria::ISNULL);
             $oDataset = AppDelayPeer::doSelectRS($oCriteria);
             $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
             $oDataset->next();
             $aProcesses = array();
             while ($aRow = $oDataset->getRow()) {
                 $aProcesses[] = $aRow['APP_UID'];
                 $oDataset->next();
             }
             $c->add($c->getNewCriterion(ApplicationPeer::APP_INIT_USER, $sUIDUserLogged));
             $c->add($c->getNewCriterion(AppThreadPeer::APP_THREAD_STATUS, 'OPEN')->addOr($c->getNewCriterion(ApplicationPeer::APP_STATUS, 'COMPLETED')->addAnd($c->getNewCriterion(AppDelegationPeer::DEL_PREVIOUS, 0))));
             $c->add($c->getNewCriterion(ApplicationPeer::APP_UID, $aProcesses, Criteria::NOT_IN));
             $c->addDescendingOrderByColumn(ApplicationPeer::APP_NUMBER);
             break;
         case 'to_do':
             $c->add(ApplicationPeer::APP_STATUS, 'TO_DO');
             $c->add(AppDelegationPeer::DEL_FINISH_DATE, null, Criteria::ISNULL);
             $c->add(AppThreadPeer::APP_THREAD_STATUS, 'OPEN');
             $c->add(AppDelegationPeer::DEL_THREAD_STATUS, 'OPEN');
             $c->addDescendingOrderByColumn(ApplicationPeer::APP_NUMBER);
             break;
         case 'draft':
             $c->add(ApplicationPeer::APP_STATUS, 'DRAFT');
             $c->add(AppDelegationPeer::DEL_FINISH_DATE, null, Criteria::ISNULL);
             $c->add(AppDelegationPeer::DEL_THREAD_STATUS, 'OPEN');
             $c->addDescendingOrderByColumn(ApplicationPeer::APP_NUMBER);
             break;
         case 'paused':
             $appDelayConds[] = array(ApplicationPeer::APP_UID, AppDelayPeer::APP_UID);
             $appDelayConds[] = array(AppDelegationPeer::DEL_INDEX, AppDelayPeer::APP_DEL_INDEX);
             $c->addJoinMC($appDelayConds, Criteria::LEFT_JOIN);
             $c->add(AppDelayPeer::APP_DELAY_UID, null, Criteria::ISNOTNULL);
             $c->add(AppDelayPeer::APP_TYPE, array("REASSIGN", "ADHOC", "CANCEL"), Criteria::NOT_IN);
             $c->add($c->getNewCriterion(AppDelayPeer::APP_DISABLE_ACTION_USER, null, Criteria::ISNULL)->addOr($c->getNewCriterion(AppDelayPeer::APP_DISABLE_ACTION_USER, 0)));
             $c->addDescendingOrderByColumn(ApplicationPeer::APP_NUMBER);
             break;
         case 'cancelled':
             $c->add($c->getNewCriterion(AppThreadPeer::APP_THREAD_STATUS, 'CLOSED')->addAnd($c->getNewCriterion(ApplicationPeer::APP_STATUS, 'CANCELLED')));
             $c->addDescendingOrderByColumn(ApplicationPeer::APP_NUMBER);
             break;
         case 'completed':
             $c->add(ApplicationPeer::APP_STATUS, 'COMPLETED');
             $c->add(AppDelegationPeer::DEL_PREVIOUS, '0', Criteria::NOT_EQUAL);
             //$c->addAsColumn('DEL_FINISH_DATE', 'max('.AppDelegationPeer::DEL_FINISH_DATE.')');
             $c->addGroupByColumn(ApplicationPeer::APP_UID);
             $c->addDescendingOrderByColumn(ApplicationPeer::APP_NUMBER);
             break;
         case 'gral':
             $c->add($c->getNewCriterion(AppThreadPeer::APP_THREAD_STATUS, 'OPEN')->addOr($c->getNewCriterion(ApplicationPeer::APP_STATUS, 'COMPLETED')->addAnd($c->getNewCriterion(AppDelegationPeer::DEL_PREVIOUS, 0))));
             $c->addDescendingOrderByColumn(ApplicationPeer::APP_NUMBER);
             $params = array();
             $sSql = BasePeer::createSelectSql($c, $params);
             break;
         case 'to_revise':
             $oCriteria = new Criteria('workflow');
             $oCriteria->add(ProcessUserPeer::USR_UID, $sUIDUserLogged);
             $oCriteria->add(ProcessUserPeer::PU_TYPE, 'SUPERVISOR');
             $oDataset = ProcessUserPeer::doSelectRS($oCriteria);
             $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
             $oDataset->next();
             $aProcesses = array();
             while ($aRow = $oDataset->getRow()) {
                 $aProcesses[] = $aRow['PRO_UID'];
                 $oDataset->next();
             }
             $c->add(ApplicationPeer::PRO_UID, $aProcesses, Criteria::IN);
             $c->add(ApplicationPeer::APP_STATUS, 'TO_DO');
             $c->add(AppDelegationPeer::DEL_FINISH_DATE, null, Criteria::ISNULL);
             $c->add(AppThreadPeer::APP_THREAD_STATUS, 'OPEN');
             $c->add(AppDelegationPeer::DEL_THREAD_STATUS, 'OPEN');
             $c->addDescendingOrderByColumn(ApplicationPeer::APP_NUMBER);
             break;
         case 'selfservice':
             //get the valid selfservice tasks for this user
             $oCase = new Cases();
             $tasks = $oCase->getSelfServiceTasks($_SESSION['USER_LOGGED']);
             $aTasks = array();
             foreach ($tasks as $key => $val) {
                 if (strlen(trim($val['uid'])) > 10) {
                     $aTasks[] = $val['uid'];
                 }
             }
             $c = new Criteria('workflow');
             $c->clearSelectColumns();
             $c->addSelectColumn(ApplicationPeer::APP_UID);
             $c->addSelectColumn(ApplicationPeer::APP_NUMBER);
             $c->addSelectColumn(ApplicationPeer::APP_UPDATE_DATE);
             $c->addSelectColumn(ApplicationPeer::PRO_UID);
             $c->addSelectColumn(ApplicationPeer::APP_INIT_USER);
             $c->addSelectColumn(AppDelegationPeer::DEL_PRIORITY);
             $c->addAsColumn('DEL_TASK_DUE_DATE', " IF (" . AppDelegationPeer::DEL_TASK_DUE_DATE . " <= NOW(),\n                    CONCAT('<span style=\\'color:red\\';>', " . AppDelegationPeer::DEL_TASK_DUE_DATE . ", '</span>'), " . AppDelegationPeer::DEL_TASK_DUE_DATE . ") ");
             $c->addSelectColumn(AppDelegationPeer::DEL_INDEX);
             $c->addSelectColumn(AppDelegationPeer::TAS_UID);
             $c->addSelectColumn(AppDelegationPeer::DEL_INIT_DATE);
             $c->addSelectColumn(AppDelegationPeer::DEL_FINISH_DATE);
             $c->addSelectColumn(UsersPeer::USR_UID);
             $c->addAsColumn('APP_CURRENT_USER', "CONCAT(USERS.USR_LASTNAME, ' ', USERS.USR_FIRSTNAME)");
             $c->addSelectColumn(ApplicationPeer::APP_STATUS);
             $c->addAsColumn('APP_TITLE', 'APP_TITLE.CON_VALUE');
             $c->addAsColumn('APP_PRO_TITLE', 'PRO_TITLE.CON_VALUE');
             $c->addAsColumn('APP_TAS_TITLE', 'TAS_TITLE.CON_VALUE');
             $c->addAlias("APP_TITLE", 'CONTENT');
             $c->addAlias("PRO_TITLE", 'CONTENT');
             $c->addAlias("TAS_TITLE", 'CONTENT');
             $c->addJoin(ApplicationPeer::APP_UID, AppDelegationPeer::APP_UID, Criteria::LEFT_JOIN);
             $c->addJoin(AppDelegationPeer::TAS_UID, TaskPeer::TAS_UID, Criteria::LEFT_JOIN);
             $appThreadConds[] = array(ApplicationPeer::APP_UID, AppThreadPeer::APP_UID);
             $appThreadConds[] = array(AppDelegationPeer::DEL_INDEX, AppThreadPeer::DEL_INDEX);
             $c->addJoinMC($appThreadConds, Criteria::LEFT_JOIN);
             $c->addJoin(AppDelegationPeer::USR_UID, UsersPeer::USR_UID, Criteria::LEFT_JOIN);
             $del = DBAdapter::getStringDelimiter();
             $appTitleConds = array();
             $appTitleConds[] = array(ApplicationPeer::APP_UID, 'APP_TITLE.CON_ID');
             $appTitleConds[] = array('APP_TITLE.CON_CATEGORY', $del . 'APP_TITLE' . $del);
             $appTitleConds[] = array('APP_TITLE.CON_LANG', $del . SYS_LANG . $del);
             $c->addJoinMC($appTitleConds, Criteria::LEFT_JOIN);
             //
             $proTitleConds = array();
             $proTitleConds[] = array(ApplicationPeer::PRO_UID, 'PRO_TITLE.CON_ID');
             $proTitleConds[] = array('PRO_TITLE.CON_CATEGORY', $del . 'PRO_TITLE' . $del);
             $proTitleConds[] = array('PRO_TITLE.CON_LANG', $del . SYS_LANG . $del);
             $c->addJoinMC($proTitleConds, Criteria::LEFT_JOIN);
             //
             $tasTitleConds = array();
             $tasTitleConds[] = array(AppDelegationPeer::TAS_UID, 'TAS_TITLE.CON_ID');
             $tasTitleConds[] = array('TAS_TITLE.CON_CATEGORY', $del . 'TAS_TITLE' . $del);
             $tasTitleConds[] = array('TAS_TITLE.CON_LANG', $del . SYS_LANG . $del);
             $c->addJoinMC($tasTitleConds, Criteria::LEFT_JOIN);
             $c->add(AppDelegationPeer::USR_UID, '');
             $c->add(AppDelegationPeer::TAS_UID, $aTasks, Criteria::IN);
             break;
         case 'to_reassign':
             $c->add($c->getNewCriterion(ApplicationPeer::APP_STATUS, 'TO_DO')->addOr($c->getNewCriterion(ApplicationPeer::APP_STATUS, 'DRAFT')));
             $c->add(AppDelegationPeer::DEL_FINISH_DATE, null, Criteria::ISNULL);
             $c->add(AppThreadPeer::APP_THREAD_STATUS, 'OPEN');
             $c->add(AppDelegationPeer::DEL_THREAD_STATUS, 'OPEN');
             $c->addDescendingOrderByColumn(ApplicationPeer::APP_NUMBER);
             break;
         case 'sent':
             $oCriteria = new Criteria('workflow');
             $oCriteria->addSelectColumn(AppDelayPeer::APP_UID);
             $oCriteria->add($oCriteria->getNewCriterion(AppDelayPeer::APP_DISABLE_ACTION_USER, null, Criteria::ISNULL)->addOr($oCriteria->getNewCriterion(AppDelayPeer::APP_DISABLE_ACTION_USER, 0)));
             $oDataset = AppDelayPeer::doSelectRS($oCriteria);
             $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
             $oDataset->next();
             $aProcesses = array();
             while ($aRow = $oDataset->getRow()) {
                 $aProcesses[] = $aRow['APP_UID'];
                 $oDataset->next();
             }
             if (isset($aAdditionalFilter) && isset($aAdditionalFilter['MINE'])) {
                 $c->add($c->getNewCriterion(ApplicationPeer::APP_INIT_USER, $sUIDUserLogged));
             } else {
                 $c->add($c->getNewCriterion(ApplicationPeer::APP_INIT_USER, $sUIDUserLogged)->addOr($c->getNewCriterion(AppDelegationPeer::USR_UID, $sUIDUserLogged)));
             }
             if (isset($aAdditionalFilter) && isset($aAdditionalFilter['APP_STATUS_FILTER'])) {
                 $c->add(ApplicationPeer::APP_STATUS, $sValue, Criteria::EQUAL);
             } else {
                 $c->add(ApplicationPeer::APP_STATUS, 'DRAFT', Criteria::NOT_EQUAL);
             }
             $c->add($c->getNewCriterion(AppDelegationPeer::DEL_THREAD_STATUS, 'CLOSED')->addOr($c->getNewCriterion(ApplicationPeer::APP_STATUS, 'COMPLETED')->addAnd($c->getNewCriterion(AppDelegationPeer::DEL_PREVIOUS, 0))));
             $c->add($c->getNewCriterion(ApplicationPeer::APP_UID, $aProcesses, Criteria::NOT_IN));
             $c->addDescendingOrderByColumn(ApplicationPeer::APP_NUMBER);
             break;
     }
     //select the xmlList to show
     if ($sTypeList == 'gral') {
         if ($RBAC->userCanAccess('PM_DELETECASE') == 1) {
             $xmlfile = $filesList['Alldelete'];
         } else {
             $xmlfile = $filesList['all'];
         }
     } else {
         $xmlfile = $filesList[$sTypeList];
     }
     if ($ClearSession) {
         //OPCION_1: claening the $_SESSION and updating the List.... only case List
         foreach ($filesList as $file) {
             $id = G::createUID('', $file . '.xml');
             unset($_SESSION['pagedTable[' . $id . ']']);
             unset($_SESSION[$id]);
         }
         //OPTION_2: cleaning the $_SESSION and whole List and xmls
         $cur = array_keys($_SESSION);
         foreach ($cur as $key) {
             if (substr($key, 0, 11) === "pagedTable[") {
                 unset($_SESSION[$key]);
             } else {
                 $xml = G::getUIDName($key, '');
                 if (strpos($xml, '.xml') !== false) {
                     unset($_SESSION[$key]);
                 }
             }
         }
     }
     return array($c, $xmlfile);
 }
 /**
  * Method to do selects.
  *
  * @param      Criteria $criteria The Criteria object used to build the SELECT statement.
  * @param      Connection $con
  * @return     array Array of selected Objects
  * @throws     PropelException Any exceptions caught during processing will be
  *       rethrown wrapped into a PropelException.
  */
 public static function doSelect(Criteria $criteria, $con = null)
 {
     return ProcessUserPeer::populateObjects(ProcessUserPeer::doSelectRS($criteria, $con));
 }
示例#9
0
                $u = $user->load($data['USR_REPLACED_BY']);
                $c = new Configurations();
                $replaced_by = $c->usersNameFormat($u['USR_USERNAME'], $u['USR_FIRSTNAME'], $u['USR_LASTNAME']);
            } else {
                $replaced_by = '';
            }
            $misc = array();
            $misc['DEP_TITLE'] = $dep_name;
            $misc['REPLACED_NAME'] = $replaced_by;
            echo '{success: true, userdata: ' . G::json_encode($data) . ', cases: ' . G::json_encode($aCount) . ', misc: ' . G::json_encode($misc) . '}';
            break;
        case "verifyIfUserAssignedAsSupervisor":
            $supervisorUserUid = $_POST["supervisorUserUid"];
            $message = "OK";
            $criteria = new Criteria("workflow");
            $criteria->addSelectColumn(ProcessUserPeer::PU_UID);
            $criteria->add(ProcessUserPeer::USR_UID, $supervisorUserUid, Criteria::EQUAL);
            $criteria->add(ProcessUserPeer::PU_TYPE, "SUPERVISOR", Criteria::EQUAL);
            $rsCriteria = ProcessUserPeer::doSelectRS($criteria);
            $rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);
            if ($rsCriteria->next()) {
                $message = "ERROR";
            }
            $response = array();
            $response["result"] = $message;
            echo G::json_encode($response);
            break;
    }
} catch (Exception $oException) {
    die($oException->getMessage());
}
 /**
  * Assign a supervisor of a process
  *
  * @param string $sProcessUID
  * @param string $sUsrUID
  * @param string $sTypeUID
  * @access public
  */
 public function addProcessSupervisor($sProcessUID, $sUsrUID, $sTypeUID)
 {
     $sPuUIDT = array();
     $oProcessUser = new \ProcessUser ( );
     $oTypeAssigneeG = \GroupwfPeer::retrieveByPK( $sUsrUID );
     $oTypeAssigneeU = \UsersPeer::retrieveByPK( $sUsrUID );
     if (is_null( $oTypeAssigneeG ) && is_null( $oTypeAssigneeU ) ) {
         throw new \Exception(\G::LoadTranslation("ID_USER_DOES_NOT_CORRESPOND_TYPE", array($sUsrUID, $sTypeUID)));
     }
     if (is_null( $oTypeAssigneeG ) && ! is_null( $oTypeAssigneeU) ) {
         if ( "SUPERVISOR"!= $sTypeUID ) {
             throw new \Exception(\G::LoadTranslation("ID_USER_DOES_NOT_CORRESPOND_TYPE", array($sUsrUID, $sTypeUID)));
         }
     }
     if (! is_null( $oTypeAssigneeG ) && is_null( $oTypeAssigneeU ) ) {
         if ( "GROUP_SUPERVISOR" != $sTypeUID ) {
             throw new \Exception(\G::LoadTranslation("ID_USER_DOES_NOT_CORRESPOND_TYPE", array($sUsrUID, $sTypeUID)));
         }
     }
     // validate Groups
     $oCriteria = new \Criteria('workflow');
     $oCriteria->addSelectColumn(\ProcessUserPeer::PU_UID);
     $oCriteria->addSelectColumn(\ProcessUserPeer::USR_UID);
     $oCriteria->addAsColumn('GRP_TITLE', \ContentPeer::CON_VALUE);
     $aConditions [] = array(\ProcessUserPeer::USR_UID, \ContentPeer::CON_ID);
     $aConditions [] = array(\ContentPeer::CON_CATEGORY, \DBAdapter::getStringDelimiter().'GRP_TITLE'.\DBAdapter::getStringDelimiter());
     $aConditions [] = array(\ContentPeer::CON_LANG, \DBAdapter::getStringDelimiter().SYS_LANG.\DBAdapter::getStringDelimiter());
     $oCriteria->addJoinMC($aConditions, \Criteria::LEFT_JOIN);
     $oCriteria->add(\ProcessUserPeer::PU_TYPE, 'GROUP_SUPERVISOR');
     $oCriteria->add(\ProcessUserPeer::PRO_UID, $sProcessUID);
     $oCriteria->add(\ProcessUserPeer::USR_UID, $sUsrUID);
     $oCriteria->addAscendingOrderByColumn(\ContentPeer::CON_VALUE);
     $oDataset = \ProcessUserPeer::doSelectRS($oCriteria);
     $oDataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
     $oDataset->next();
     while ($aRow = $oDataset->getRow()) {
         $sPuUIDT = $aRow['PU_UID'];
         $oDataset->next();
     }
     // validate Users
     $oCriteria = new \Criteria('workflow');
     $oCriteria->addSelectColumn(\ProcessUserPeer::USR_UID);
     $oCriteria->addSelectColumn(\ProcessUserPeer::PU_UID);
     $oCriteria->addJoin(\ProcessUserPeer::USR_UID, \UsersPeer::USR_UID, \Criteria::LEFT_JOIN);
     $oCriteria->add(\ProcessUserPeer::PU_TYPE, 'SUPERVISOR');
     $oCriteria->add(\ProcessUserPeer::PRO_UID, $sProcessUID);
     $oCriteria->add(\ProcessUserPeer::USR_UID, $sUsrUID);
     $oCriteria->addAscendingOrderByColumn(\UsersPeer::USR_FIRSTNAME);
     $oDataset = \ProcessUserPeer::doSelectRS($oCriteria);
     $oDataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
     $oDataset->next();
     while ($aRow = $oDataset->getRow()) {
         $sPuUIDT = $aRow['PU_UID'];
         $oDataset->next();
     }
     if (sizeof($sPuUIDT) == 0) {
         $sPuUID = \G::generateUniqueID();
         $oProcessUser->create(array('PU_UID' => $sPuUID,
                                     'PRO_UID' => $sProcessUID,
                                     'USR_UID' => $sUsrUID,
                                     'PU_TYPE' => $sTypeUID));
         $oCriteria = $this->getProcessSupervisor($sProcessUID, $sPuUID);
         return $oCriteria;
     } else {
         throw new \Exception(\G::LoadTranslation("ID_RELATION_EXIST"));
     }
 }
示例#11
0
 /**
  * gets the TO_REVISE cases list criteria
  * param $userUid the current userUid
  * param $doCount if true this will return the criteria for count cases only
  * @return Criteria object $Criteria
  */
 public function getToRevise($userUid, $doCount)
 {
     require_once 'classes/model/ProcessUser.php';
     //adding configuration fields from the configuration options
     //and forming the criteria object
     $oCriteria = new Criteria('workflow');
     $oCriteria->add(ProcessUserPeer::USR_UID, $userUid);
     $oCriteria->add(ProcessUserPeer::PU_TYPE, 'SUPERVISOR');
     $oDataset = ProcessUserPeer::doSelectRS($oCriteria);
     $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
     $oDataset->next();
     $aProcesses = array();
     while ($aRow = $oDataset->getRow()) {
         $aProcesses[] = $aRow['PRO_UID'];
         $oDataset->next();
     }
     if ($doCount && !isset($this->confCasesList['PMTable']) && !empty($this->confCasesList['PMTable'])) {
         $c = new Criteria('workflow');
     } else {
         $c = $this->addPMFieldsToCriteria('todo');
     }
     $c->add(AppCacheViewPeer::PRO_UID, $aProcesses, Criteria::IN);
     $c->add(AppCacheViewPeer::APP_STATUS, 'TO_DO');
     $c->add(AppCacheViewPeer::DEL_FINISH_DATE, null, Criteria::ISNULL);
     $c->add(AppCacheViewPeer::APP_THREAD_STATUS, 'OPEN');
     $c->add(AppCacheViewPeer::DEL_THREAD_STATUS, 'OPEN');
     return $c;
 }