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 require_once("../interface/globals.php");
25 $getdir = isset($_POST['sel_pt']) ?
$_POST['sel_pt'] : 0;
27 $tdir = $GLOBALS['OE_SITE_DIR'] . '/documents/onsite_portal_documents/templates/' . $getdir . '/';
29 if (!mkdir($tdir, 0755, true)) {
30 die(xl('Failed to create folder'));
34 $tdir = $GLOBALS['OE_SITE_DIR'] . '/documents/onsite_portal_documents/templates/';
37 function getAuthUsers()
39 $response = sqlStatement("SELECT patient_data.pid, Concat_Ws(' ', patient_data.fname, patient_data.lname) as ptname FROM patient_data WHERE allow_patient_portal = 'YES'");
41 while ($row = sqlFetchArray($response)) {
47 function getTemplateList($dir)
50 if (substr($dir, -1) != "/") {
54 $d = @dir
($dir) or die("File List: Failed opening directory " . text($dir) . " for reading");
55 while (false !== ($entry = $d->read())) {
56 if ($entry[0] == "." ||
substr($entry, -3) != 'tpl') {
60 if (is_dir("$dir$entry")) {
62 'pathname' => "$dir$entry",
65 'lastmod' => filemtime("$dir$entry")
67 } elseif (is_readable("$dir$entry")) {
69 'pathname' => "$dir$entry",
71 'size' => filesize("$dir$entry"),
72 'lastmod' => filemtime("$dir$entry")
83 <meta charset
="UTF-8">
84 <title
><?php
echo xlt('OpenEMR Portal'); ?
> |
<?php
echo xlt('Import'); ?
></title
>
85 <meta content
='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name
='viewport'>
86 <meta name
="description" content
="Developed By sjpadgett@gmail.com">
88 <link href
="<?php echo $GLOBALS['assets_static_relative']; ?>/font-awesome-4-6-3/css/font-awesome.min.css" rel
="stylesheet" type
="text/css" />
89 <link href
="<?php echo $GLOBALS['assets_static_relative']; ?>/bootstrap-3-3-4/dist/css/bootstrap.min.css" rel
="stylesheet" type
="text/css" />
90 <?php
if ($_SESSION['language_direction'] == 'rtl') { ?
>
91 <link href
="<?php echo $GLOBALS['assets_static_relative']; ?>/bootstrap-rtl-3-3-4/dist/css/bootstrap-rtl.min.css" rel
="stylesheet" type
="text/css" />
93 <link href
="assets/css/style.css?v=<?php echo $v_js_includes; ?>" rel
="stylesheet" type
="text/css" />
94 <script src
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-11-3/index.js" type
="text/javascript"></script
>
95 <script src
="<?php echo $GLOBALS['assets_static_relative']; ?>/bootstrap-3-3-4/dist/js/bootstrap.min.js" type
="text/javascript"></script
>
96 <link href
="<?php echo $GLOBALS['assets_static_relative']; ?>/summernote-0-8-2/dist/summernote.css" rel
="stylesheet" type
="text/css" />
97 <script type
='text/javascript' src
="<?php echo $GLOBALS['assets_static_relative']; ?>/summernote-0-8-2/dist/summernote.js"></script
>
98 <script type
='text/javascript' src
="<?php echo $GLOBALS['assets_static_relative']; ?>/summernote-0-8-2/dist/plugin/nugget/summernote-ext-nugget.js"></script
>
101 var currentEdit
= "";
102 var tedit
= function(docname
) {
103 currentEdit
= docname
;
104 getDocument(docname
, 'get', '')
108 var tsave
= function() {
109 var makrup
= $
('#templatecontent').summernote('code');
110 getDocument(currentEdit
, 'save', makrup
)
112 var tdelete
= function(docname
) {
113 var delok
= confirm("<?php echo xls('You are about to delete template'); ?>: "+docname+
"\n<?php echo xls('Is this Okay?'); ?>");
114 if(delok
=== true) {getDocument(docname
, 'delete', '')}
117 function getDocument(docname
, mode
, content
){
118 var liburl
= 'import_template.php';
122 data
: {docid
: docname
, mode
: mode
,content
: content
},
123 beforeSend
: function(xhr
){
124 console
.log("Please wait..."+content
);
126 error
: function(qXHR
, textStatus
, errorThrow
){
127 console
.log("There was an error");
129 success
: function(templateHtml
, textStatus
, jqXHR
){
131 //console.log("File get..."+templateHtml);
132 $
('#templatecontent').summernote('destroy');
133 $
('#templatecontent').empty().append(templateHtml
);
134 $
('#popeditor').modal({backdrop
: "static"});
135 $
('#templatecontent').summernote({
140 ['style', ['bold', 'italic', 'underline', 'clear']],
141 ['fontsize', ['fontsize']],
142 ['color', ['color']],
143 ['para', ['ul', 'ol', 'paragraph']],
144 ['insert', ['link','picture', 'video', 'hr']],
145 ['view', ['fullscreen', 'codeview']],
146 ['insert', ['nugget']],
147 ['edit',['undo','redo']]
151 '{ParseAsHTML}{TextInput}', '{smTextInput}', '{CheckMark}', '{ynRadioGroup}', '{DOS}','{ReferringDOC}', '{PatientID}',
152 '{PatientName}', '{PatientSex}', '{PatientDOB}', '{PatientPhone}', '{PatientSignature}', '{Address}', '{City}', '{State}', '{Zip}',
153 '{AdminSignature}', '{Medications}', '{ProblemList}', '{Allergies}', '{ChiefComplaint}'
155 label
: 'Tags / Directives',
156 tooltip
: 'Insert at current cursor location.'
158 options
:{'label': 'Tags/Directives',
159 'tooltip': 'Insert Tag or Directive'}
162 else if(mode
== 'save'){
163 $
('#templatecontent').summernote('destroy');
166 else if(mode
== 'delete'){
174 .modal
.modal
-wide
.modal
-dialog
{
177 .modal
-wide
.modal
-body
{
181 <body
class="skin-blue">
182 <div
class='container' style
='display: block;'>
184 <h3
><?php
echo xlt('Patient Document Template Upload'); ?
></h3
>
185 <h4
><em
><?php
echo xlt('File base name becomes Menu selection'); ?
>.<br
><?php
echo xlt('Automatically applies correct extension on successful upload'); ?
>.<br
>
186 <?php
echo xlt('Example Privacy_Agreement.txt becomes Privacy Agreement button in Patient Documents'); ?
>.</em
></h4
>
187 <form id
="form_upload" class="form" action
="import_template.php" method
="post" enctype
="multipart/form-data">
188 <input
class="btn btn-info" type
="file" name
="tplFile">
190 <button
class="btn btn-primary" type
="button" onclick
="location.href='./patient/provider'"><?php
echo xlt('Home'); ?
></button
>
191 <input type
='hidden' name
="up_dir" value
='<?php global $getdir;
193 <button
class="btn btn-success" type
="submit" name
="upload_submit" id
="upload_submit"><?php
echo xlt('Upload Template for'); ?
> <span style
="font-size: 14px;" class="label label-default" id
='ptstatus'></span
></button
>
196 <h3
><?php
echo xlt('Active Templates'); ?
></h3
>
197 <div
class='col col-md col-lg'>
198 <form id
= "edit_form" name
= "edit_form" class="form-inline" action
="" method
="post">
199 <div
class="form-group">
200 <label
for="sel_pt"><?php
echo xlt('Patient'); ?
></label
>
201 <select
class="form-control" id
="sel_pt" name
="sel_pt">
202 <option value
='0'><?php
echo xlt("Global All Patients")?
></option
>
204 $ppt = getAuthUsers();
206 foreach ($ppt as $pt) {
207 if ($getdir != $pt['pid']) {
208 echo "<option value=" . attr($pt['pid']) . ">" . text($pt['ptname']) . "</option>";
210 echo "<option value='" . attr($pt['pid']) . "' selected='selected'>" . text($pt['ptname']) . "</option>";
214 echo "</select></div>";
215 echo '<button type="submit" class="btn btn-default">' . xlt('Refresh') . '</button>';
216 echo '</form></div>';
217 $dirlist = getTemplateList($tdir);
218 echo "<table class='table table-striped table-bordered'>";
220 echo "<tr><th>" . xlt("Template") . " - <i>" . xlt("Click to edit") . "</i></th><th>" . xlt("Size") . "</th><th>" . xlt("Last Modified") . "</th></tr>";
223 foreach ($dirlist as $file) {
224 $t = "'" . $file['pathname'] . "'";
226 echo '<td><button id="tedit' . attr($t) . '" class="btn btn-sm btn-primary" onclick="tedit(' . attr($t) . ')" type="button">' . text($file['name']) . '</button>
227 <button id="tdelete' . attr($t) . '" class="btn btn-xs btn-danger" onclick="tdelete(' . attr($t) . ')" type="button">' . xlt("Delete") . '</button></td>';
228 echo "<td>{$file['size']}</td>";
229 echo "<td>", date('r', $file['lastmod']), "</td>";
237 $
(document
).ready(function(){
238 $
("#popeditor").on("show.bs.modal", function() {
239 var height
= $
(window
).height() - 200;
240 $
(this
).find(".modal-body").css("max-height", height
);
242 $
("#sel_pt").change(function(){
243 $
("#edit_form").submit();
245 $
("#ptstatus").text($
("#sel_pt").find(":selected").text())
249 <div
class="modal modal-wide fade" id
="popeditor">
250 <div
class="modal-dialog modal-lg">
251 <div
class="modal-content">
252 <div
class="modal-header">
253 <button type
="button" class="close" data
-dismiss
="modal">
254 <span aria
-hidden
="true">×
;</span
>
255 <span
class="sr-only"><?php
echo xlt('Close'); ?
></span
>
257 <h4
class="modal-title"><?php
echo xlt('Edit Template'); ?
></h4
>
259 <div
class="modal-body">
260 <div
class="edittpl" id
="templatecontent"></div
>
262 <div
class="modal-footer">
263 <button type
="button" class="btn btn-danger btn-xs" data
-dismiss
="modal"><?php
echo xlt('Dismiss'); ?
></button
>
264 <button type
="button" class="btn btn-success btn-xs" data
-dismiss
="modal" onclick
="tsave()"><?php
echo xlt('Save'); ?
></button
>