2 // Copyright (C) 2005-2011 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 lists all players/patients by name within squad.
10 // It is applicable only for sports teams.
12 require_once("../globals.php");
13 require_once("$srcdir/patient.inc");
14 require_once("$srcdir/acl.inc");
15 require_once("$srcdir/calendar_events.inc.php");
17 // Temporary variable while new logic is being tested.
18 // True means that missing days in the daily_fitness table default to
19 // the previous entry's values, if there is one.
20 // Otherwise the default fitness level (Fully Fit) is used.
23 $squads = acl_get_squads();
24 $auth_notes_a = acl_check('encounters', 'notes_a');
26 $alertmsg = ''; // not used yet but maybe later
28 $form_date = fixDate($_POST['form_date'], date('Y-m-d'));
31 $now = mktime(0, 0, 0, substr($form_date, 5, 2),
32 substr($form_date, 8, 2), substr($form_date, 0, 4));
34 // Get attributes of the default fitless level.
35 $fdefault = sqlQuery("SELECT * FROM list_options WHERE " .
36 "list_id = 'fitness' ORDER BY is_default DESC, seq ASC LIMIT 1");
38 $query = "SELECT pid, squad, fitness, lname, fname FROM patient_data";
39 $res = sqlStatement($query);
41 // Sort the patients in squad priority order.
42 function patient_compare($a, $b) {
44 if ($squads[$a['squad']][3] == $squads[$b['squad']][3]) {
45 if ($a['lname'] == $b['lname']) {
46 return ($a['fname'] < $b['fname']) ?
-1 : 1;
48 return ($a['lname'] < $b['lname']) ?
-1 : 1;
50 // The squads are different so compare their order attributes,
51 // or unassigned squads sort last.
52 if (! $squads[$a['squad']][3]) return 1;
53 if (! $squads[$b['squad']][3]) return -1;
54 return ($squads[$a['squad']][2] < $squads[$b['squad']][2]) ?
-1 : 1;
59 while ($row = sqlFetchArray($res)) $ordres[] = $row;
60 usort($ordres, "patient_compare");
65 <?php
html_header_show(); ?
>
66 <link rel
=stylesheet href
="<?php echo $css_header;?>" type
="text/css">
68 <style type
="text/css">
71 <?php
if (empty($_GET['embed'])) { ?
>
72 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/topdialog.js"></script
>
74 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/dialog.js"></script
>
75 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/js/jquery.js"></script
>
76 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/js/ajtooltip.js"></script
>
77 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/textformat.js"></script
>
79 <script language
="JavaScript">
80 <?php
if (empty($_GET['embed'])) require($GLOBALS['srcdir'] . "/restoreSession.php"); ?
>
82 var mypcc
= '<?php echo $GLOBALS['phone_country_code
'] ?>';
86 $maintop = $_GET['embed'] ?
"top" : "opener.top";
87 echo " $maintop.restoreSession();\n";
88 if ($GLOBALS['concurrent_layout']) {
89 echo " $maintop.RTop.location = '../patient_file/summary/demographics.php?set_pid=' + pid;\n";
90 // echo " $maintop.left_nav.forceDual();\n"; // Decided not to do this.
92 echo " $maintop.location = '../patient_file/patient_file.php?set_pid=' + pid;\n";
94 if (empty($_GET['embed'])) echo " window.close();\n";
98 // Process click to pop up the dialog window.
99 function rosdlgclick(pid
, date
) {
100 cascwin('players_report_dialog.php?plid=' + pid +
'&date=' + date
,
101 '_blank', 850, 550, "resizable=1,scrollbars=1");
104 function mov1(elem
, plid
) {
105 ttMouseOver(elem
, "players_report_ajax.php?plid=" + plid
);
108 function mov2(elem
, plid
, date
) {
109 ttMouseOver(elem
, "players_report_ajax.php?plid=" + plid +
"&date=" + date
);
112 function refreshme() {
113 // location.reload();
114 document
.forms
[0].submit();
119 <title
><?php
xl('Weekly Exposures','e'); ?
></title
>
122 <body leftmargin
='0' topmargin
='0' marginwidth
='0' marginheight
='0'>
125 <form method
='post' action
='players_report.php<?php if (!empty($_GET['embed
'])) echo "?embed=1"; ?>'>
127 <table border
='0' cellpadding
='5' cellspacing
='0' width
='98%'>
130 <td height
="1" colspan
="2">
134 <tr bgcolor
='#ddddff'>
136 <h2
><?php
xl('Weekly Exposures','e'); ?
></h2
>
139 <b
><?php
echo date('l, F j, Y', $now) ?
></b
> 
;
140 <input type
='text' name
='form_date' id
='form_date' size
='10' value
='<?php echo date('Y
-m
-d
', $now) ?>'
141 onkeyup
='datekeyup(this,mypcc)' onblur
='dateblur(this,mypcc)' title
='yyyy-mm-dd'>
142 <img src
='../pic/show_calendar.gif' align
='absbottom' width
='24' height
='22'
143 id
='img_date' border
='0' alt
='[?]' style
='cursor:pointer'
144 title
='<?php xl('Click here to choose a start date
','e
'); ?>'>
146 <input type
='submit' name
='form_refresh' value
='<?php xl('Refresh
','e
'); ?>'>
151 <td height
="1" colspan
="2">
157 <table border
='0' cellpadding
='1' cellspacing
='2' width
='98%'>
159 <tr bgcolor
="#dddddd">
161  
;<?php
xl('Squad','e'); ?
>
164  
;<?php
xl('Player','e'); ?
>
169 for ($day = 0; $day < 8; ++
$day) {
170 echo " <td class='dehead' colspan='2' align='center'>";
171 echo date('D', $time);
173 $time +
= 60 * 60 * 24;
179 foreach ($ordres as $row) {
180 $squadvalue = $row['squad'];
181 $squadname = $squads[$squadvalue][3];
183 if (! acl_check('squads', $squadvalue)) continue;
187 $patient_id = $row['pid'];
191  
;<?php
echo ($squadname == $lastsquad) ?
"" : $squadname ?
>
194  
;<a href
='javascript:gopid(<?php echo $patient_id ?>)' style
='color:#000000'><?php
echo $row['lname'] . ", " . $row['fname'] ?
></a
>
198 for ($day = 0; $day < 8; ++
$day) {
199 $date = date('Y-m-d', $time);
200 $ymd = date('Ymd', $time);
203 // For a given date, fitness info is the last on or before that date,
204 // or if there is none then the defaults apply.
205 $dfrow = sqlQuery("SELECT df.*, lf.title AS lf_title, lf.mapping AS lf_mapping " .
206 "FROM daily_fitness AS df " .
207 "LEFT JOIN list_options AS lf ON lf.list_id = 'fitness' AND lf.option_id = df.fitness " .
208 "WHERE df.pid = '$patient_id' AND df.date <= '$date' " .
209 "ORDER BY df.date DESC LIMIT 1");
212 $dfrow = sqlQuery("SELECT df.*, lf.title AS lf_title, lf.mapping AS lf_mapping " .
213 "FROM daily_fitness AS df " .
214 "LEFT JOIN list_options AS lf ON lf.list_id = 'fitness' AND lf.option_id = df.fitness " .
215 "WHERE df.pid = '$patient_id' AND df.date = '$date'");
220 'fitness' => $fdefault['option_id'],
221 'lf_title' => $fdefault['title'],
222 'lf_mapping' => $fdefault['mapping'],
228 $mapping = explode(':', $dfrow['lf_mapping']);
229 $bgcolor = $mapping[0];
231 // Compute percentage of participation.
234 $eres = getSquadEvents($date, $squadvalue, $patient_id);
236 while ($erow = sqlFetchArray($eres)) {
237 if (!eventMatchesDay($erow, $date)) continue;
238 $duration = (int) ($erow['pc_duration'] / 60);
239 $eventmins +
= $duration;
240 if (empty($erow['pid']) ||
$erow['minutes'] > $duration) {
241 $partmins +
= $duration;
244 $partmins +
= $erow['minutes'];
248 echo " <td class='detail' " .
249 "bgcolor='$bgcolor' " .
250 "onclick='rosdlgclick($patient_id,$ymd)' " .
251 "onmouseover='mov1(this,$patient_id)' " .
252 "onmouseout='ttMouseOut()' " .
254 if ($PROPLOGIC && (empty($dfrow['date']) ||
$dfrow['date'] != $date))
255 echo '<i>' . $mapping[1] . '</i>';
259 echo " <td class='detail' align='right' " .
260 "bgcolor='$bgcolor' " .
261 "style='width:40pt;' " .
262 "onclick='rosdlgclick($patient_id,$ymd)' " .
263 "onmouseover='mov2(this,$patient_id,$ymd)' " .
264 "onmouseout='ttMouseOut()' " .
266 if ($partmins < $eventmins) {
267 echo ((int)($partmins * 100 / $eventmins)) . "%\n";
271 $time +
= 60 * 60 * 24;
276 $lastsquad = $squadname;
286 style
='position:absolute;width:500px;border:1px solid black;padding:2px;background-color:#ffffaa;visibility:hidden;z-index:1000;font-size:9pt;'
292 echo " alert('$alertmsg');\n";
296 <!-- stuff
for the popup calendar
-->
297 <style type
="text/css">@import
url(../../library
/dynarch_calendar
.css
);</style
>
298 <script type
="text/javascript" src
="../../library/dynarch_calendar.js"></script
>
299 <?php
include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?
>
300 <script type
="text/javascript" src
="../../library/dynarch_calendar_setup.js"></script
>
301 <script language
="Javascript">
302 Calendar
.setup({inputField
:"form_date", ifFormat
:"%Y-%m-%d", button
:"img_date"});