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