public function listData(DataTable $dataTable, TranslatorInterface $translator) { $qb = QueryBuilder::select()->field('i.id', 'id')->field('i.name', 'name')->field('i.groupName', 'groupName')->field('s.id', 'status')->field('s.name', 'statusName')->field('s.label', 'statusLabel')->field('t.name', 'territory')->field('i.memberNum', 'memberNum')->field('i.percentCompleteness', 'percentCompleteness')->from(CoreTables::AREA_TBL, 'i')->join(CoreTables::TERRITORY_TBL, 't', QueryClause::clause('i.territoryId = t.id'))->join(CoreTables::AREA_STATUS_TBL, 's', QueryClause::clause('i.statusId = s.id'))->where(QueryClause::clause('i.projectId = :projectId', ':projectId', $this->project->getId())); if ($dataTable->hasFilter(AreaFilter::class) && $dataTable->getFilter()->isCategorySelected()) { $qb->join(CoreTables::GROUP_TBL, 'g', QueryClause::clause('g.id = i.groupId')); } $recordsTotal = QueryBuilder::copyWithoutFields($qb)->field('COUNT(i.id)', 'cnt')->where($dataTable->buildCountingCondition($qb->getWhere()))->fetchCell($this->conn); $recordsFiltered = QueryBuilder::copyWithoutFields($qb)->field('COUNT(i.id)', 'cnt')->where($dataTable->buildFetchingCondition($qb->getWhere()))->fetchCell($this->conn); $qb->postprocess(function ($row) use($translator) { $row['statusName'] = $translator->trans($row['statusName'], [], 'statuses'); $row['percentCompleteness'] .= '%'; return $row; }); $dataTable->processQuery($qb); return $dataTable->createAnswer($recordsTotal, $recordsFiltered, $qb->where($dataTable->buildFetchingCondition($qb->getWhere()))->fetchAll($this->conn)); }