function adhocAssignUsersk($params) { G::LoadClass('groups'); G::LoadClass('tasks'); $oTasks = new Tasks(); $aAux = $oTasks->getGroupsOfTask($_SESSION['TASK'], 2); $aAdhocUsers = array(); $oGroups = new Groups(); foreach ($aAux as $aGroup) { $aUsers = $oGroups->getUsersOfGroup($aGroup['GRP_UID']); foreach ($aUsers as $aUser) { if ($aUser['USR_UID'] != $_SESSION['USER_LOGGED']) { $aAdhocUsers[] = $aUser['USR_UID']; } } } $aAux = $oTasks->getUsersOfTask($_SESSION['TASK'], 2); foreach ($aAux as $aUser) { if ($aUser['USR_UID'] != $_SESSION['USER_LOGGED']) { $aAdhocUsers[] = $aUser['USR_UID']; } } require_once 'classes/model/Users.php'; $oCriteria = new Criteria('workflow'); $oCriteria->addSelectColumn(UsersPeer::USR_UID); $oCriteria->addSelectColumn(UsersPeer::USR_FIRSTNAME); $oCriteria->addSelectColumn(UsersPeer::USR_LASTNAME); $oCriteria->add(UsersPeer::USR_UID, $aAdhocUsers, Criteria::IN); $oDataset = UsersPeer::doSelectRS($oCriteria); $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $aData = array(); while ($oDataset->next()) { $aData[] = $oDataset->getRow(); } $this->data = $aData; }
/** * Return an assignee list of an activity * * @param string $processUid * @param string $taskUid * @param string $option * @param int $taskUserType * @param array $arrayFilterData * @param int $start * @param int $limit * @param string $type * * return array */ public function getTaskAssignees($processUid, $taskUid, $option, $taskUserType, $arrayFilterData = null, $start = null, $limit = null, $type = null) { try { $arrayAssignee = array(); $numRecTotal = 0; $startbk = $start; $limitbk = $limit; //Verify data $process = new \ProcessMaker\BusinessModel\Process(); $process->throwExceptionIfDataNotMetPagerVarDefinition(array("start" => $start, "limit" => $limit), array("start" => "start", "limit" => "limit")); $arrayFieldDefinition = array("OPTION" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array("ASSIGNEE", "AVAILABLE"), "fieldNameAux" => "option"), "TASK_USER_TYPE" => array("type" => "int", "required" => true, "empty" => false, "defaultValues" => array(1, 2), "fieldNameAux" => "taskUserType")); $process->throwExceptionIfDataNotMetFieldDefinition(array("OPTION" => $option, "TASK_USER_TYPE" => $taskUserType), $arrayFieldDefinition, array("option" => "option", "taskUserType" => "taskUserType"), false); //Set variables $filterName = "filter"; if (!is_null($arrayFilterData) && is_array($arrayFilterData) && isset($arrayFilterData["filter"])) { $arrayAux = array("" => "filter", "LEFT" => "lfilter", "RIGHT" => "rfilter"); $filterName = $arrayAux[isset($arrayFilterData["filterOption"]) ? $arrayFilterData["filterOption"] : ""]; } //Get data if (!is_null($limit) && $limit . "" == "0") { //Return return array("total" => $numRecTotal, "start" => (int) (!is_null($startbk) ? $startbk : 0), "limit" => (int) (!is_null($limitbk) ? $limitbk : 0), $filterName => !is_null($arrayFilterData) && is_array($arrayFilterData) && isset($arrayFilterData["filter"]) ? $arrayFilterData["filter"] : "", "data" => $arrayAssignee); } //Verify data $process->throwExceptionIfNotExistsProcess($processUid, "prj_uid"); $this->throwExceptionIfNotExistsTask($processUid, $taskUid, "act_uid"); //Set variables $numRecTotalGroup = 0; $numRecTotalUser = 0; switch ($option) { case "ASSIGNEE": break; case "AVAILABLE": $task = new \Tasks(); $arrayGroupUid = array(); foreach ($task->getGroupsOfTask($taskUid, $taskUserType) as $value) { $arrayGroupUid[] = $value['GRP_UID']; } $arrayUserUid = array(); foreach ($task->getUsersOfTask($taskUid, $taskUserType) as $value) { $arrayUserUid[] = $value['USR_UID']; } break; } //Groups //Query if (empty($type) || $type == "group") { $criteriaGroup = new \Criteria("workflow"); $criteriaGroup->addSelectColumn(\GroupwfPeer::GRP_UID); $criteriaGroup->addAsColumn("GRP_TITLE", \ContentPeer::CON_VALUE); switch ($option) { case "ASSIGNEE": $criteriaGroup->addJoin(\TaskUserPeer::USR_UID, \GroupwfPeer::GRP_UID, \Criteria::LEFT_JOIN); $criteriaGroup->add(\TaskUserPeer::TAS_UID, $taskUid, \Criteria::EQUAL); $criteriaGroup->add(\TaskUserPeer::TU_TYPE, $taskUserType, \Criteria::EQUAL); $criteriaGroup->add(\TaskUserPeer::TU_RELATION, 2, \Criteria::EQUAL); break; case "AVAILABLE": $criteriaGroup->add(\GroupwfPeer::GRP_UID, $arrayGroupUid, \Criteria::NOT_IN); break; } $criteriaGroup->addJoin(\GroupwfPeer::GRP_UID, \ContentPeer::CON_ID, \Criteria::LEFT_JOIN); $criteriaGroup->add(\ContentPeer::CON_CATEGORY, "GRP_TITLE", \Criteria::EQUAL); $criteriaGroup->add(\ContentPeer::CON_LANG, SYS_LANG, \Criteria::EQUAL); if (!is_null($arrayFilterData) && is_array($arrayFilterData) && isset($arrayFilterData["filter"]) && trim($arrayFilterData["filter"]) != "") { $arraySearch = array("" => "%" . $arrayFilterData["filter"] . "%", "LEFT" => $arrayFilterData["filter"] . "%", "RIGHT" => "%" . $arrayFilterData["filter"]); $search = $arraySearch[isset($arrayFilterData["filterOption"]) ? $arrayFilterData["filterOption"] : ""]; $criteriaGroup->add(\ContentPeer::CON_VALUE, $search, \Criteria::LIKE); } $criteriaGroup->add(\GroupwfPeer::GRP_STATUS, "ACTIVE", \Criteria::EQUAL); //Number records total $criteriaCount = clone $criteriaGroup; $criteriaCount->clearSelectColumns(); $criteriaCount->addSelectColumn("COUNT(" . \GroupwfPeer::GRP_UID . ") AS NUM_REC"); switch ($option) { case "ASSIGNEE": $rsCriteriaCount = \TaskUserPeer::doSelectRS($criteriaCount); break; case "AVAILABLE": $rsCriteriaCount = \GroupwfPeer::doSelectRS($criteriaCount); break; } $rsCriteriaCount->setFetchmode(\ResultSet::FETCHMODE_ASSOC); $result = $rsCriteriaCount->next(); $row = $rsCriteriaCount->getRow(); $numRecTotalGroup = (int) $row["NUM_REC"]; $numRecTotal = $numRecTotal + $numRecTotalGroup; } //Users //Query if (empty($type) || $type == "user") { $criteriaUser = new \Criteria("workflow"); $criteriaUser->addSelectColumn(\UsersPeer::USR_UID); $criteriaUser->addSelectColumn(\UsersPeer::USR_USERNAME); $criteriaUser->addSelectColumn(\UsersPeer::USR_FIRSTNAME); $criteriaUser->addSelectColumn(\UsersPeer::USR_LASTNAME); switch ($option) { case "ASSIGNEE": $criteriaUser->addJoin(\TaskUserPeer::USR_UID, \UsersPeer::USR_UID, \Criteria::LEFT_JOIN); $criteriaUser->add(\TaskUserPeer::TAS_UID, $taskUid, \Criteria::EQUAL); $criteriaUser->add(\TaskUserPeer::TU_TYPE, $taskUserType, \Criteria::EQUAL); $criteriaUser->add(\TaskUserPeer::TU_RELATION, 1, \Criteria::EQUAL); break; case "AVAILABLE": $criteriaUser->add(\UsersPeer::USR_UID, $arrayUserUid, \Criteria::NOT_IN); break; } if (!is_null($arrayFilterData) && is_array($arrayFilterData) && isset($arrayFilterData["filter"]) && trim($arrayFilterData["filter"]) != "") { $arraySearch = array("" => "%" . $arrayFilterData["filter"] . "%", "LEFT" => $arrayFilterData["filter"] . "%", "RIGHT" => "%" . $arrayFilterData["filter"]); $search = $arraySearch[isset($arrayFilterData["filterOption"]) ? $arrayFilterData["filterOption"] : ""]; $criteriaUser->add($criteriaUser->getNewCriterion(\UsersPeer::USR_USERNAME, $search, \Criteria::LIKE)->addOr($criteriaUser->getNewCriterion(\UsersPeer::USR_FIRSTNAME, $search, \Criteria::LIKE))->addOr($criteriaUser->getNewCriterion(\UsersPeer::USR_LASTNAME, $search, \Criteria::LIKE))); } $criteriaUser->add(\UsersPeer::USR_STATUS, "ACTIVE", \Criteria::EQUAL); //Number records total $criteriaCount = clone $criteriaUser; $criteriaCount->clearSelectColumns(); $criteriaCount->addSelectColumn("COUNT(" . \UsersPeer::USR_UID . ") AS NUM_REC"); switch ($option) { case "ASSIGNEE": $rsCriteriaCount = \TaskUserPeer::doSelectRS($criteriaCount); break; case "AVAILABLE": $rsCriteriaCount = \UsersPeer::doSelectRS($criteriaCount); break; } $rsCriteriaCount->setFetchmode(\ResultSet::FETCHMODE_ASSOC); $result = $rsCriteriaCount->next(); $row = $rsCriteriaCount->getRow(); $numRecTotalUser = (int) $row["NUM_REC"]; $numRecTotal = $numRecTotal + $numRecTotalUser; } //Groups //Query if (empty($type) || $type == "group") { $criteriaGroup->addAscendingOrderByColumn("GRP_TITLE"); if (!is_null($start)) { $criteriaGroup->setOffset((int) $start); } if (!is_null($limit)) { $criteriaGroup->setLimit((int) $limit); } switch ($option) { case "ASSIGNEE": $rsCriteriaGroup = \TaskUserPeer::doSelectRS($criteriaGroup); break; case "AVAILABLE": $rsCriteriaGroup = \GroupwfPeer::doSelectRS($criteriaGroup); break; } $rsCriteriaGroup->setFetchmode(\ResultSet::FETCHMODE_ASSOC); $numRecGroup = 0; while ($rsCriteriaGroup->next()) { $row = $rsCriteriaGroup->getRow(); $criteria2 = new \Criteria("workflow"); $criteria2->addSelectColumn("COUNT(" . \GroupUserPeer::GRP_UID . ") AS NUM_MEM"); $criteria2->add(\GroupUserPeer::GRP_UID, $row["GRP_UID"], \Criteria::EQUAL); $rsCriteria2 = \GroupUserPeer::doSelectRS($criteria2); $rsCriteria2->setFetchmode(\ResultSet::FETCHMODE_ASSOC); $result = $rsCriteria2->next(); $row2 = $rsCriteria2->getRow(); $row["GRP_TITLE"] = $row["GRP_TITLE"] . " (" . $row2["NUM_MEM"] . " " . \G::LoadTranslation((int) $row2["NUM_MEM"] == 1 ? "ID_USER" : "ID_USERS") . ")"; $arrayAssignee[] = $this->getTaskAssigneeDataFromRecord(array($row["GRP_UID"], $row["GRP_TITLE"], "", $row["GRP_TITLE"], "group"), $taskUserType); $numRecGroup++; } } //Users //Query if (empty($type) || $type == "user") { $flagUser = true; if ($numRecTotalGroup > 0) { if ($numRecGroup > 0) { if (!is_null($limit)) { if ($numRecGroup < (int) $limit) { $start = 0; $limit = $limit - $numRecGroup; } else { $flagUser = false; } } else { $start = 0; } } else { $start = (int) $start - $numRecTotalGroup; } } if ($flagUser) { //Users //Query $criteriaUser->addAscendingOrderByColumn(\UsersPeer::USR_FIRSTNAME); if (!is_null($start)) { $criteriaUser->setOffset((int) $start); } if (!is_null($limit)) { $criteriaUser->setLimit((int) $limit); } switch ($option) { case "ASSIGNEE": $rsCriteriaUser = \TaskUserPeer::doSelectRS($criteriaUser); break; case "AVAILABLE": $rsCriteriaUser = \UsersPeer::doSelectRS($criteriaUser); break; } $rsCriteriaUser->setFetchmode(\ResultSet::FETCHMODE_ASSOC); while ($rsCriteriaUser->next()) { $row = $rsCriteriaUser->getRow(); $arrayAssignee[] = $this->getTaskAssigneeDataFromRecord(array($row["USR_UID"], $row["USR_FIRSTNAME"], $row["USR_LASTNAME"], $row["USR_USERNAME"], "user"), $taskUserType); } } } //Return return array("total" => $numRecTotal, "start" => (int) (!is_null($startbk) ? $startbk : 0), "limit" => (int) (!is_null($limitbk) ? $limitbk : 0), $filterName => !is_null($arrayFilterData) && is_array($arrayFilterData) && isset($arrayFilterData["filter"]) ? $arrayFilterData["filter"] : "", "data" => $arrayAssignee); } catch (\Exception $e) { throw $e; } }
$aCasesList = array(); foreach ($APP_UIDS as $APP_UID) { $aCase = $oCases->loadCaseInCurrentDelegation($APP_UID, true); $aUsersInvolved = array(); $aCaseGroups = $oTasks->getGroupsOfTask($aCase['TAS_UID'], 1); foreach ($aCaseGroups as $aCaseGroup) { $aCaseUsers = $oGroups->getUsersOfGroup($aCaseGroup['GRP_UID']); foreach ($aCaseUsers as $aCaseUser) { if ($aCaseUser['USR_UID'] != $sReassignFromUser) { $aCaseUserRecord = $oUser->load($aCaseUser['USR_UID']); $aUsersInvolved[$aCaseUser['USR_UID']] = $aCaseUserRecord['USR_FIRSTNAME'] . ' ' . $aCaseUserRecord['USR_LASTNAME']; // . ' (' . $aCaseUserRecord['USR_USERNAME'] . ')'; } } } $aCaseUsers = $oTasks->getUsersOfTask($aCase['TAS_UID'], 1); foreach ($aCaseUsers as $aCaseUser) { if ($aCaseUser['USR_UID'] != $sReassignFromUser) { $aCaseUserRecord = $oUser->load($aCaseUser['USR_UID']); $aUsersInvolved[$aCaseUser['USR_UID']] = $aCaseUserRecord['USR_FIRSTNAME'] . ' ' . $aCaseUserRecord['USR_LASTNAME']; // . ' (' . $aCaseUserRecord['USR_USERNAME'] . ')'; } } $oTmp = new stdClass(); $oTmp->items = $aUsersInvolved; $oTmp->id = $aCase['APP_UID']; $aCase['USERS'] = $oTmp; array_push($aCasesList, $aCase); } $filedNames = array("APP_UID", "APP_NUMBER", "APP_UPDATE_DATE", "DEL_PRIORITY", "DEL_INDEX", "TAS_UID", "DEL_INIT_DATE", "DEL_FINISH_DATE", "USR_UID", "APP_STATUS", "DEL_TASK_DUE_DATE", "APP_CURRENT_USER", "APP_TITLE", "APP_PRO_TITLE", "APP_TAS_TITLE", "APP_DEL_PREVIOUS_USER", "USERS"); $aCasesList = array_merge(array($filedNames), $aCasesList);
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; }
/** * Send Message each user id * * @param array $request_data * @author Ronald Quenta <*****@*****.**> * */ public function routeCaseNotification($currentUserId, $processId, $currentTaskId, $appFields, $aTasks, $nextIndex) { try { $oUser = new \Users(); $aUser = $oUser->load( $currentUserId ); $response = array(); $task = new \Tasks(); $group = new \Groups(); foreach ($aTasks as $aTask) { $arrayTaskUser = array(); switch ($aTask["TAS_ASSIGN_TYPE"]) { case "SELF_SERVICE": if (isset($aTask["TAS_UID"]) && !empty($aTask["TAS_UID"])) { $arrayAux1 = $task->getGroupsOfTask($aTask["TAS_UID"], 1); foreach ($arrayAux1 as $arrayGroup) { $arrayAux2 = $group->getUsersOfGroup($arrayGroup["GRP_UID"]); foreach ($arrayAux2 as $arrayUser) { $arrayTaskUser[] = $arrayUser["USR_UID"]; } } $arrayAux1 = $task->getUsersOfTask($aTask["TAS_UID"], 1); foreach ($arrayAux1 as $arrayUser) { $arrayTaskUser[] = $arrayUser["USR_UID"]; } } break; default: if (isset($aTask["USR_UID"]) && !empty($aTask["USR_UID"])) { $arrayTaskUser = $aTask["USR_UID"]; } break; } // $oTask = new \Task(); // $currentTask = $oTask->load($aTask['TAS_UID']); $delIndex = null; foreach ($nextIndex as $nIndex) { if($aTask['TAS_UID'] == $nIndex['TAS_UID']){ $delIndex = $nIndex['DEL_INDEX']; break; } } $userIds = $arrayTaskUser; $message = '#'. $appFields['APP_NUMBER'] . ' : '.$appFields['APP_TITLE']; $data = array( 'processId' => $processId, 'taskId' => $aTask["TAS_UID"], 'caseId' => $appFields['APP_UID'], 'caseTitle' => $appFields['APP_TITLE'], 'delIndex' => $delIndex, 'typeList' => 'todo' ); if ($userIds) { $oNoti = new \NotificationDevice(); $devices = array(); if (is_array($userIds)){ foreach ($userIds as $id) { $deviceUser = $oNoti->loadByUsersId($id); $devices = array_merge($devices, $deviceUser); } } else { $devices = $oNoti->loadByUsersId($userIds); $lists = new \ProcessMaker\BusinessModel\Lists(); $counter = $lists->getCounters($userIds); $light = new \ProcessMaker\Services\Api\Light(); $result = $light->parserCountersCases($counter); $data['counters'] = $result; } $devicesAndroidIds = array(); $devicesAppleIds = array(); foreach ($devices as $dev) { switch ($dev['DEV_TYPE']) { case "apple": $devicesAppleIds[] = $dev['DEV_REG_ID']; break; case "android": $devicesAndroidIds[] = $dev['DEV_REG_ID']; break; } } if (count($devicesAppleIds) > 0) { $oNotification = new PushMessageIOS(); $oNotification->setSettingNotification(); $oNotification->setDevices($devicesAppleIds); $response['apple'] = $oNotification->send($message, $data); } if (count($devicesAndroidIds) > 0) { $oNotification = new PushMessageAndroid(); $oNotification->setSettingNotification(); $oNotification->setDevices($devicesAndroidIds); $response['android'] = $oNotification->send($message, $data); } } } } catch (\Exception $e) { throw new \Exception(\Api::STAT_APP_EXCEPTION, $e->getMessage()); } return $response; }
public function getExtAvailableUsersList($sTaskUID = '', $iType = 2) { try { $oTasks = new Tasks(); $aAux = $oTasks->getGroupsOfTask($sTaskUID, $iType); $aUIDS1 = array(); $aUIDS2 = array(); foreach ($aAux as $aGroup) { $aUIDS1[] = $aGroup['GRP_UID']; } $aAux = $oTasks->getUsersOfTask($sTaskUID, $iType); foreach ($aAux as $aUser) { $aUIDS2[] = $aUser['USR_UID']; } $aUsers = array(); $aUsers[] = array('LABEL' => 'char', 'TAS_UID' => 'char', 'USR_UID' => 'char', 'TU_TYPE' => 'integer', 'TU_RELATION' => 'integer'); $sDelimiter = DBAdapter::getStringDelimiter(); $oCriteria = new Criteria('workflow'); $oCriteria->addSelectColumn(GroupwfPeer::GRP_UID); $oCriteria->addAsColumn('GRP_TITLE', 'C.CON_VALUE'); $oCriteria->addAlias('C', 'CONTENT'); $aConditions = array(); $aConditions[] = array(GroupwfPeer::GRP_UID, 'C.CON_ID'); $aConditions[] = array('C.CON_CATEGORY', $sDelimiter . 'GRP_TITLE' . $sDelimiter); $aConditions[] = array('C.CON_LANG', $sDelimiter . SYS_LANG . $sDelimiter); $oCriteria->addJoinMC($aConditions, Criteria::LEFT_JOIN); $oCriteria->add(GroupwfPeer::GRP_STATUS, 'ACTIVE'); $oCriteria->add(GroupwfPeer::GRP_UID, $aUIDS1, Criteria::NOT_IN); //$oCriteria->add(GroupwfPeer::GRP_UID, '', Criteria::NOT_EQUAL); $oDataset = GroupwfPeer::doSelectRS($oCriteria); $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); $c = 0; while ($aRow = $oDataset->getRow()) { $c++; $oCriteria = new Criteria('workflow'); $oCriteria->addSelectColumn('COUNT(*) AS MEMBERS_NUMBER'); $oCriteria->add(GroupUserPeer::GRP_UID, $aRow['GRP_UID']); $oDataset2 = GroupUserPeer::doSelectRS($oCriteria); $oDataset2->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset2->next(); $aRow2 = $oDataset2->getRow(); $aUsers[] = array('LABEL' => $aRow['GRP_TITLE'] . ' <a href="#" onclick="usersGroup(\'' . $aRow['GRP_UID'] . '\', \'' . $c . '\');return false;"><font color="green"><strong>(' . $aRow2['MEMBERS_NUMBER'] . ' ' . ((int) $aRow2['MEMBERS_NUMBER'] == 1 ? G::LoadTranslation('ID_USER') : G::LoadTranslation('ID_USERS')) . ')</strong></font></a> <br /><div id="users' . $c . '" style="display: none"></div>', 'TAS_UID' => $sTaskUID, 'USR_UID' => $aRow['GRP_UID'], 'TU_TYPE' => $iType, 'TU_RELATION' => 2); $oDataset->next(); } $sDelimiter = DBAdapter::getStringDelimiter(); $oCriteria = new Criteria('workflow'); $oCriteria->addSelectColumn(UsersPeer::USR_UID); $oCriteria->addSelectColumn(UsersPeer::USR_FIRSTNAME); $oCriteria->addSelectColumn(UsersPeer::USR_LASTNAME); $oCriteria->add(UsersPeer::USR_STATUS, 'ACTIVE'); $oCriteria->add(UsersPeer::USR_UID, $aUIDS2, Criteria::NOT_IN); $oDataset = UsersPeer::doSelectRS($oCriteria); $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC); $oDataset->next(); while ($aRow = $oDataset->getRow()) { $aUsers[] = array('LABEL' => $aRow['USR_FIRSTNAME'] . ' ' . $aRow['USR_LASTNAME'], 'TAS_UID' => $sTaskUID, 'USR_UID' => $aRow['USR_UID'], 'TU_TYPE' => $iType, 'TU_RELATION' => 1); $oDataset->next(); } global $_DBArray; $_DBArray = isset($_SESSION['_DBArray']) ? $_SESSION['_DBArray'] : ''; $_DBArray['availableUsers'] = $aUsers; $_SESSION['_DBArray'] = $_DBArray; return $_SESSION['_DBArray']['availableUsers']; } catch (Exception $oError) { throw $oError; } }
public function getUsersToReassign($TAS_UID, $USR_UID) { 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']; } } $aAux = $oTasks->getUsersOfTask($TAS_UID, 2); foreach ($aAux as $aUser) { if ($aUser['USR_UID'] != $USR_UID) { $row[] = $aUser['USR_UID']; } } require_once 'classes/model/Users.php'; $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(); } return $rows; }
} $aUsers = array($_GET['USR_UID']); $aAux1 = $oTasks->getGroupsOfTask($aRow['TAS_UID'], 1); foreach ($aAux1 as $aGroup) { $aAux2 = $oGroups->getUsersOfGroup($aGroup['GRP_UID']); foreach ($aAux2 as $aUser) { if (!in_array($aUser['USR_UID'], $aUsers)) { $aUsers[] = $aUser['USR_UID']; $aData = $oUser->load($aUser['USR_UID']); $oTemplatePower->newBlock('users'); $oTemplatePower->assign('USR_UID', $aUser['USR_UID']); $oTemplatePower->assign('USR_FULLNAME', $aData['USR_FIRSTNAME'] . ' ' . $aData['USR_LASTNAME'] . ' (' . $aData['USR_USERNAME'] . ')'); } } } $aAux1 = $oTasks->getUsersOfTask($aRow['TAS_UID'], 1); foreach ($aAux1 as $aUser) { if (!in_array($aUser['USR_UID'], $aUsers)) { $aUsers[] = $aUser['USR_UID']; $aData = $oUser->load($aUser['USR_UID']); $oTemplatePower->newBlock('users'); $oTemplatePower->assign('USR_UID', $aUser['USR_UID']); $oTemplatePower->assign('USR_FULLNAME', $aData['USR_FIRSTNAME'] . ' ' . $aData['USR_LASTNAME'] . ' (' . $aData['USR_USERNAME'] . ')'); } } $oTemplatePower->gotoBlock('cases'); $oTemplatePower->assign('ID_STATUS', G::LoadTranslation('ID_TO_DO')); $oTemplatePower->assign('ID_NO_REASSIGN', G::LoadTranslation('ID_NO_REASSIGN')); $oDataset->next(); } $oDataset = ApplicationPeer::doSelectRS($oCriteriaDraft);
/** * Return the available adhoc users and users groups to assigned to an activity * * @param string $sProcessUID {@min 32} {@max 32} * @param string $sTaskUID {@min 32} {@max 32} * @param string $filter * @param int $start * @param int $limit * @param string $type * * return array * * @access public */ public function getTaskAvailableAdhocAssignee($sProcessUID, $sTaskUID, $filter, $start, $limit, $type) { try { require_once (PATH_RBAC_HOME . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "RbacUsers.php"); require_once (PATH_TRUNK . "workflow" . PATH_SEP . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "TaskUser.php"); require_once (PATH_TRUNK . "workflow" . PATH_SEP . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "GroupUser.php"); Validator::proUid($sProcessUID, '$prj_uid'); $this->validateActUid($sTaskUID); $iType = 2; $oTasks = new \Tasks(); $aAux = $oTasks->getGroupsOfTask($sTaskUID, $iType); $aUIDS1 = array(); $aUIDS2 = array(); foreach ($aAux as $aGroup) { $aUIDS1[] = $aGroup['GRP_UID']; } $aAux = $oTasks->getUsersOfTask($sTaskUID, $iType); foreach ($aAux as $aUser) { $aUIDS2[] = $aUser['USR_UID']; } $aUsers = array(); $c = 0; $oTasks = new \Tasks(); $aAux = $oTasks->getGroupsOfTask($sTaskUID, 2); $aUIDS1 = array(); foreach ($aAux as $aGroup) { $aUIDS1[] = $aGroup['GRP_UID']; } $criteria = new \Criteria( 'workflow' ); $criteria->addSelectColumn( \GroupwfPeer::GRP_UID ); $criteria->addSelectColumn( \GroupwfPeer::GRP_STATUS ); $criteria->addSelectColumn( \GroupwfPeer::GRP_UX ); $criteria->add(\GroupwfPeer::GRP_STATUS, "ACTIVE", \Criteria::EQUAL); $criteria->addAsColumn( 'GRP_TITLE', \ContentPeer::CON_VALUE ); $criteria->addJoin( \GroupwfPeer::GRP_UID, \ContentPeer::CON_ID, \Criteria::LEFT_JOIN ); $criteria->add( \ContentPeer::CON_CATEGORY, 'GRP_TITLE' ); $criteria->add( \ContentPeer::CON_LANG, SYS_LANG ); $criteria->addAscendingOrderByColumn( \ContentPeer::CON_VALUE ); if ($filter != '') { $criteria->add( \ContentPeer::CON_VALUE, '%' . $filter . '%', \Criteria::LIKE ); } $oDataset = \GroupwfPeer::doSelectRS( $criteria ); $oDataset->setFetchmode( \ResultSet::FETCHMODE_ASSOC ); $groups = array (); while ($oDataset->next()) { $groups[] = $oDataset->getRow(); } $result = array ('rows' => $groups); foreach ($result['rows'] as $results) { if (! in_array($results['GRP_UID'], $aUIDS1)) { $c++; $oCriteria = new \Criteria('workflow'); $oCriteria->addSelectColumn('COUNT(*) AS MEMBERS_NUMBER'); $oCriteria->add(\GroupUserPeer::GRP_UID, $results['GRP_UID']); $oDataset2 = \GroupUserPeer::doSelectRS($oCriteria); $oDataset2->setFetchmode(\ResultSet::FETCHMODE_ASSOC); $oDataset2->next(); $aRow2 = $oDataset2->getRow(); if ($type == '' || $type == 'group') { $aUsers[] = array('ada_uid' => $results['GRP_UID'], 'ada_name' => (!isset($aRow2['GROUP_INACTIVE']) ? $results['GRP_TITLE'] . ' (' . $aRow2['MEMBERS_NUMBER'] . ' ' . ((int) $aRow2['MEMBERS_NUMBER'] == 1 ? \G::LoadTranslation('ID_USER') : \G::LoadTranslation('ID_USERS')). ')' . '' : $results['GRP_TITLE'] . ' ' . $aRow2['GROUP_INACTIVE']), 'ada_lastname' => "", 'ada_username' => "", 'ada_type' => "group" ); } } } $oCriteria = new \Criteria('workflow'); $oCriteria->addSelectColumn(\UsersPeer::USR_UID); $oCriteria->addSelectColumn(\UsersPeer::USR_USERNAME); $oCriteria->addSelectColumn(\UsersPeer::USR_FIRSTNAME); $oCriteria->addSelectColumn(\UsersPeer::USR_LASTNAME); $oCriteria->addSelectColumn(\UsersPeer::USR_EMAIL); if ($filter != '') { $oCriteria->add( $oCriteria->getNewCriterion( \UsersPeer::USR_USERNAME, "%$filter%", \Criteria::LIKE )->addOr( $oCriteria->getNewCriterion( \UsersPeer::USR_FIRSTNAME, "%$filter%", \Criteria::LIKE ) )->addOr( $oCriteria->getNewCriterion( \UsersPeer::USR_LASTNAME, "%$filter%", \Criteria::LIKE ) ) ); } $oCriteria->add(\UsersPeer::USR_STATUS, 'ACTIVE'); $oCriteria->add(\UsersPeer::USR_UID, $aUIDS2, \Criteria::NOT_IN); $oDataset = \UsersPeer::doSelectRS($oCriteria); $oDataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC); $oDataset->next(); while ($aRow = $oDataset->getRow()) { if ($type == '' || $type == 'user') { $aUsers[] = array('ada_uid' => $aRow['USR_UID'], 'ada_name' => $aRow['USR_FIRSTNAME'], 'ada_lastname' => $aRow['USR_LASTNAME'], 'ada_username' => $aRow['USR_USERNAME'], 'ada_type' => "user" ); } $oDataset->next(); } if ($start) { if ($start < 0) { throw new \Exception(\G::LoadTranslation("ID_INVALID_START")); } } else { $start = 0; } if (isset($limit)) { if ($limit < 0) { throw new \Exception(\G::LoadTranslation("ID_INVALID_LIMIT")); } else { if ($limit == 0) { return array(); } } } else { $limit = count($aUsers) + 1; } $aUsers = $this->arrayPagination($aUsers, $start, $limit); return $aUsers; } catch (\Exception $e) { throw $e; } }
$aCaseGroups = $oTasks->getGroupsOfTask($TaskUid, 1); $oConf = new Configurations(); $ConfEnv = $oConf->getFormats(); foreach ($aCaseGroups as $aCaseGroup) { $aCaseUsers = $oGroups->getUsersOfGroup($aCaseGroup['GRP_UID']); foreach ($aCaseUsers as $aCaseUser) { if ($aCaseUser['USR_UID'] != $sReassignFromUser) { $aCaseUserRecord = $oUser->load($aCaseUser['USR_UID']); $sCaseUser = G::getFormatUserList($ConfEnv['format'], $aCaseUserRecord); // $aUsersInvolved[] = array ( 'userUid' => $aCaseUser['USR_UID'] , 'userFullname' => $aCaseUserRecord['USR_FIRSTNAME'] . ' ' . $aCaseUserRecord['USR_LASTNAME']); // . ' (' . $aCaseUserRecord['USR_USERNAME'] . ')'; $aUsersInvolved[] = array('userUid' => $aCaseUser['USR_UID'], 'userFullname' => $sCaseUser); // . ' (' . $aCaseUserRecord['USR_USERNAME'] . ')'; } } } $aCaseUsers = $oTasks->getUsersOfTask($TaskUid, 1); foreach ($aCaseUsers as $aCaseUser) { if ($aCaseUser['USR_UID'] != $sReassignFromUser) { $aCaseUserRecord = $oUser->load($aCaseUser['USR_UID']); $sCaseUser = G::getFormatUserList($ConfEnv['format'], $aCaseUserRecord); // $aUsersInvolved[] = array ( 'userUid' => $aCaseUser['USR_UID'] , 'userFullname' => $aCaseUserRecord['USR_FIRSTNAME'] . ' ' . $aCaseUserRecord['USR_LASTNAME']); // . ' (' . $aCaseUserRecord['USR_USERNAME'] . ')'; $aUsersInvolved[] = array('userUid' => $aCaseUser['USR_UID'], 'userFullname' => $sCaseUser); // . ' (' . $aCaseUserRecord['USR_USERNAME'] . ')'; } } // $oTmp = new stdClass(); // $oTmp->items = $aUsersInvolved; $result = array(); $aUsersInvolved = array_sort($aUsersInvolved, 'userFullname', SORT_ASC, $query); $result['data'] = $aUsersInvolved; print G::json_encode($result);
$aUsrUid = array(); $aAux1 = $oTasks->getGroupsOfTask($aRow['TAS_UID'], 1); foreach ($aAux1 as $value1) { $aAux2 = $oGroups->getUsersOfGroup($value1['GRP_UID']); foreach ($aAux2 as $value2) { if ($aRow['USR_UID'] != $value2['USR_UID']) { if (!in_array($value2['USR_UID'], $aUsrUid)) { //var_dump($aRow['USR_UID'], $value2['USR_UID']);echo '<br /><br />'; $aAux = $oUser->load($value2['USR_UID']); $aUsr[$aAux['USR_FIRSTNAME'] . ' ' . $aAux['USR_LASTNAME']] = $aAux; $aUsrUid[] = $value2['USR_UID']; } } } } $aUsers = $oTasks->getUsersOfTask($aRow['TAS_UID'], 1); foreach ($aUsers as $key => $value) { if ($aRow['USR_UID'] != $value['USR_UID']) { if (!in_array($value['USR_UID'], $aUsrUid)) { $aUsr[$value['USR_FIRSTNAME'] . ' ' . $value['USR_LASTNAME']] = $value; } } } ksort($aUsr); //$users=''; //$users='<select name="USERS"><option value="">Seleccione</option>'; foreach ($aUsr as $key => $value) { $tpl->newBlock("users"); $name = $value['USR_FIRSTNAME'] . ' ' . $value['USR_LASTNAME'] . ' (' . $value['USR_USERNAME'] . ')'; //$users=$users."<option value='".$value['USR_UID']."'>". $name ."</option>"; $tpl->assign("USR_UID", $value['USR_UID']);
public function getTaskUserSelfService($tas_uid, $appFields) { $oTask = new \Tasks(); $oGroup = new \Groups(); $taskNextDel = \TaskPeer::retrieveByPK($tas_uid); $arrayTaskUser = array(); if ($taskNextDel->getTasAssignType() == "SELF_SERVICE" && trim($taskNextDel->getTasGroupVariable()) != "") { // Self Service Value Based Assignment $nextTaskGroupVariable = trim($taskNextDel->getTasGroupVariable(), " @#"); if (isset($appFields["APP_DATA"][$nextTaskGroupVariable])) { $dataGroupVariable = $appFields["APP_DATA"][$nextTaskGroupVariable]; $dataGroupVariable = is_array($dataGroupVariable) ? $dataGroupVariable : trim($dataGroupVariable); if (!empty($dataGroupVariable) && is_array($dataGroupVariable)) { $arrayTaskUser[] = $dataGroupVariable; } elseif (!empty($dataGroupVariable)) { $arrayUsersOfGroup = $oGroup->getUsersOfGroup($dataGroupVariable); foreach ($arrayUsersOfGroup as $arrayUser) { $arrayTaskUser[] = $arrayUser["USR_UID"]; } } } } else { // Self Service $arrayGroupsOfTask = $oTask->getGroupsOfTask($tas_uid, 1); foreach ($arrayGroupsOfTask as $arrayGroup) { $arrayUsersOfGroup = $oGroup->getUsersOfGroup($arrayGroup["GRP_UID"]); foreach ($arrayUsersOfGroup as $arrayUser) { $arrayTaskUser[] = $arrayUser["USR_UID"]; } } $arrayUsersOfTask = $oTask->getUsersOfTask($tas_uid, 1); foreach ($arrayUsersOfTask as $arrayUser) { $arrayTaskUser[] = $arrayUser["USR_UID"]; } } return $arrayTaskUser; }