Exemple #1
0
 /**
  * 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()));
     }
 }
Exemple #2
0
    /**
     * Get list Cases Paused
     *
     * @copyright Colosa - Bolivia
     *
     * @url GET /paused
     */
    public function doGetCasesListPaused(
        $start = 0,
        $limit = 10,
        $sort = 'APP_PAUSED_DATE',
        $dir = 'DESC',
        $cat_uid = '',
        $pro_uid = '',
        $search = '',
        $filter = '',
        $date_from = '',
        $date_to = ''
    ) {
        try {
            $dataList['userId'] = $this->getUserId();
            $dataList['action'] = 'paused';
            $dataList['paged']  = true;

            $dataList['start']    = $start;
            $dataList['limit']    = $limit;
            $dataList['sort']     = $sort;
            $dataList['dir']      = $dir;
            $dataList['category'] = $cat_uid;
            $dataList['process']  = $pro_uid;
            $dataList['search']   = $search;
            $dataList['filter']   = $filter;
            $dataList['dateFrom'] = $date_from;
            $dataList['dateTo']   = $date_to;
            $lists = new \ProcessMaker\BusinessModel\Lists();
            $response = $lists->getList('paused', $dataList);
            $result = $this->parserDataParticipated($response['data']);
            return $result;
        } catch (\Exception $e) {
            throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
        }
    }
    /**
     * 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;
    }
Exemple #4
0
    /**
     * Get count list Unassigned
     *
     * @param string $category {@from path}
     * @param string $process {@from path}
     * @param string $search {@from path}
     * @param string $filter {@from path}
     * @param string $date_from {@from path}
     * @param string $date_to {@from path}
     * @return array
     *
     * @author Brayan Pereyra (Cochalo) <*****@*****.**>
     * @copyright Colosa - Bolivia
     *
     * @url GET /unassigned/total
     */
    public function doGetCountUnassigned(
        $category = '',
        $process = '',
        $search = '',
        $filter = '',
        $date_from = '',
        $date_to = ''
    ) {
        try {
            $dataList['userId'] = $this->getUserId();

            $dataList['category'] = $category;
            $dataList['process']  = $process;
            $dataList['search']   = $search;
            $dataList['filter']   = $filter;
            $dataList['dateFrom'] = $date_from;
            $dataList['dateTo']   = $date_to;

            $lists = new \ProcessMaker\BusinessModel\Lists();
            $response = $lists->getList('participated_history', $dataList, true);
            return $response;
        } catch (\Exception $e) {
            throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
        }
    }