/** * Get count for all lists * * @return array * * @author Brayan Pereyra (Cochalo) <*****@*****.**> * @copyright Colosa - Bolivia * * @url GET /counters-lists */ public function doGetCountersLists() { try { $userId = $this->getUserId(); $lists = new \ProcessMaker\BusinessModel\Lists(); $response = $lists->getCounters($userId); return $response; } catch (\Exception $e) { throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); } }
/** * Get list counters * @return array * * @copyright Colosa - Bolivia * * @url GET /counters */ public function countersCases() { try { $userId = $this->getUserId(); $lists = new \ProcessMaker\BusinessModel\Lists(); $response = $lists->getCounters($userId); $result = $this->parserCountersCases($response); } catch (\Exception $e) { throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); } return $result; }
/** * 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; }