added acl checking
[openemr.git] / interface / reports / players_report.php
blob6c4686798efdce01775e9157aaab5d7acdbb0b1a
1 <?
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 $fitnesses = array(
20 'Full Play',
21 'Full Training',
22 'Restricted Training',
23 'Injured Out',
24 'Rehabilitation'
27 $fitcolors = array('#6677ff', '#00cc00', '#ffff00', '#ff3333', '#ff8800');
29 $alertmsg = ''; // not used yet but maybe later
31 $query = "SELECT pid, squad, fitness, lname, fname FROM " .
32 "patient_data"; // ORDER BY squad, lname, fname
33 $res = sqlStatement($query);
35 // Sort the patients in squad priority order.
36 function patient_compare($a, $b) {
37 global $squads;
38 if ($squads[$a['squad']][3] == $squads[$b['squad']][3]) {
39 if ($a['lname'] == $b['lname']) {
40 return ($a['fname'] < $b['fname']) ? -1 : 1;
42 return ($a['lname'] < $b['lname']) ? -1 : 1;
44 // The squads are different so compare their order attributes,
45 // or unassigned squads sort last.
46 if (! $squads[$a['squad']][3]) return 1;
47 if (! $squads[$b['squad']][3]) return -1;
48 return ($squads[$a['squad']][2] < $squads[$b['squad']][2]) ? -1 : 1;
50 $ordres = array();
51 if ($res) {
52 while ($row = sqlFetchArray($res)) $ordres[] = $row;
53 usort($ordres, "patient_compare");
56 <html>
57 <head>
58 <link rel=stylesheet href="<?echo $css_header;?>" type="text/css">
60 <script language="JavaScript">
62 function gopid(pid) {
63 <? if ($_GET['embed']) { ?>
64 top.location = '../patient_file/patient_file.php?set_pid=' + pid;
65 <? } else { ?>
66 opener.top.location = '../patient_file/patient_file.php?set_pid=' + pid;
67 window.close();
68 <? } ?>
71 </script>
73 <title><? xl('Team Roster','e'); ?></title>
74 </head>
76 <body leftmargin='0' topmargin='0' marginwidth='0' marginheight='0'>
77 <center>
79 <form method='post' action='players_report.php'>
81 <table border='0' cellpadding='5' cellspacing='0' width='98%'>
83 <tr>
84 <td height="1" colspan="2">
85 </td>
86 </tr>
88 <tr bgcolor='#ddddff'>
89 <td align='left'>
90 <h2><? xl('Team Roster','e'); ?></h2>
91 </td>
92 <td align='right'>
93 <b><? echo date('l, F j, Y') ?></b>
94 </td>
95 </tr>
97 <tr>
98 <td height="1" colspan="2">
99 </td>
100 </tr>
102 </table>
104 <table border='0' cellpadding='1' cellspacing='2' width='98%'>
106 <tr bgcolor="#dddddd">
107 <td class="dehead">
108 &nbsp;<? xl('Squad','e'); ?>
109 </td>
110 <td class="dehead">
111 &nbsp;<? xl('Player','e'); ?>
112 </td>
113 <td class="dehead">
114 &nbsp;<? xl('Fitness','e'); ?>
115 </td>
116 <td class="dehead">
117 &nbsp;<? xl('Last Encounter','e'); ?>
118 </td>
119 </tr>
121 // if ($res) {
122 $lastsquad = '';
123 foreach ($ordres as $row) {
124 $squadvalue = $row['squad'];
125 $squadname = $squads[$squadvalue][3];
126 if ($squadname) {
127 if (! acl_check('squads', $squadvalue)) continue;
128 } else {
129 $squadname = "None";
131 $patient_id = $row['pid'];
132 $fitness = $row['fitness'];
133 if (! $fitness) $fitness = 1;
134 $query = "SELECT date, reason " .
135 "FROM form_encounter WHERE " .
136 "pid = '$patient_id' " .
137 "ORDER BY date DESC LIMIT 1";
138 $erow = sqlQuery($query);
140 <tr>
141 <td class="detail">
142 &nbsp;<? echo ($squadname == $lastsquad) ? "" : $squadname ?>
143 </td>
144 <td class="detail" bgcolor="<? echo $fitcolors[$fitness-1] ?>">
145 &nbsp;<a href='javascript:gopid(<? echo $patient_id ?>)' style='color:#000000'><? echo $row['lname'] . ", " . $row['fname'] ?></a>
146 </td>
147 <td class="detail" bgcolor="<? echo $fitcolors[$fitness-1] ?>">
148 <? echo $fitnesses[$fitness-1] ?>&nbsp;
149 </td>
150 <td class="detail" bgcolor="<? echo $fitcolors[$fitness-1] ?>">
151 &nbsp;<?php
152 if ($auth_notes_a) {
153 echo substr($erow['date'], 0, 10) . ' ' . $erow['reason'];
154 } else {
155 echo '(No access)';
157 ?>&nbsp;
158 </td>
159 </tr>
161 $lastsquad = $squadname;
163 // }
166 </table>
168 </form>
169 </center>
170 <script>
172 if ($alertmsg) {
173 echo " alert('$alertmsg');\n";
176 </script>
177 </body>
178 </html>