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',
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) {
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;
54 while ($row = sqlFetchArray($res)) $ordres[] = $row;
55 usort($ordres, "patient_compare");
60 <link rel
=stylesheet href
="<?echo $css_header;?>" type
="text/css">
62 <script language
="JavaScript">
65 <?
if ($_GET['embed']) { ?
>
66 top
.location
= '../patient_file/patient_file.php?set_pid=' + pid
;
68 opener
.top
.location
= '../patient_file/patient_file.php?set_pid=' + pid
;
75 <title
><?
xl('Team Roster','e'); ?
></title
>
78 <body leftmargin
='0' topmargin
='0' marginwidth
='0' marginheight
='0'>
81 <form method
='post' action
='players_report.php'>
83 <table border
='0' cellpadding
='5' cellspacing
='0' width
='98%'>
86 <td height
="1" colspan
="2">
90 <tr bgcolor
='#ddddff'>
92 <h2
><?
xl('Team Roster','e'); ?
></h2
>
95 <b
><?
echo date('l, F j, Y') ?
></b
>
100 <td height
="1" colspan
="2">
106 <table border
='0' cellpadding
='1' cellspacing
='2' width
='98%'>
108 <tr bgcolor
="#dddddd">
110  
;<?
xl('Squad','e'); ?
>
113  
;<?
xl('Player','e'); ?
>
116  
;<?
xl('Fitness','e'); ?
>
119  
;<?
xl('Last Encounter','e'); ?
>
125 foreach ($ordres as $row) {
126 $squadvalue = $row['squad'];
127 $squadname = $squads[$squadvalue][3];
129 if (! acl_check('squads', $squadvalue)) continue;
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);
144  
;<?
echo ($squadname == $lastsquad) ?
"" : $squadname ?
>
146 <td
class="detail" bgcolor
="<? echo $fitcolors[$fitness-1] ?>">
147  
;<a href
='javascript:gopid(<? echo $patient_id ?>)' style
='color:#000000'><?
echo $row['lname'] . ", " . $row['fname'] ?
></a
>
149 <td
class="detail" bgcolor
="<? echo $fitcolors[$fitness-1] ?>">
150 <?
echo $fitnesses[$fitness-1] ?
> 
;
152 <td
class="detail" bgcolor
="<? echo $fitcolors[$fitness-1] ?>">
155 echo substr($erow['date'], 0, 10) . ' ' . $erow['reason'];
163 $lastsquad = $squadname;
175 echo " alert('$alertmsg');\n";