added gacl config files to upgrade instructions
[openemr.git] / interface / reports / players_report.php
blobf1fe443bbbae73fb20d0f1a18fcdebe86a4472f6
1 <?php
2 // Copyright (C) 2005 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 report simply lists all players/patients by name within
10 // squad. It is applicable only for sports teams.
12 include_once("../globals.php");
13 include_once("$srcdir/patient.inc");
14 include_once("$srcdir/acl.inc");
16 $squads = acl_get_squads();
17 $auth_notes_a = acl_check('encounters', 'notes_a');
19 $alertmsg = ''; // not used yet but maybe later
21 // Get fitness level names and colors.
22 $PLAYER_FITNESSES = array();
23 $fres = sqlStatement("SELECT * FROM list_options WHERE " .
24 "list_id = 'fitness' ORDER BY seq");
25 while ($frow = sqlFetchArray($fres)) $PLAYER_FITNESSES[] = $frow['title'];
26 if (!empty($GLOBALS['fitness_colors'])) $PLAYER_FITCOLORS = $GLOBALS['fitness_colors'];
28 $query = "SELECT pid, squad, fitness, lname, fname FROM " .
29 "patient_data"; // ORDER BY squad, lname, fname
30 $res = sqlStatement($query);
32 // Sort the patients in squad priority order.
33 function patient_compare($a, $b) {
34 global $squads;
35 if ($squads[$a['squad']][3] == $squads[$b['squad']][3]) {
36 if ($a['lname'] == $b['lname']) {
37 return ($a['fname'] < $b['fname']) ? -1 : 1;
39 return ($a['lname'] < $b['lname']) ? -1 : 1;
41 // The squads are different so compare their order attributes,
42 // or unassigned squads sort last.
43 if (! $squads[$a['squad']][3]) return 1;
44 if (! $squads[$b['squad']][3]) return -1;
45 return ($squads[$a['squad']][2] < $squads[$b['squad']][2]) ? -1 : 1;
47 $ordres = array();
48 if ($res) {
49 while ($row = sqlFetchArray($res)) $ordres[] = $row;
50 usort($ordres, "patient_compare");
53 <html>
54 <head>
55 <? html_header_show();?>
56 <link rel=stylesheet href="<?php echo $css_header;?>" type="text/css">
58 <script language="JavaScript">
60 function gopid(pid) {
61 <?php
62 $maintop = $_GET['embed'] ? "top" : "opener.top";
63 echo " $maintop.restoreSession();\n";
64 if ($GLOBALS['concurrent_layout']) {
65 if( $GLOBALS['dutchpc'] ) {
66 echo " $maintop.RTop.location = '../patient_file/summary/demographics_dutch.php?set_pid=' + pid;\n";
67 } else {
68 echo " $maintop.RTop.location = '../patient_file/summary/demographics.php?set_pid=' + pid;\n";
70 } else {
71 echo " $maintop.location = '../patient_file/patient_file.php?set_pid=' + pid;\n";
73 if (empty($_GET['embed'])) echo " window.close();\n";
77 </script>
79 <title><?php xl('Team Roster','e'); ?></title>
80 </head>
82 <body leftmargin='0' topmargin='0' marginwidth='0' marginheight='0'>
83 <center>
85 <form method='post' action='players_report.php'>
87 <table border='0' cellpadding='5' cellspacing='0' width='98%'>
89 <tr>
90 <td height="1" colspan="2">
91 </td>
92 </tr>
94 <tr bgcolor='#ddddff'>
95 <td align='left'>
96 <h2><?php xl('Team Roster','e'); ?></h2>
97 </td>
98 <td align='right'>
99 <b><?php echo date('l, F j, Y') ?></b>
100 </td>
101 </tr>
103 <tr>
104 <td height="1" colspan="2">
105 </td>
106 </tr>
108 </table>
110 <table border='0' cellpadding='1' cellspacing='2' width='98%'>
112 <tr bgcolor="#dddddd">
113 <td class="dehead">
114 &nbsp;<?php xl('Squad','e'); ?>
115 </td>
116 <td class="dehead">
117 &nbsp;<?php xl('Player','e'); ?>
118 </td>
119 <td class="dehead">
120 &nbsp;<?php xl('Fitness','e'); ?>
121 </td>
122 <td class="dehead">
123 &nbsp;<?php xl('Last Encounter','e'); ?>
124 </td>
125 </tr>
126 <?php
127 // if ($res) {
128 $lastsquad = '';
129 foreach ($ordres as $row) {
130 $squadvalue = $row['squad'];
131 $squadname = $squads[$squadvalue][3];
132 if ($squadname) {
133 if (! acl_check('squads', $squadvalue)) continue;
134 } else {
135 $squadname = "None";
137 $patient_id = $row['pid'];
138 $fitness = $row['fitness'];
139 if (! $fitness) $fitness = 1;
140 $query = "SELECT date, reason " .
141 "FROM form_encounter WHERE " .
142 "pid = '$patient_id' " .
143 "ORDER BY date DESC LIMIT 1";
144 $erow = sqlQuery($query);
146 <tr>
147 <td class="detail">
148 &nbsp;<?php echo ($squadname == $lastsquad) ? "" : $squadname ?>
149 </td>
150 <td class="detail" bgcolor="<?php echo $PLAYER_FITCOLORS[$fitness-1] ?>">
151 &nbsp;<a href='javascript:gopid(<?php echo $patient_id ?>)' style='color:#000000'><?php echo $row['lname'] . ", " . $row['fname'] ?></a>
152 </td>
153 <td class="detail" bgcolor="<?php echo $PLAYER_FITCOLORS[$fitness-1] ?>">
154 <?php echo $PLAYER_FITNESSES[$fitness-1] ?>&nbsp;
155 </td>
156 <td class="detail" bgcolor="<?php echo $PLAYER_FITCOLORS[$fitness-1] ?>">
157 &nbsp;<?php
158 if ($auth_notes_a) {
159 echo substr($erow['date'], 0, 10) . ' ' . $erow['reason'];
160 } else {
161 echo '(No access)';
163 ?>&nbsp;
164 </td>
165 </tr>
166 <?php
167 $lastsquad = $squadname;
169 // }
172 </table>
174 </form>
175 </center>
176 <script>
177 <?php
178 if ($alertmsg) {
179 echo " alert('$alertmsg');\n";
182 </script>
183 </body>
184 </html>