modified addBilling function call to hardcode auth
[openemr.git] / interface / logview / logview.php
blobfbe107b5e3392333b29c61e652bdaa0f39670539
1 <?php
2 include_once("../globals.php");
3 include_once("$srcdir/log.inc");
4 include_once("$srcdir/formdata.inc.php");
5 require_once("$srcdir/formatting.inc.php");
6 ?>
7 <html>
8 <head>
9 <?php html_header_show();?>
10 <link rel="stylesheet" href='<?php echo $GLOBALS['webroot'] ?>/library/dynarch_calendar.css' type='text/css'>
11 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/dialog.js"></script>
12 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/dynarch_calendar.js"></script>
13 <?php include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?>
14 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/dynarch_calendar_setup.js"></script>
16 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/js/jquery-1.2.2.min.js"></script>
17 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
18 <style>
19 #logview {
20 width: 100%;
22 #logview table {
23 width:100%;
24 border-collapse: collapse;
26 #logview th {
27 background-color: #cccccc;
28 cursor: pointer; cursor: hand;
29 padding: 5px 5px;
30 align: left;
31 text-align: left;
34 #logview td {
35 background-color: #ffffff;
36 border-bottom: 1px solid #808080;
37 cursor: default;
38 padding: 5px 5px;
39 vertical-align: top;
41 .highlight {
42 background-color: #336699;
43 color: #336699;
45 </style>
46 <script>
47 //function to disable the event type field if the event name is disclosure
48 function eventTypeChange(eventname)
50 if (eventname == "disclosure") {
51 document.theform.type_event.disabled = true;
53 else {
54 document.theform.type_event.disabled = false;
58 // VicarePlus :: This invokes the find-patient popup.
59 function sel_patient() {
60 dlgopen('../main/calendar/find_patient_popup.php?pflag=0', '_blank', 500, 400);
63 // VicarePlus :: This is for callback by the find-patient popup.
64 function setpatient(pid, lname, fname, dob) {
65 var f = document.theform;
66 f.form_patient.value = lname + ', ' + fname;
67 f.form_pid.value = pid;
70 </script>
71 </head>
72 <body class="body_top">
73 <font class="title"><?php xl('Logs Viewer','e'); ?></font>
74 <br>
75 <?php
76 $err_message=0;
77 if ($_GET["start_date"])
78 $start_date = formData('start_date','G');
80 if ($_GET["end_date"])
81 $end_date = formData('end_date','G');
83 if ($_GET["form_patient"])
84 $form_patient = formData('form_patient','G');
87 * Start date should not be greater than end date - Date Validation
89 if ($start_date && $end_date)
91 if($start_date > $end_date){
92 echo "<table><tr class='alert'><td colspan=7>"; xl('Start Date should not be greater than End Date',e);
93 echo "</td></tr></table>";
94 $err_message=1;
99 <?php
100 $form_user = formData('form_user','R');
101 $form_pid = formData('form_pid','R');
102 if ($form_patient == '' ) $form_pid = '';
104 $res = sqlStatement("select distinct LEFT(date,10) as date from log order by date desc limit 30");
105 for($iter=0;$row=sqlFetchArray($res);$iter++) {
106 $ret[$iter] = $row;
109 // Get the users list.
110 $sqlQuery = "SELECT username, fname, lname FROM users " .
111 "WHERE active = 1 AND ( info IS NULL OR info NOT LIKE '%Inactive%' ) ";
113 $ures = sqlStatement($sqlQuery);
116 <?php
117 $get_sdate=$start_date ? $start_date : date("Y-m-d");
118 $get_edate=$end_date ? $end_date : date("Y-m-d");
122 <br>
123 <FORM METHOD="GET" name="theform" id="theform">
125 $sortby = formData('sortby','G') ;
127 <input type="hidden" name="sortby" id="sortby" value="<?php echo $sortby; ?>">
128 <input type=hidden name=csum value="">
129 <table>
130 <tr><td>
131 <span class="text"><?php xl('Start Date','e'); ?>: </span>
132 </td><td>
133 <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 xl('yyyy-mm-dd Date of service','e'); ?>" onkeyup="datekeyup(this,mypcc)" onblur="dateblur(this,mypcc)" />
134 <img src="../pic/show_calendar.gif" align="absbottom" width="24" height="22" id="img_begin_date" border="0" alt="[?]" style="cursor: pointer; cursor: hand" title="<?php xl('Click here to choose a date','e'); ?>">&nbsp;
135 </td>
136 <td>
137 <span class="text"><?php xl('End Date','e'); ?>: </span>
138 </td><td>
139 <input type="text" size="10" name="end_date" id="end_date" value="<?php echo $end_date ? substr($end_date, 0, 10) : date('Y-m-d'); ?>" title="<?php xl('yyyy-mm-dd Date of service','e'); ?>" onkeyup="datekeyup(this,mypcc)" onblur="dateblur(this,mypcc)" />
140 <img src="../pic/show_calendar.gif" align="absbottom" width="24" height="22" id="img_end_date" border="0" alt="[?]" style="cursor: pointer; cursor: hand" title="<?php xl('Click here to choose a date','e'); ?>">&nbsp;
141 </td>
142 <!--VicarePlus :: Feature For Generating Log For The Selected Patient --!>
143 <td>
144 &nbsp;&nbsp;<span class='text'><?php echo htmlspecialchars(xl('Patient'),ENT_NOQUOTES); ?>: </span>
145 </td>
146 <td>
147 <input type='text' size='20' name='form_patient' style='width:100%;cursor:pointer;cursor:hand' value='<?php echo $form_patient ? $form_patient : htmlspecialchars(xl('Click To Select'),ENT_QUOTES); ?>' onclick='sel_patient()' title='<?php echo htmlspecialchars(xl('Click to select patient'),ENT_QUOTES); ?>' />
148 <input type='hidden' name='form_pid' value='<?php echo $form_pid; ?>' />
149 </td>
150 </tr>
151 <tr><td>
152 <span class='text'><?php xl('User','e'); ?>: </span>
153 </td>
154 <td>
155 <?php
156 echo "<select name='form_user'>\n";
157 echo " <option value=''>" . xl('All') . "</option>\n";
158 while ($urow = sqlFetchArray($ures)) {
159 if (!trim($urow['username'])) continue;
160 echo " <option value='" . $urow['username'] . "'";
161 if ($urow['username'] == $form_user) echo " selected";
162 echo ">" . $urow['lname'];
163 if ($urow['fname']) echo ", " . $urow['fname'];
164 echo "</option>\n";
166 echo "</select>\n";
168 </td>
169 <td>
170 <!-- list of events name -->
171 <span class='text'><?php xl('Name of Events','e'); ?>: </span>
172 </td>
173 <td>
174 <?php
175 $res = sqlStatement("select distinct event from log order by event ASC");
176 $ename_list=array(); $j=0;
177 while ($erow = sqlFetchArray($res)) {
178 if (!trim($erow['event'])) continue;
179 $data = explode('-', $erow['event']);
180 $data_c = count($data);
181 $ename=$data[0];
182 for($i=1;$i<($data_c-1);$i++)
184 $ename.="-".$data[$i];
186 $ename_list[$j]=$ename;
187 $j=$j+1;
189 $res1 = sqlStatement("select distinct event from extended_log order by event ASC");
190 $j=0;
191 while ($row = sqlFetchArray($res1)) {
192 if (!trim($row['event'])) continue;
193 $new_event = explode('-', $row['event']);
194 $no = count($new_event);
195 $events=$new_event[0];
196 for($i=1;$i<($no-1);$i++)
198 $events.="-".$new_event[$i];
200 if ($events=="disclosure")
201 $ename_list[$j]=$events;
202 $j=$j+1;
204 $ename_list=array_unique($ename_list);
205 $ename_list=array_merge($ename_list);
206 $ecount=count($ename_list);
207 echo "<select name='eventname' onchange='eventTypeChange(this.options[this.selectedIndex].value);'>\n";
208 echo " <option value=''>" . xl('All') . "</option>\n";
209 for($k=0;$k<$ecount;$k++) {
210 echo " <option value='" .$ename_list[$k]. "'";
211 if ($ename_list[$k] == $eventname && $ename_list[$k]!= "") echo " selected";
212 echo ">" . $ename_list[$k];
213 echo "</option>\n";
215 echo "</select>\n";
217 </td>
218 <!-- type of events ends -->
219 <td>
220 &nbsp;&nbsp;<span class='text'><?php xl('Type of Events','e'); ?>: </span>
221 </td><td>
222 <?php
223 $event_types=array("select", "update", "insert", "delete", "replace");
224 $lcount=count($event_types);
225 if($eventname=="disclosure"){
226 echo "<select name='type_event' disabled='disabled'>\n";
227 echo " <option value=''>" . xl('All') . "</option>\n";
228 echo "</option>\n";
230 else{
231 echo "<select name='type_event'>\n";}
232 echo " <option value=''>" . xl('All') . "</option>\n";
233 for($k=0;$k<$lcount;$k++) {
234 echo " <option value='" .$event_types[$k]. "'";
235 if ($event_types[$k] == $type_event && $event_types[$k]!= "") echo " selected";
236 echo ">" . $event_types[$k];
237 echo "</option>\n";
239 echo "</select>\n";
241 </td>
242 <tr><td>
243 <span class='text'><?php xl('Include Checksum','e'); ?>: </span>
244 </td><td>
246 $check_sum = formData('check_sum','G');
248 <input type="checkbox" name="check_sum" " <?php if ($check_sum == 'on') echo "checked"; ?>"></input>
249 </td>
250 <td>
251 <input type=hidden name="event" value=<?php echo $event ; ?>>
252 <a href="javascript:document.theform.submit();" class='link_submit'>[<?php xl('Refresh','e'); ?>]</a>
253 </td>
254 </tr>
255 </table>
256 </FORM>
259 <?php if ($start_date && $end_date && $err_message!=1) { ?>
260 <div id="logview">
261 <table>
262 <tr>
263 <!-- <TH><?php xl('Date', 'e'); ?><TD> -->
264 <th id="sortby_date" class="text" title="<?php xl('Sort by date/time','e'); ?>"><?php xl('Date','e'); ?></th>
265 <th id="sortby_event" class="text" title="<?php xl('Sort by Event','e'); ?>"><?php xl('Event','e'); ?></th>
266 <th id="sortby_user" class="text" title="<?php xl('Sort by User','e'); ?>"><?php xl('User','e'); ?></th>
267 <th id="sortby_cuser" class="text" title="<?php xl('Sort by Crt User','e'); ?>"><?php xl('Certificate User','e'); ?></th>
268 <th id="sortby_group" class="text" title="<?php xl('Sort by Group','e'); ?>"><?php xl('Group','e'); ?></th>
269 <th id="sortby_pid" class="text" title="<?php xl('Sort by PatientID','e'); ?>"><?php xl('PatientID','e'); ?></th>
270 <th id="sortby_success" class="text" title="<?php xl('Sort by Success','e'); ?>"><?php xl('Success','e'); ?></th>
271 <th id="sortby_comments" class="text" title="<?php xl('Sort by Comments','e'); ?>"><?php xl('Comments','e'); ?></th>
272 <?php if($check_sum) {?>
273 <th id="sortby_checksum" class="text" title="<?php xl('Sort by Checksum','e'); ?>"><?php xl('Checksum','e'); ?></th>
274 <?php } ?>
275 </tr>
277 $eventname = formData('eventname','G');
278 $type_event = formData('type_event','G');
280 <input type=hidden name=event value=<?php echo $eventname."-".$type_event ?>>
281 <?php
283 $tevent=""; $gev="";
284 if($eventname != "" && $type_event != "")
286 $getevent=$eventname."-".$type_event;
289 if(($eventname == "") && ($type_event != ""))
290 { $tevent=$type_event;
292 else if($type_event =="" && $eventname != "")
293 {$gev=$eventname;}
294 else if ($eventname == "")
295 {$gev = "";}
296 else
297 {$gev = $getevent;}
299 if ($ret = getEvents(array('sdate' => $get_sdate,'edate' => $get_edate, 'user' => $form_user, 'patient' => $form_pid, 'sortby' => $_GET['sortby'], 'levent' =>$gev, 'tevent' =>$tevent))) {
302 foreach ($ret as $iter) {
303 //translate comments
304 $patterns = array ('/^success/','/^failure/','/ encounter/');
305 $replace = array ( xl('success'), xl('failure'), xl('encounter','',' '));
306 $trans_comments = preg_replace($patterns, $replace, $iter["comments"]);
309 <TR class="oneresult">
310 <TD class="text"><?php echo oeFormatShortDate(substr($iter["date"], 0, 10)) . substr($iter["date"], 10) ?></TD>
311 <TD class="text"><?php echo xl($iter["event"])?></TD>
312 <TD class="text"><?php echo $iter["user"]?></TD>
313 <TD class="text"><?php echo $iter["crt_user"]?></TD>
314 <TD class="text"><?php echo $iter["groupname"]?></TD>
315 <TD class="text"><?php echo $iter["patient_id"]?></TD>
316 <TD class="text"><?php echo $iter["success"]?></TD>
317 <TD class="text"><?php echo $trans_comments?></TD>
318 <?php if($check_sum) { ?>
319 <TD class="text"><?php echo $iter["checksum"]?></TD>
320 <?php } ?>
321 </TR>
323 <?php
327 if (($eventname=="disclosure") || ($gev == ""))
329 $eventname="disclosure";
330 if ($ret = getEvents(array('sdate' => $get_sdate,'edate' => $get_edate, 'user' => $form_user, 'patient' => $form_pid, 'sortby' => $_GET['sortby'], 'event' =>$eventname))) {
331 foreach ($ret as $iter) {
332 $comments=xl('Recipient Name').":".$iter["recipient"].";".xl('Disclosure Info').":".$iter["description"];
334 <TR class="oneresult">
335 <TD class="text"><?php echo htmlspecialchars(oeFormatShortDate(substr($iter["date"], 0, 10)) . substr($iter["date"], 10),ENT_NOQUOTES); ?></TD>
336 <TD class="text"><?php echo htmlspecialchars(xl($iter["event"]),ENT_NOQUOTES);?></TD>
337 <TD class="text"><?php echo htmlspecialchars($iter["user"],ENT_NOQUOTES);?></TD>
338 <TD class="text"><?php echo htmlspecialchars($iter["crt_user"],ENT_NOQUOTES);?></TD>
339 <TD class="text"><?php echo htmlspecialchars($iter["groupname"],ENT_NOQUOTES);?></TD>
340 <TD class="text"><?php echo htmlspecialchars($iter["patient_id"],ENT_NOQUOTES);?></TD>
341 <TD class="text"><?php echo htmlspecialchars($iter["success"],ENT_NOQUOTES);?></TD>
342 <TD class="text"><?php echo htmlspecialchars($comments,ENT_NOQUOTES);?></TD>
343 <?php if($check_sum) { ?>
344 <TD class="text"><?php echo htmlspecialchars($iter["checksum"],ENT_NOQUOTES);?></TD>
345 <?php } ?>
346 </TR>
347 <?php
352 </table>
353 </div>
355 <?php } ?>
357 </body>
359 <script language="javascript">
361 // jQuery stuff to make the page a little easier to use
362 $(document).ready(function(){
363 // funny thing here... good learning experience
364 // the TR has TD children which have their own background and text color
365 // toggling the TR color doesn't change the TD color
366 // so we need to change all the TR's children (the TD's) just as we did the TR
367 // thus we have two calls to toggleClass:
368 // 1 - for the parent (the TR)
369 // 2 - for each of the children (the TDs)
370 $(".oneresult").mouseover(function() { $(this).toggleClass("highlight"); $(this).children().toggleClass("highlight"); });
371 $(".oneresult").mouseout(function() { $(this).toggleClass("highlight"); $(this).children().toggleClass("highlight"); });
373 // click-able column headers to sort the list
374 $("#sortby_date").click(function() { $("#sortby").val("date"); $("#theform").submit(); });
375 $("#sortby_event").click(function() { $("#sortby").val("event"); $("#theform").submit(); });
376 $("#sortby_user").click(function() { $("#sortby").val("user"); $("#theform").submit(); });
377 $("#sortby_cuser").click(function() { $("#sortby").val("user"); $("#theform").submit(); });
378 $("#sortby_group").click(function() { $("#sortby").val("groupname"); $("#theform").submit(); });
379 $("#sortby_pid").click(function() { $("#sortby").val("patient_id"); $("#theform").submit(); });
380 $("#sortby_success").click(function() { $("#sortby").val("success"); $("#theform").submit(); });
381 $("#sortby_comments").click(function() { $("#sortby").val("comments"); $("#theform").submit(); });
382 $("#sortby_checksum").click(function() { $("#sortby").val("checksum"); $("#theform").submit(); });
386 /* required for popup calendar */
387 Calendar.setup({inputField:"start_date", ifFormat:"%Y-%m-%d", button:"img_begin_date"});
388 Calendar.setup({inputField:"end_date", ifFormat:"%Y-%m-%d", button:"img_end_date"});
390 </script>
392 </html>