public function postFaxImport() { $pid = Input::get('pid'); $pt = Demographics::find($pid); if ($pt) { $directory = Session::get('documents_dir') . $pid; $result = Received::find(Input::get('received_id')); if (Input::get('fax_import_pages') == '') { $file1 = $result->filePath; $file2 = $directory . "/" . $result->fileName . '_' . time() . '.pdf'; if (!copy($file1, $file2)) { echo "Fax import failed!"; exit(0); } } else { $page_array = explode(",", Input::get('fax_import_pages')); $page = " "; foreach ($page_array as $page_item) { $page .= "A" . $page_item . " "; } $filename = str_replace(".pdf", "", $result->fileName); $file2 = $directory . "/" . $filename . "_" . time() . "_excerpt.pdf"; $commandpdf2 = 'pdftk A="' . $result->filePath . '" cat' . $page . 'output "' . $file2 . '"'; $commandpdf3 = escapeshellcmd($commandpdf2); exec($commandpdf3); } $pages_data2 = array('documents_url' => $file2, 'pid' => $pid, 'documents_type' => Input::get('documents_type'), 'documents_desc' => Input::get('documents_desc'), 'documents_from' => Input::get('documents_from'), 'documents_viewed' => Input::get('documents_viewed'), 'documents_date' => date('Y-m-d', strtotime(Input::get('documents_date')))); $documents_id = DB::table('documents')->insertGetId($pages_data2); $this->audit('Add'); echo 'Fax imported!'; exit(0); } else { echo 'No patient for fax to be imported!'; exit(0); } }
public function view_fax($id) { $result = Received::find($id); $file_path = $result->filePath; return Response::download($file_path); }