columnsView; } /** * Get the data corresponding to List Inbox * * @return array */ public function getData() { // Start the query for get the cases related to the user $query = Delegation::query()->select($this->getColumnsView()); // Join with process $query->joinProcess(); // Join with users $query->joinUser(); // Join with application for add the initial scope for TO_DO cases $query->inbox($this->getUserId()); // Define a specific risk switch ($this->getRiskStatus()) { case 'ON_TIME': // Scope that search for the ON_TIME cases $query->onTime(); break; case 'AT_RISK': // Scope that search for the AT_RISK cases $query->atRisk(); break; case 'OVERDUE': // Scope that search for the OVERDUE cases $query->overdue(); break; } // Scope to search for an specific process if (!empty($this->getProcessId())) { $query->processId($this->getProcessId()); } // The order by clause $query->orderBy($this->getOrderByColumn(), $this->getOrderDirection()); // The limit by clause $query->offset($this->getOffset())->limit($this->getLimit()); //Execute the query $results = $query->get(); // Prepare the result $results->transform(function ($item, $key) { // Get priority label $priorityLabel = self::PRIORITIES[$item['DEL_PRIORITY']]; $item['DEL_PRIORITY_LABEL'] = G::LoadTranslation("ID_PRIORITY_{$priorityLabel}"); // Get task color label $item['TAS_COLOR'] = $this->getTaskColor($item['DEL_TASK_DUE_DATE']); $item['TAS_COLOR_LABEL'] = self::TASK_COLORS[$item['TAS_COLOR']]; // Apply the date format defined in environment $item['DEL_TASK_DUE_DATE_LABEL'] = applyMaskDateEnvironment($item['DEL_TASK_DUE_DATE']); $item['DEL_DELEGATE_DATE_LABEL'] = applyMaskDateEnvironment($item['DEL_DELEGATE_DATE']); return $item; }); return $results->values()->toArray(); } /** * Get the number of rows corresponding to the List Inbox * * @return int */ public function getCounter() { $query = Delegation::query()->select(); // Scope that sets the queries for List Inbox $query->inbox($this->getUserId()); // Return the number of rows return $query->count(); } }