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');
19 $alertmsg = ''; // not used yet but maybe later
21 // Get fitness level names and colors.
22 $PLAYER_FITNESSES = array();
23 $fres = sqlStatement("SELECT * FROM list_options WHERE " .
24 "list_id = 'fitness' ORDER BY seq");
25 while ($frow = sqlFetchArray($fres)) $PLAYER_FITNESSES[] = $frow['title'];
26 if (!empty($GLOBALS['fitness_colors'])) $PLAYER_FITCOLORS = $GLOBALS['fitness_colors'];
28 $query = "SELECT pid, squad, fitness, lname, fname FROM " .
29 "patient_data"; // ORDER BY squad, lname, fname
30 $res = sqlStatement($query);
32 // Sort the patients in squad priority order.
33 function patient_compare($a, $b) {
35 if ($squads[$a['squad']][3] == $squads[$b['squad']][3]) {
36 if ($a['lname'] == $b['lname']) {
37 return ($a['fname'] < $b['fname']) ?
-1 : 1;
39 return ($a['lname'] < $b['lname']) ?
-1 : 1;
41 // The squads are different so compare their order attributes,
42 // or unassigned squads sort last.
43 if (! $squads[$a['squad']][3]) return 1;
44 if (! $squads[$b['squad']][3]) return -1;
45 return ($squads[$a['squad']][2] < $squads[$b['squad']][2]) ?
-1 : 1;
49 while ($row = sqlFetchArray($res)) $ordres[] = $row;
50 usort($ordres, "patient_compare");
55 <?
html_header_show();?
>
56 <link rel
=stylesheet href
="<?php echo $css_header;?>" type
="text/css">
58 <script language
="JavaScript">
62 $maintop = $_GET['embed'] ?
"top" : "opener.top";
63 echo " $maintop.restoreSession();\n";
64 if ($GLOBALS['concurrent_layout']) {
65 if( $GLOBALS['dutchpc'] ) {
66 echo " $maintop.RTop.location = '../patient_file/summary/demographics_dutch.php?set_pid=' + pid;\n";
68 echo " $maintop.RTop.location = '../patient_file/summary/demographics.php?set_pid=' + pid;\n";
71 echo " $maintop.location = '../patient_file/patient_file.php?set_pid=' + pid;\n";
73 if (empty($_GET['embed'])) echo " window.close();\n";
79 <title
><?php
xl('Team Roster','e'); ?
></title
>
82 <body leftmargin
='0' topmargin
='0' marginwidth
='0' marginheight
='0'>
85 <form method
='post' action
='players_report.php'>
87 <table border
='0' cellpadding
='5' cellspacing
='0' width
='98%'>
90 <td height
="1" colspan
="2">
94 <tr bgcolor
='#ddddff'>
96 <h2
><?php
xl('Team Roster','e'); ?
></h2
>
99 <b
><?php
echo date('l, F j, Y') ?
></b
>
104 <td height
="1" colspan
="2">
110 <table border
='0' cellpadding
='1' cellspacing
='2' width
='98%'>
112 <tr bgcolor
="#dddddd">
114  
;<?php
xl('Squad','e'); ?
>
117  
;<?php
xl('Player','e'); ?
>
120  
;<?php
xl('Fitness','e'); ?
>
123  
;<?php
xl('Last Encounter','e'); ?
>
129 foreach ($ordres as $row) {
130 $squadvalue = $row['squad'];
131 $squadname = $squads[$squadvalue][3];
133 if (! acl_check('squads', $squadvalue)) continue;
137 $patient_id = $row['pid'];
138 $fitness = $row['fitness'];
139 if (! $fitness) $fitness = 1;
140 $query = "SELECT date, reason " .
141 "FROM form_encounter WHERE " .
142 "pid = '$patient_id' " .
143 "ORDER BY date DESC LIMIT 1";
144 $erow = sqlQuery($query);
148  
;<?php
echo ($squadname == $lastsquad) ?
"" : $squadname ?
>
150 <td
class="detail" bgcolor
="<?php echo $PLAYER_FITCOLORS[$fitness-1] ?>">
151  
;<a href
='javascript:gopid(<?php echo $patient_id ?>)' style
='color:#000000'><?php
echo $row['lname'] . ", " . $row['fname'] ?
></a
>
153 <td
class="detail" bgcolor
="<?php echo $PLAYER_FITCOLORS[$fitness-1] ?>">
154 <?php
echo $PLAYER_FITNESSES[$fitness-1] ?
> 
;
156 <td
class="detail" bgcolor
="<?php echo $PLAYER_FITCOLORS[$fitness-1] ?>">
159 echo substr($erow['date'], 0, 10) . ' ' . $erow['reason'];
167 $lastsquad = $squadname;
179 echo " alert('$alertmsg');\n";