4 * Copyright (C) 2016-2017 Jerry Padgett <sjpadgett@gmail.com>
6 * LICENSE: This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Affero General Public License as
8 * published by the Free Software Foundation, either version 3 of the
9 * License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Affero General Public License for more details.
16 * You should have received a copy of the GNU Affero General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 * @author Jerry Padgett <sjpadgett@gmail.com>
21 * @link http://www.open-emr.org
25 if ( isset($_SESSION['pid']) && isset($_SESSION['patient_portal_onsite_two']) ) {
26 $pid = $_SESSION['pid'];
28 require_once ( dirname( __FILE__
) . "/../../interface/globals.php" );
33 require_once ( dirname( __FILE__
) . "/../../interface/globals.php" );
34 if ( ! isset($_SESSION['authUserID']) ){
35 $landingpage = "index.php";
36 header('Location: '.$landingpage);
41 require_once ( "$srcdir/classes/Document.class.php" );
42 require_once ( "$srcdir/classes/Note.class.php" );
43 require_once ( "$srcdir/formatting.inc.php" );
44 require_once ( "$srcdir/htmlspecialchars.inc.php" );
45 require_once ( "$srcdir/html2pdf/vendor/autoload.php" );
46 require_once (dirname( __FILE__
)."/appsql.class.php" );
48 $logit = new ApplicationTable();
49 $htmlin = $_REQUEST['content'];
50 $dispose = $_POST['handler'];
53 $form_filename = $_REQUEST['docid'] . '_' . $GLOBALS['pid'] . '.pdf';
54 $templatedir = $GLOBALS['OE_SITE_DIR'] . "/documents/onsite_portal_documents/patient_documents";
55 $templatepath = "$templatedir/$form_filename";
57 $pdf = new HTML2PDF( $GLOBALS['pdf_layout'], $GLOBALS['pdf_size'], $GLOBALS['pdf_language'], true,
58 'UTF-8', array ($GLOBALS['pdf_left_margin'],$GLOBALS['pdf_top_margin'],$GLOBALS['pdf_right_margin'],$GLOBALS['pdf_bottom_margin']
60 $pdf->writeHtml( $htmlin, false );
61 if( $dispose == 'download' ){
62 header( 'Content-type: application/pdf' );
63 header( 'Content-Disposition: attachment; filename=$form_filename' );
64 $pdf->Output( $form_filename, 'D' );
65 $logit->portalLog('download document',$_SESSION['pid'],('document:'.$form_filename));
67 if( $dispose == 'view' ){
68 Header( "Content-type: application/pdf" );
69 $pdf->Output( $templatepath, 'I' );
71 if( $dispose == 'chart' ){
72 $data = $pdf->Output( $form_filename, 'S' );
75 $rc = $d->createDocument( $GLOBALS['pid'], 29, $form_filename, 'application/pdf', $data );
78 $logit->portalLog('chart document',$_SESSION['pid'],('document:'.$form_filename));
84 echo 'Message: ' .$e->getMessage();
85 die(xlt("no signature in document"));
87 // not currently used but meant to be.
88 function doc_toDoc( $htmlin ){
89 header( "Content-type: application/vnd.oasis.opendocument.text" );
90 header( "Content-Disposition: attachment;Filename=document_name.html" );
92 echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=Windows-1252\">";