Portal updates and general bug fixes (#2318)
[openemr.git] / portal / sign / lib / show-signature.php
blobedabf8744d77c832d11ef306beacda37406a97cd
1 <?php
2 /**
3 * Patient Portal
5 * @package OpenEMR
6 * @link http://www.open-emr.org
7 * @author Jerry Padgett <sjpadgett@gmail.com>
8 * @copyright Copyright (c) 2016-2019 Jerry Padgett <sjpadgett@gmail.com>
9 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
12 $ignoreAuth = true;
13 require_once("../../../interface/globals.php");
15 $data = (array)(json_decode(file_get_contents("php://input")));
16 $pid = $data['pid'];
17 $user = $data['user'];
18 $type = $data['type'];
19 $signer = $data['signer'];
21 $created = time();
22 $lastmod = date('Y-m-d H:i:s');
23 $status = 'filed';
25 if ($pid == 0 || empty($user)) {
26 if ($type != 'admin-signature' || empty($user)) {
27 echo(text('error'));
28 return;
32 if ($type == 'admin-signature') {
33 $pid = 0;
34 $row = sqlQuery("SELECT pid,status,sig_image,type,user FROM onsite_signatures WHERE user=? && type=?", array($user, $type));
35 } else {
36 $row = sqlQuery("SELECT pid,status,sig_image,type,user FROM onsite_signatures WHERE pid=?", array($pid));
39 if (!$row['pid'] && !$row['user']) {
40 $status = 'waiting';
41 $qstr = "INSERT INTO onsite_signatures (pid,lastmod,status,type,user,signator,created) VALUES (?,?,?,?,?,?,?)";
42 sqlStatement($qstr, array($pid, $lastmod, $status, $type, $user, $signer, $created));
45 if ($row['status'] == 'filed') {
46 echo js_escape($row['sig_image']);
47 } elseif ($row['status'] == 'waiting' || $status == 'waiting') {
48 echo js_escape('waiting');
51 exit();