move jquery-1.2.2.min.js to assets
[openemr.git] / interface / logview / erx_logview.php
blobf9ee39799a603e9a0598470979aa6505ed4718ee
1 <?php
3 /**
4 * interface/logview/erx_logview.php Display NewCrop errors.
6 * Copyright (C) 2011 ZMG LLC <sam@zhservices.com>
8 * LICENSE: This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by the Free
10 * Software Foundation; either version 3 of the License, or (at your option) any
11 * later version. This program is distributed in the hope that it will be
12 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
14 * Public License for more details. You should have received a copy of the GNU
15 * General Public License along with this program.
16 * If not, see <http://opensource.org/licenses/gpl-license.php>.
18 * @package OpenEMR
19 * @subpackage NewCrop
20 * @author Eldho Chacko <eldho@zhservices.com>
21 * @author Vinish K <vinish@zhservices.com>
22 * @author Sam Likins <sam.likins@wsi-services.com>
23 * @link http://www.open-emr.org
26 $sanitize_all_escapes = true; // SANITIZE ALL ESCAPES
28 $fake_register_globals = false; // STOP FAKE REGISTER GLOBALS
30 require_once(__DIR__.'/../globals.php');
31 require_once($srcdir.'/log.inc');
32 require_once($srcdir.'/formdata.inc.php');
33 require_once($srcdir.'/formatting.inc.php');
35 $error_log_path = $GLOBALS['OE_SITE_DIR'].'/documents/erx_error';
37 if(array_key_exists('filename', $_REQUEST)) {
38 $filename = $_REQUEST['filename'];
39 } else {
40 $filename = '';
43 if(array_key_exists('start_date', $_REQUEST)) {
44 $start_date = $_REQUEST['start_date'];
45 } else {
46 $start_date = '';
49 if($filename) {
50 $bat_content = '';
52 preg_match('/erx_error-\d{4}-\d{1,2}-\d{1,2}\.log/', $filename, $matches);
54 if($matches) {
55 if($fd = fopen($error_log_path.'/'.$filename, 'r')) {
56 $bat_content = fread($fd, filesize($error_log_path.'/'.$filename));
59 header('Pragma: public');
60 header('Expires: 0');
61 header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
62 header('Content-Type: application/force-download');
63 header('Content-Disposition: attachment; filename='.$filename);
64 header('Content-Description: File Transfer');
65 header('Content-Length: '.strlen($bat_content));
67 echo $bat_content;
69 die;
74 <html>
75 <head>
76 <?php html_header_show(); ?>
77 <link rel="stylesheet" href="<?php echo $css_header; ?>" type="text/css">
78 <link rel="stylesheet" href="<?php echo $GLOBALS['webroot']; ?>/library/dynarch_calendar.css" type="text/css">
79 <script type="text/javascript" src="<?php echo $GLOBALS['webroot']; ?>/library/dialog.js"></script>
80 <script type="text/javascript" src="<?php echo $GLOBALS['webroot']; ?>/library/dynarch_calendar.js"></script>
81 <?php include_once($GLOBALS['srcdir'].'/dynarch_calendar_en.inc.php'); ?>
82 <script type="text/javascript" src="<?php echo $GLOBALS['webroot']; ?>/library/dynarch_calendar_setup.js"></script>
83 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-2-2/index.js"></script>
84 </head>
85 <body class="body_top">
86 <form method="post">
87 <font class="title"><?php echo xlt('eRx Logs'); ?></font><br><br>
88 <table>
89 <tr>
90 <td>
91 <span class="text"><?php echo xlt('Date'); ?>: </span>
92 </td>
93 <td>
94 <input type="text" size="10" name="start_date" id="start_date" value="<?php echo $start_date ? substr($start_date, 0, 10) : date('Y-m-d'); ?>" title="<?php echo xlt('yyyy-mm-dd Date of service'); ?>" onkeyup="datekeyup(this, mypcc)" onblur="dateblur(this, mypcc)" />
95 <img src="<?php echo $GLOBALS['webroot']; ?>/interface/pic/show_calendar.gif" align="absbottom" width="24" height="22" id="img_begin_date" border="0" alt="[?]" style="cursor: pointer; cursor: hand" title="<?php echo xlt('Click here to choose a date'); ?>">&nbsp;
96 </td>
97 <td>
98 <input type="submit" name="search_logs" value="<?php echo xlt('Search'); ?>">
99 </td>
100 </tr>
101 </table>
102 </form>
103 <?php
105 $check_for_file = 0;
106 if(array_key_exists('search_logs', $_REQUEST)) {
107 if ($handle = opendir($error_log_path)) {
108 while(false !== ($file = readdir($handle))) {
109 $file_as_in_folder = 'erx_error-'.$start_date.'.log';
111 if($file != '.' && $file != '..' && $file_as_in_folder == $file) {
112 $check_for_file = 1;
113 $fd = fopen ($error_log_path.'/'.$file, 'r');
114 $bat_content = fread($fd, filesize($error_log_path.'/'.$file));
116 <p><?php echo xlt('Download'); ?>: <a href="erx_logview.php?filename=<?php echo htmlspecialchars($file, ENT_QUOTES); ?>"><?php echo htmlspecialchars($file, ENT_NOQUOTES); ?></a></p>
117 <textarea rows="35" cols="132"><?php echo htmlspecialchars($bat_content, ENT_QUOTES); ?></textarea>
118 <?php
122 if($check_for_file == 0) {
123 echo xlt('No log file exist for the selected date').': '.$start_date;
128 </body>
129 <script type="text/javascript">
130 Calendar.setup({inputField:"start_date", ifFormat:"%Y-%m-%d", button:"img_begin_date"});
131 </script>
132 </html>