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
24 if (isset($_SESSION['pid']) && isset($_SESSION['patient_portal_onsite_two'])) {
26 require_once(dirname(__FILE__
) . "/../../interface/globals.php");
30 require_once(dirname(__FILE__
) . "/../../interface/globals.php");
31 if (! isset($_SESSION['authUserID'])) {
32 $landingpage = "index.php";
33 header('Location: ' . $landingpage);
38 require_once(dirname(__FILE__
) . "/../lib/portal_mail.inc");
39 require_once("$srcdir/pnotes.inc");
41 $task = $_POST['task'];
46 $noteid = $_POST['noteid'] ?
$_POST['noteid'] : 0;
47 $notejson = $_POST['notejson'] ?
json_decode($_POST['notejson'], true) : 0;
48 $reply_noteid = $_POST['replyid'] ?
$_POST['replyid'] : 0;
49 $owner = isset($_POST['owner']) ?
$_POST['owner'] : $_SESSION['pid'];
50 $note = $_POST['inputBody'];
51 $title = $_POST['title'];
52 $sid = $_POST['sender_id'];
53 $sn = $_POST['sender_name'];
54 $rid = $_POST['recipient_id'];
55 $rn = $_POST['recipient_name'];
60 $pid = isset($_POST['pid']) ?
$_POST['pid'] : 0;
61 addPnote($pid, $note, 1, 1, $title, $sid, '', 'New');
62 updatePortalMailMessageStatus($noteid, 'Sent');
66 // each user has their own copy of message
67 sendMail($owner, $note, $title, $header, $noteid, $sid, $sn, $rid, $rn, 'New');
68 sendMail($rid, $note, $title, $header, $noteid, $sid, $sn, $rid, $rn, 'New', $reply_noteid);
72 sendMail($owner, $note, $title, $header, $noteid, $sid, $sn, $rid, $rn, 'Reply', '');
73 sendMail($rid, $note, $title, $header, $noteid, $sid, $sn, $rid, $rn, 'New', $reply_noteid);
77 updatePortalMailMessageStatus($noteid, 'Delete');
81 foreach ($notejson as $deleteid) {
82 updatePortalMailMessageStatus($deleteid, 'Delete');
88 updatePortalMailMessageStatus($noteid, 'Read');
91 echo 'missing note id';
96 $result = getMails($owner, 'inbox', '', '');
97 echo json_encode($result);
104 $result = getMails($owner, 'sent', '', '');
105 echo json_encode($result);
112 $result = getMails($owner, 'all', '', '');
113 echo json_encode($result);
120 $result = getMails($owner, 'deleted', '', '');
121 echo json_encode($result);
131 if (isset($_REQUEST["submit"])) {
132 header("Location: {$_REQUEST["submit
"]}");