added a couple of fitness attributes for sports teams
[openemr.git] / interface / reports / players_report.php
blobb2381ae0b3d1ba3605c6a0e04031123e2a513249
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',
25 'Illness',
26 'International Duty'
29 $fitcolors = array('#6677ff', '#00cc00', '#ffff00', '#ff3333', '#ff8800', '#ffeecc', '#ffccaa');
31 $alertmsg = ''; // not used yet but maybe later
33 $query = "SELECT pid, squad, fitness, lname, fname FROM " .
34 "patient_data"; // ORDER BY squad, lname, fname
35 $res = sqlStatement($query);
37 // Sort the patients in squad priority order.
38 function patient_compare($a, $b) {
39 global $squads;
40 if ($squads[$a['squad']][3] == $squads[$b['squad']][3]) {
41 if ($a['lname'] == $b['lname']) {
42 return ($a['fname'] < $b['fname']) ? -1 : 1;
44 return ($a['lname'] < $b['lname']) ? -1 : 1;
46 // The squads are different so compare their order attributes,
47 // or unassigned squads sort last.
48 if (! $squads[$a['squad']][3]) return 1;
49 if (! $squads[$b['squad']][3]) return -1;
50 return ($squads[$a['squad']][2] < $squads[$b['squad']][2]) ? -1 : 1;
52 $ordres = array();
53 if ($res) {
54 while ($row = sqlFetchArray($res)) $ordres[] = $row;
55 usort($ordres, "patient_compare");
58 <html>
59 <head>
60 <link rel=stylesheet href="<?echo $css_header;?>" type="text/css">
62 <script language="JavaScript">
64 function gopid(pid) {
65 <? if ($_GET['embed']) { ?>
66 top.location = '../patient_file/patient_file.php?set_pid=' + pid;
67 <? } else { ?>
68 opener.top.location = '../patient_file/patient_file.php?set_pid=' + pid;
69 window.close();
70 <? } ?>
73 </script>
75 <title><? xl('Team Roster','e'); ?></title>
76 </head>
78 <body leftmargin='0' topmargin='0' marginwidth='0' marginheight='0'>
79 <center>
81 <form method='post' action='players_report.php'>
83 <table border='0' cellpadding='5' cellspacing='0' width='98%'>
85 <tr>
86 <td height="1" colspan="2">
87 </td>
88 </tr>
90 <tr bgcolor='#ddddff'>
91 <td align='left'>
92 <h2><? xl('Team Roster','e'); ?></h2>
93 </td>
94 <td align='right'>
95 <b><? echo date('l, F j, Y') ?></b>
96 </td>
97 </tr>
99 <tr>
100 <td height="1" colspan="2">
101 </td>
102 </tr>
104 </table>
106 <table border='0' cellpadding='1' cellspacing='2' width='98%'>
108 <tr bgcolor="#dddddd">
109 <td class="dehead">
110 &nbsp;<? xl('Squad','e'); ?>
111 </td>
112 <td class="dehead">
113 &nbsp;<? xl('Player','e'); ?>
114 </td>
115 <td class="dehead">
116 &nbsp;<? xl('Fitness','e'); ?>
117 </td>
118 <td class="dehead">
119 &nbsp;<? xl('Last Encounter','e'); ?>
120 </td>
121 </tr>
123 // if ($res) {
124 $lastsquad = '';
125 foreach ($ordres as $row) {
126 $squadvalue = $row['squad'];
127 $squadname = $squads[$squadvalue][3];
128 if ($squadname) {
129 if (! acl_check('squads', $squadvalue)) continue;
130 } else {
131 $squadname = "None";
133 $patient_id = $row['pid'];
134 $fitness = $row['fitness'];
135 if (! $fitness) $fitness = 1;
136 $query = "SELECT date, reason " .
137 "FROM form_encounter WHERE " .
138 "pid = '$patient_id' " .
139 "ORDER BY date DESC LIMIT 1";
140 $erow = sqlQuery($query);
142 <tr>
143 <td class="detail">
144 &nbsp;<? echo ($squadname == $lastsquad) ? "" : $squadname ?>
145 </td>
146 <td class="detail" bgcolor="<? echo $fitcolors[$fitness-1] ?>">
147 &nbsp;<a href='javascript:gopid(<? echo $patient_id ?>)' style='color:#000000'><? echo $row['lname'] . ", " . $row['fname'] ?></a>
148 </td>
149 <td class="detail" bgcolor="<? echo $fitcolors[$fitness-1] ?>">
150 <? echo $fitnesses[$fitness-1] ?>&nbsp;
151 </td>
152 <td class="detail" bgcolor="<? echo $fitcolors[$fitness-1] ?>">
153 &nbsp;<?php
154 if ($auth_notes_a) {
155 echo substr($erow['date'], 0, 10) . ' ' . $erow['reason'];
156 } else {
157 echo '(No access)';
159 ?>&nbsp;
160 </td>
161 </tr>
163 $lastsquad = $squadname;
165 // }
168 </table>
170 </form>
171 </center>
172 <script>
174 if ($alertmsg) {
175 echo " alert('$alertmsg');\n";
178 </script>
179 </body>
180 </html>