6 * @link http://www.open-emr.org
7 * @author ophthal <magauran@ophthal.org>
8 * @author sunsetsystems <sunsetsystems>
9 * @author JP-DEV\sjpad <sjpadgett@gmail.com>
10 * @author Rod Roark <rod@sunsetsystems.com>
11 * @copyright Copyright (c) 2016 ophthal <magauran@ophthal.org>
12 * @copyright Copyright (c) 2007 sunsetsystems <sunsetsystems>
13 * @copyright Copyright (c) 2017 JP-DEV\sjpad <sjpadgett@gmail.com>
14 * @copyright Copyright (c) 2015 Rod Roark <rod@sunsetsystems.com>
15 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
18 // login.php makes sure the session ID captured here is different for each
19 // new login. We maintain it here because most browsers do not have separate
20 // cookie storage for different top-level windows. This function should be
21 // called just prior to invoking any server script that requires correct
22 // session data. onclick="top.restoreSession()" usually does the job.
24 var oemr_session_name
= '<?php echo session_name(); ?>';
25 var oemr_session_id
= '<?php echo session_id(); ?>';
26 var oemr_dialog_close_msg
= '<?php echo (function_exists('xla
')) ? xla("OK to close this other popup window?") : "OK to close this other popup window?"; ?>';
28 function restoreSession() {
29 <?php
if (!empty($GLOBALS['restore_sessions'])) { ?
>
30 var ca
= document
.cookie
.split('; ');
31 for (var i
= 0; i
< ca
.length
; ++i
) {
32 var c
= ca
[i
].split('=');
33 if (c
[0] == oemr_session_name
&& c
[1] != oemr_session_id
) {
34 <?php
if ($GLOBALS['restore_sessions'] == 2) { ?
>
35 alert('Changing session ID from\n"' + c
[1] +
'" to\n"' + oemr_session_id +
'"');
37 document
.cookie
= oemr_session_name +
'=' + oemr_session_id +
'; path=<?php echo($web_root ? $web_root : '/');?>';
44 // Pages that have a Print button or link should call this to initialize it for logging.
45 // This is done at page load time in case we want to hide or disable the element.
46 // The second argument, if present, specifies a log message to be used instead of logging
47 // the entire document and will always prevent hiding of the button or link.
49 function printLogSetup(elem
, logdata
) {
50 if (elem
== null) return;
51 var doc
= elem
.ownerDocument
;
52 var win
= doc
.defaultView || doc
.parentWindow
;
53 if (typeof(logdata
) == 'undefined') logdata
= null;
54 <?php
if ($GLOBALS['gbl_print_log_option'] == 1) { ?
>
55 if (logdata
== null) {
56 elem
.style
.display
= 'none';
60 win
.printlogdata
= logdata
;
61 elem
.onclick
= function () {
62 // This is a function definition and variables here will be evaluated when the function executes.
63 top
.printLogPrint(this
);
67 // Pages that would otherwise call window.print() at load time should call this instead
68 // to support print logging. In this case the passed argument is normally the window,
69 // and data to log, if specified, should be in the caller's window.printlogdata.
70 // If no log data is specified and the global option to hide the print feature is set,
71 // then no printing is done and the function returns false.
73 function printLogPrint(elem
) {
75 if (elem
.ownerDocument
) {
76 var doc
= elem
.ownerDocument
;
77 win
= doc
.defaultView || doc
.parentWindow
;
79 <?php
if ($GLOBALS['gbl_print_log_option'] == 1) { ?
>
80 // Returning false means we didn't print.
81 if (!win
.printlogdata
) return false;
83 if (win
.printlog_before_print
) win
.printlog_before_print();
85 <?php
if (!empty($GLOBALS['gbl_print_log_option'])) { ?
>
86 comments
= win
.printlogdata || win
.document
.body
.innerHTML
;
88 $
.post("<?php echo $GLOBALS['webroot']; ?>/library/ajax/log_print_action_ajax.php",
89 { comments
: comments
}