Highway to PSR2
[openemr.git] / interface / reports / chart_location_activity.php
blob73f43c356d1c0285d2a3b5873ff0b5791551afa8
1 <?php
2 // Copyright (C) 2008-2015 Rod Roark <rod@sunsetsystems.com>
3 //
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
9 // This reports checkins and checkouts for a specified patient's chart.
12 use OpenEMR\Core\Header;
14 require_once("../globals.php");
15 require_once("$srcdir/patient.inc");
16 require_once("$srcdir/options.inc.php");
18 $form_patient_id = trim($_POST['form_patient_id']);
20 <html>
21 <head>
22 <title><?php echo xlt('Chart Location Activity'); ?></title>
24 <?php Header::setupHeader(); ?>
26 <style type="text/css">
28 /* specifically include & exclude from printing */
29 @media print {
30 #report_parameters {
31 visibility: hidden;
32 display: none;
34 #report_parameters_daterange {
35 visibility: visible;
36 display: inline;
38 #report_results table {
39 margin-top: 0px;
43 /* specifically exclude some from the screen */
44 @media screen {
45 #report_parameters_daterange {
46 visibility: hidden;
47 display: none;
51 </style>
53 <script language="JavaScript">
54 $(document).ready(function() {
55 var win = top.printLogSetup ? top : opener.top;
56 win.printLogSetup(document.getElementById('printbutton'));
57 });
58 </script>
60 </head>
62 <body class="body_top">
64 <span class='title'><?php echo xlt('Report'); ?> - <?php echo xlt('Chart Location Activity'); ?></span>
66 <?php
67 $curr_pid = $pid;
68 $ptrow = array();
69 if (!empty($form_patient_id)) {
70 $query = "SELECT pid, pubpid, fname, mname, lname FROM patient_data WHERE " .
71 "pubpid = ? ORDER BY pid LIMIT 1";
72 $ptrow = sqlQuery($query, array($form_patient_id));
73 if (empty($ptrow)) {
74 $curr_pid = 0;
75 echo "<font color='red'>" . xlt('Chart ID') . " '" . text($form_patient_id) . "' " . xlt('not found!') . "</font><br />&nbsp;<br />";
76 } else {
77 $curr_pid = $ptrow['pid'];
79 } else if (!empty($curr_pid)) {
80 $query = "SELECT pid, pubpid, fname, mname, lname FROM patient_data WHERE " .
81 "pid = ?";
82 $ptrow = sqlQuery($query, array($curr_pid));
83 $form_patient_id = $ptrow['pubpid'];
86 if (!empty($ptrow)) {
87 echo '<span class="title">' . text(xl('for', '', '', ' '));
88 echo text($ptrow['lname']) . ', ' . text($ptrow['fname']) . ' ' . text($ptrow['mname']) . ' ';
89 echo "(" . text($ptrow['pubpid']) . ")";
90 echo "</span>\n";
94 <div id="report_parameters_daterange">
95 </div>
97 <form name='theform' id='theform' method='post' action='chart_location_activity.php' onsubmit='return top.restoreSession()'>
99 <div id="report_parameters">
101 <input type='hidden' name='form_refresh' id='form_refresh' value=''/>
102 <table>
103 <tr>
104 <td width='200px'>
105 <div style='float:left'>
107 <table class='text'>
108 <tr>
109 <td class='control-label'>
110 <?php echo xlt('Patient ID'); ?>:
111 </td>
112 <td>
113 <input type='text' name='form_patient_id' class='form-control' size='10' maxlength='31' value='<?php echo attr($form_patient_id) ?>'
114 title='<?php echo xla('Patient ID'); ?>' />
115 </td>
116 </tr>
117 </table>
119 </div>
121 </td>
122 <td align='left' valign='middle' height="100%">
123 <table style='border-left:1px solid; width:100%; height:100%' >
124 <tr>
125 <td>
126 <div class="text-center">
127 <div class="btn-group" role="group">
128 <a href='#' class='btn btn-default btn-save' onclick='$("#form_refresh").attr("value","true"); $("#theform").submit();'>
129 <?php echo xlt('Submit'); ?>
130 </a>
131 <?php if ($_POST['form_refresh'] || !empty($ptrow)) { ?>
132 <a href='#' class='btn btn-default btn-print' id='printbutton'>
133 <?php echo xlt('Print'); ?>
134 </a>
135 <?php } ?>
136 </div>
137 </div>
138 </td>
139 </tr>
140 </table>
141 </td>
142 </tr>
143 </table>
145 </div> <!-- end of parameters -->
147 <?php
148 if ($_POST['form_refresh'] || !empty($ptrow)) {
150 <div id="report_results">
151 <table>
152 <thead>
153 <th> <?php echo xlt('Time'); ?> </th>
154 <th> <?php echo xlt('Destination'); ?> </th>
155 </thead>
156 <tbody>
157 <?php
158 $row = array();
159 if (!empty($ptrow)) {
160 $res = \services\PatientService::getChartTrackerInformationActivity($curr_pid);
161 while ($row = sqlFetchArray($res)) {
163 <tr>
164 <td>
165 <?php echo text(oeFormatShortDate(substr($row['ct_when'], 0, 10))) . text(substr($row['ct_when'], 10)); ?>
166 </td>
167 <td>
168 <?php
169 if (!empty($row['ct_location'])) {
170 echo generate_display_field(array('data_type'=>'1','list_id'=>'chartloc'), $row['ct_location']);
171 } else if (!empty($row['ct_userid'])) {
172 echo text($row['lname']) . ', ' . text($row['fname']) . ' ' . text($row['mname']);
175 </td>
176 </tr>
177 <?php
178 } // end while
179 } // end if
181 </tbody>
182 </table>
183 </div> <!-- end of results -->
184 <?php } else { ?>
185 <div class='text'>
186 <?php echo xlt('Please input search criteria above, and click Submit to view results.'); ?>
187 </div>
188 <?php } ?>
190 </form>
191 </body>
192 </html>