2 // Copyright (C) 2005 Rod Roark <rod@sunsetsystems.com>
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();
21 'Restricted Training',
26 $fitcolors = array('#6677ff', '#00cc00', '#ffff00', '#ff3333', '#ff8800');
28 $alertmsg = ''; // not used yet but maybe later
30 $query = "SELECT pid, squad, fitness, lname, fname FROM " .
31 "patient_data"; // ORDER BY squad, lname, fname
32 $res = sqlStatement($query);
34 // Sort the patients in squad priority order.
35 function patient_compare($a, $b) {
37 if ($squads[$a['squad']][3] == $squads[$b['squad']][3]) {
38 if ($a['lname'] == $b['lname']) {
39 return ($a['fname'] < $b['fname']) ?
-1 : 1;
41 return ($a['lname'] < $b['lname']) ?
-1 : 1;
43 // The squads are different so compare their order attributes,
44 // or unassigned squads sort last.
45 if (! $squads[$a['squad']][3]) return 1;
46 if (! $squads[$b['squad']][3]) return -1;
47 return ($squads[$a['squad']][2] < $squads[$b['squad']][2]) ?
-1 : 1;
51 while ($row = sqlFetchArray($res)) $ordres[] = $row;
52 usort($ordres, "patient_compare");
57 <link rel
=stylesheet href
="<?echo $css_header;?>" type
="text/css">
59 <script language
="JavaScript">
62 <?
if ($_GET['embed']) { ?
>
63 top
.location
= '../patient_file/patient_file.php?set_pid=' + pid
;
65 opener
.top
.location
= '../patient_file/patient_file.php?set_pid=' + pid
;
72 <title
>Team Roster
</title
>
75 <body leftmargin
='0' topmargin
='0' marginwidth
='0' marginheight
='0'>
78 <form method
='post' action
='players_report.php'>
80 <table border
='0' cellpadding
='5' cellspacing
='0' width
='98%'>
83 <td height
="1" colspan
="2">
87 <tr bgcolor
='#ddddff'>
92 <b
><?
echo date('l, F j, Y') ?
></b
>
97 <td height
="1" colspan
="2">
103 <table border
='0' cellpadding
='1' cellspacing
='2' width
='98%'>
105 <tr bgcolor
="#dddddd">
122 foreach ($ordres as $row) {
123 $squadvalue = $row['squad'];
124 $squadname = $squads[$squadvalue][3];
126 if (! acl_check('squads', $squadvalue)) continue;
130 $patient_id = $row['pid'];
131 $fitness = $row['fitness'];
132 if (! $fitness) $fitness = 1;
133 $query = "SELECT date, reason " .
134 "FROM form_encounter WHERE " .
135 "pid = '$patient_id' " .
136 "ORDER BY date DESC LIMIT 1";
137 $erow = sqlQuery($query);
141  
;<?
echo ($squadname == $lastsquad) ?
"" : $squadname ?
>
143 <td
class="detail" bgcolor
="<? echo $fitcolors[$fitness-1] ?>">
144  
;<a href
='javascript:gopid(<? echo $patient_id ?>)' style
='color:#000000'><?
echo $row['lname'] . ", " . $row['fname'] ?
></a
>
146 <td
class="detail" bgcolor
="<? echo $fitcolors[$fitness-1] ?>">
147 <?
echo $fitnesses[$fitness-1] ?
> 
;
149 <td
class="detail" bgcolor
="<? echo $fitcolors[$fitness-1] ?>">
150  
;<?
echo substr($erow['date'], 0, 10) . ' ' . $erow['reason'] ?
> 
;
154 $lastsquad = $squadname;
166 echo " alert('$alertmsg');\n";