2 // Copyright (C) 2005-2010 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 /*********************************************************************
22 // Get fitness level names and colors.
23 $PLAYER_FITNESSES = array();
24 $fres = sqlStatement("SELECT * FROM list_options WHERE " .
25 "list_id = 'fitness' ORDER BY seq");
26 while ($frow = sqlFetchArray($fres)) $PLAYER_FITNESSES[] = $frow['title'];
27 if (!empty($GLOBALS['fitness_colors'])) $PLAYER_FITCOLORS = $GLOBALS['fitness_colors'];
28 *********************************************************************/
29 // Get attributes of the default fitless level.
30 $fdefault = sqlQuery("SELECT * FROM list_options WHERE " .
31 "list_id = 'fitness' ORDER BY is_default DESC, seq ASC LIMIT 1");
32 /********************************************************************/
34 $query = "SELECT pid, squad, lname, fname FROM " .
35 "patient_data"; // ORDER BY squad, lname, fname
36 $res = sqlStatement($query);
38 // Sort the patients in squad priority order.
39 function patient_compare($a, $b) {
41 if ($squads[$a['squad']][3] == $squads[$b['squad']][3]) {
42 if ($a['lname'] == $b['lname']) {
43 return ($a['fname'] < $b['fname']) ?
-1 : 1;
45 return ($a['lname'] < $b['lname']) ?
-1 : 1;
47 // The squads are different so compare their order attributes,
48 // or unassigned squads sort last.
49 if (! $squads[$a['squad']][3]) return 1;
50 if (! $squads[$b['squad']][3]) return -1;
51 return ($squads[$a['squad']][2] < $squads[$b['squad']][2]) ?
-1 : 1;
55 while ($row = sqlFetchArray($res)) $ordres[] = $row;
56 usort($ordres, "patient_compare");
61 <?
html_header_show();?
>
62 <link rel
=stylesheet href
="<?php echo $css_header;?>" type
="text/css">
64 <script language
="JavaScript">
68 $maintop = $_GET['embed'] ?
"top" : "opener.top";
69 echo " $maintop.restoreSession();\n";
70 if ($GLOBALS['concurrent_layout']) {
72 echo " $maintop.RTop.location = '../patient_file/summary/demographics.php?set_pid=' + pid;\n";
75 echo " $maintop.location = '../patient_file/patient_file.php?set_pid=' + pid;\n";
77 if (empty($_GET['embed'])) echo " window.close();\n";
83 <title
><?php
xl('Team Roster','e'); ?
></title
>
86 <body leftmargin
='0' topmargin
='0' marginwidth
='0' marginheight
='0'>
89 <form method
='post' action
='old_players_report.php'>
91 <table border
='0' cellpadding
='5' cellspacing
='0' width
='98%'>
94 <td height
="1" colspan
="2">
98 <tr bgcolor
='#ddddff'>
100 <h2
><?php
xl('Team Roster','e'); ?
></h2
>
103 <b
><?php
echo date('l, F j, Y') ?
></b
>
108 <td height
="1" colspan
="2">
114 <table border
='0' cellpadding
='1' cellspacing
='2' width
='98%'>
116 <tr bgcolor
="#dddddd">
118  
;<?php
xl('Squad','e'); ?
>
121  
;<?php
xl('Player','e'); ?
>
124  
;<?php
xl('Fitness','e'); ?
>
127  
;<?php
xl('Last Encounter','e'); ?
>
133 foreach ($ordres as $row) {
134 $squadvalue = $row['squad'];
135 $squadname = $squads[$squadvalue][3];
137 if (! acl_check('squads', $squadvalue)) continue;
141 $patient_id = $row['pid'];
143 /******************************************************************
144 $fitness = $row['fitness'];
145 if (! $fitness) $fitness = 1;
146 ******************************************************************/
147 $date = date('Y-m-d');
148 $dfrow = sqlQuery("SELECT df.*, lf.title AS lf_title, lf.mapping AS lf_mapping " .
149 "FROM daily_fitness AS df " .
150 "LEFT JOIN list_options AS lf ON lf.list_id = 'fitness' AND lf.option_id = df.fitness " .
151 "WHERE df.pid = '$patient_id' AND df.date = '$date'");
154 'fitness' => $fdefault['option_id'],
155 'lf_title' => $fdefault['title'],
156 'lf_mapping' => $fdefault['mapping'],
159 $mapping = explode(':', $dfrow['lf_mapping']);
160 $bgcolor = $mapping[0];
161 /*****************************************************************/
163 $query = "SELECT date, reason " .
164 "FROM form_encounter WHERE " .
165 "pid = '$patient_id' " .
166 "ORDER BY date DESC LIMIT 1";
167 $erow = sqlQuery($query);
171  
;<?php
echo ($squadname == $lastsquad) ?
"" : $squadname ?
>
173 <td
class="detail" bgcolor
="<?php echo $bgcolor ?>">
174  
;<a href
='javascript:gopid(<?php echo $patient_id ?>)' style
='color:#000000'><?php
echo $row['lname'] . ", " . $row['fname'] ?
></a
>
176 <td
class="detail" bgcolor
="<?php echo $bgcolor ?>">
177 <?php
echo $dfrow['lf_title'] ?
> 
;
179 <td
class="detail" bgcolor
="<?php echo $bgcolor ?>">
182 echo substr($erow['date'], 0, 10) . ' ' . $erow['reason'];
190 $lastsquad = $squadname;
202 echo " alert('$alertmsg');\n";