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();
17 $auth_notes_a = acl_check('encounters', 'notes_a');
22 'Restricted Training',
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) {
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;
52 while ($row = sqlFetchArray($res)) $ordres[] = $row;
53 usort($ordres, "patient_compare");
58 <link rel
=stylesheet href
="<?echo $css_header;?>" type
="text/css">
60 <script language
="JavaScript">
63 <?
if ($_GET['embed']) { ?
>
64 top
.location
= '../patient_file/patient_file.php?set_pid=' + pid
;
66 opener
.top
.location
= '../patient_file/patient_file.php?set_pid=' + pid
;
73 <title
><?
xl('Team Roster','e'); ?
></title
>
76 <body leftmargin
='0' topmargin
='0' marginwidth
='0' marginheight
='0'>
79 <form method
='post' action
='players_report.php'>
81 <table border
='0' cellpadding
='5' cellspacing
='0' width
='98%'>
84 <td height
="1" colspan
="2">
88 <tr bgcolor
='#ddddff'>
90 <h2
><?
xl('Team Roster','e'); ?
></h2
>
93 <b
><?
echo date('l, F j, Y') ?
></b
>
98 <td height
="1" colspan
="2">
104 <table border
='0' cellpadding
='1' cellspacing
='2' width
='98%'>
106 <tr bgcolor
="#dddddd">
108  
;<?
xl('Squad','e'); ?
>
111  
;<?
xl('Player','e'); ?
>
114  
;<?
xl('Fitness','e'); ?
>
117  
;<?
xl('Last Encounter','e'); ?
>
123 foreach ($ordres as $row) {
124 $squadvalue = $row['squad'];
125 $squadname = $squads[$squadvalue][3];
127 if (! acl_check('squads', $squadvalue)) continue;
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);
142  
;<?
echo ($squadname == $lastsquad) ?
"" : $squadname ?
>
144 <td
class="detail" bgcolor
="<? echo $fitcolors[$fitness-1] ?>">
145  
;<a href
='javascript:gopid(<? echo $patient_id ?>)' style
='color:#000000'><?
echo $row['lname'] . ", " . $row['fname'] ?
></a
>
147 <td
class="detail" bgcolor
="<? echo $fitcolors[$fitness-1] ?>">
148 <?
echo $fitnesses[$fitness-1] ?
> 
;
150 <td
class="detail" bgcolor
="<? echo $fitcolors[$fitness-1] ?>">
153 echo substr($erow['date'], 0, 10) . ' ' . $erow['reason'];
161 $lastsquad = $squadname;
173 echo " alert('$alertmsg');\n";