/** * Move pdf file * * @param null $contract_id * @return bool */ public function movePdFToFolder($contract_id = null) { if (is_null($contract_id)) { $contracts = $this->contract->getProcessCompleted(); foreach ($contracts as $contract) { $file = $contract->file; $moveTo = sprintf('%s/%s', $contract->id, $contract->file); if ($this->contract->moveS3File($file, $moveTo)) { $this->info(sprintf('Contract %s : completed.', $contract_id)); continue; } $this->info(sprintf('Contract %s : failed.', $contract_id)); } return true; } $contract = $this->contract->find($contract_id); $file = $contract->file; $moveTo = sprintf('%s/%s', $contract->id, $contract->file); if ($this->contract->moveS3File($file, $moveTo)) { $this->info(sprintf('Contract %s : completed.', $contract_id)); return true; } $this->info(sprintf('Contract %s : failed.', $contract_id)); return true; }
/** * @param Request $request * @param UserService $user * @param ContractService $contract * @return \Illuminate\View\View */ public function index(Request $request, UserService $user, ContractService $contract) { $filter = $request->only('contract', 'user'); $activityLogs = $this->activity->getAll($filter); $users = $user->getList(); $contracts = $contract->getList(); return view('activitylog.index', compact('activityLogs', 'users', 'contracts')); }
/** * Display all the tasks for a specific contract * @param $contract_id * @return string */ public function process($contract_id) { $contract = $this->contract->findWithTasks($contract_id); $contract->tasks = $this->task->appendAssignment($contract->tasks); $tasks = $this->task->getTotalByStatus($contract_id); $tasks['total_pages'] = $contract->tasks->count(); if ($tasks['total_pending_approval'] > 0) { $this->mailer->send(['email' => $contract->created_user->email, 'name' => $contract->created_user->name], sprintf("Mturk assignments for your action for [%s]", $contract->title), 'mturk.email.notify', ['task' => $tasks, 'contract' => ['id' => $contract->id, 'title' => $contract->title]]); } }
/** * Text send to RC * * @param $contract_id * @return bool */ public function copyTextToRC($contract_id) { $tasks = $this->task->getAll($contract_id); foreach ($tasks as $task) { $this->page->saveText($contract_id, $task->page_no, $task->assignments->assignment->answer, false); } $contract = $this->contract->find($contract_id); $contract->mturk_status = Contract::MTURK_COMPLETE; $this->logger->info('Contract text updated from MTurk', ['Contract id' => $contract_id]); $this->logger->activity('mturk.log.sent_to_rc', null, $contract_id); return $contract->save(); }
/** * Execute the console command. */ public function fire() { $contracts = Contract::all(); foreach ($contracts as $key => $contract) { $contractDir = $contract->id; if ($this->storage->disk('s3')->exists("{$contractDir}/{$contract->file}")) { try { if ($this->renameS3ContractFileName($contract)) { $this->contract->updateFileName($contract); $this->info("done moving {$contractDir}/{$contract->file}"); } } catch (\Exception $e) { $message = $e->getMessage(); $this->error("error moving {$contractDir}/{$contract->file}:{$message}"); } } else { $this->error("{$contractDir}/{$contract->file} file does not exists"); } } $this->call('nrgi:bulkindex'); }
/** * Generate word file from console command * * @param $contract_id * @return bool */ protected function generateWordFile($contract_id) { if (is_null($contract_id)) { $contracts = $this->contract->getProcessCompleted(); if (!is_null($contracts)) { foreach ($contracts as $contract) { $this->generateWordFile($contract->id); } return true; } $this->info('Contract not found'); return false; } if ($this->contract->updateWordFile($contract_id)) { $this->info(sprintf('Contract %s : completed.', $contract_id)); return true; } else { $this->info(sprintf('Contract %s : failed.', $contract_id)); return false; } }
public function review(Request $request, $contractId) { try { $page = $this->pages->getText($contractId, $request->input('page', '1')); $action = $request->input('action', ''); $canEdit = $action == "edit" ? 'true' : 'false'; $contract = $this->contract->findWithPages($contractId); $pages = $contract->pages; } catch (\Exception $e) { return abort(404); } return view('contract.page.review', compact('contract', 'pages', 'page', 'canEdit', 'canAnnotate')); }
/** * Download Word File * * @param $contract_id */ public function download($contract_id) { $contract = $this->contract->find($contract_id); if (empty($contract)) { abort(404); } $text = $this->contract->getTextFromS3($contract->id, $contract->file); if (empty($text)) { abort(404); } $filename = sprintf('%s-%s', $contract->id, str_limit(str_slug($contract->title), 70)); header("Content-type: application/vnd.ms-wordx"); header("Content-Disposition: attachment;Filename={$filename}.doc"); $html = "<html>"; $html .= "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">"; $html .= "<body>"; $html .= $text; $html .= "</body>"; $html .= "</html>"; echo $html; exit; }
/** * Post contract annotations * * @param $id */ public function postAnnotation($id) { $contract = $this->contract->findWithAnnotations($id); $annotationData = []; $data = []; $annotations = $contract->annotations; foreach ($annotations as $annotation) { $json = $annotation->annotation; $json->id = $annotation->id; $json->contact_id = $contract->id; $json->metadata = $this->getMetadataForES($contract->metadata, true); $annotationData[] = $json; } $data['annotations'] = json_encode($annotationData); try { $request = $this->http->post($this->apiURL('contract/annotations'), null, $data); $response = $request->send(); $this->logger->info('Annotation successfully submitted to Elastic Search.', $response->json()); } catch (Exception $e) { $this->logger->error($e->getMessage()); } }
/** * Task Detail * * @param $contract_id * @param $task_id * @return \Illuminate\View\View */ public function taskDetail($contract_id, $task_id) { $contract = $this->contract->findWithTasks($contract_id); $task = $this->task->get($contract_id, $task_id); return view('mturk.detail', compact('contract', 'task')); }
/** * Update process status * * @param $status * @return bool * @throws \Exception */ public function processStatus($status) { $contract = $this->contract->find($this->contract_id); $contract->pdf_process_status = $status; return $contract->save(); }