public function getContractAnnotations($contractId) { $annotationData = []; $contract = $this->annotation->getContractPagesWithAnnotations($contractId); foreach ($contract->annotations as $annotation) { $json = $annotation->annotation; $json->page = $annotation->document_page_no; $json->id = $annotation->id; $annotationData[] = $json; } return $annotationData; }
/** * Get Annotation status Count */ public function annotationStatusCount() { $draft = $this->annotation->getStatusCountByType(Annotation::DRAFT); $completed = $this->annotation->getStatusCountByType(Annotation::COMPLETED); $rejected = $this->annotation->getStatusCountByType(Annotation::REJECTED); $published = $this->annotation->getStatusCountByType(Annotation::PUBLISHED); $statusRaw = compact('draft', 'completed', 'rejected', 'published'); $contract = []; foreach ($statusRaw['draft'] as $key => $value) { $status = $this->annotation->checkStatus([$value->status, $statusRaw['completed'][$key]->status, $statusRaw['rejected'][$key]->status, $statusRaw['published'][$key]->status]); $status = empty($status) ? 'processing' : $status; $contract[$status][] = $value->id; } $count = []; foreach ($contract as $status => $ids) { $count[$status] = count($ids); } $default = ['draft' => 0, 'completed' => 0, 'rejected' => 0, 'published' => 0, 'processing' => 0]; return array_merge($default, $count); }