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 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 $squads = acl_get_squads();
18 $auth_notes_a = acl_check('encounters', 'notes_a');
20 $alertmsg = ''; // not used yet but maybe later
22 $form_date = fixDate($_POST['form_date'], date('Y-m-d'));
25 $now = mktime(0, 0, 0, substr($form_date, 5, 2),
26 substr($form_date, 8, 2), substr($form_date, 0, 4));
28 // Get attributes of the default fitless level.
29 $fdefault = sqlQuery("SELECT * FROM list_options WHERE " .
30 "list_id = 'fitness' ORDER BY is_default DESC, seq ASC LIMIT 1");
32 $query = "SELECT pid, squad, fitness, lname, fname FROM patient_data";
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;
53 while ($row = sqlFetchArray($res)) $ordres[] = $row;
54 usort($ordres, "patient_compare");
59 <?php
html_header_show(); ?
>
60 <link rel
=stylesheet href
="<?php echo $css_header;?>" type
="text/css">
62 <style type
="text/css">
65 <?php
if (empty($_GET['embed'])) { ?
>
66 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/topdialog.js"></script
>
68 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/dialog.js"></script
>
69 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/js/jquery.js"></script
>
70 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/js/ajtooltip.js"></script
>
71 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/textformat.js"></script
>
73 <script language
="JavaScript">
74 <?php
if (empty($_GET['embed'])) require($GLOBALS['srcdir'] . "/restoreSession.php"); ?
>
76 var mypcc
= '<?php echo $GLOBALS['phone_country_code
'] ?>';
80 $maintop = $_GET['embed'] ?
"top" : "opener.top";
81 echo " $maintop.restoreSession();\n";
82 if ($GLOBALS['concurrent_layout']) {
83 echo " $maintop.RTop.location = '../patient_file/summary/demographics.php?set_pid=' + pid;\n";
84 echo " $maintop.left_nav.forceDual();\n";
86 echo " $maintop.location = '../patient_file/patient_file.php?set_pid=' + pid;\n";
88 if (empty($_GET['embed'])) echo " window.close();\n";
92 // Process click to pop up the dialog window.
93 function rosdlgclick(pid
, date
) {
94 cascwin('players_report_dialog.php?plid=' + pid +
'&date=' + date
,
95 '_blank', 850, 550, "resizable=1,scrollbars=1");
98 function mov1(elem
, plid
) {
99 ttMouseOver(elem
, "players_report_ajax.php?plid=" + plid
);
102 function mov2(elem
, plid
, date
) {
103 ttMouseOver(elem
, "players_report_ajax.php?plid=" + plid +
"&date=" + date
);
106 function refreshme() {
107 // location.reload();
108 document
.forms
[0].submit();
113 <title
><?php
xl('Weekly Exposures','e'); ?
></title
>
116 <body leftmargin
='0' topmargin
='0' marginwidth
='0' marginheight
='0'>
119 <form method
='post' action
='players_report.php<?php if (!empty($_GET['embed
'])) echo "?embed=1"; ?>'>
121 <table border
='0' cellpadding
='5' cellspacing
='0' width
='98%'>
124 <td height
="1" colspan
="2">
128 <tr bgcolor
='#ddddff'>
130 <h2
><?php
xl('Weekly Exposures','e'); ?
></h2
>
133 <b
><?php
echo date('l, F j, Y', $now) ?
></b
> 
;
134 <input type
='text' name
='form_date' id
='form_date' size
='10' value
='<?php echo date('Y
-m
-d
', $now) ?>'
135 onkeyup
='datekeyup(this,mypcc)' onblur
='dateblur(this,mypcc)' title
='yyyy-mm-dd'>
136 <img src
='../pic/show_calendar.gif' align
='absbottom' width
='24' height
='22'
137 id
='img_date' border
='0' alt
='[?]' style
='cursor:pointer'
138 title
='<?php xl('Click here to choose a start date
','e
'); ?>'>
140 <input type
='submit' name
='form_refresh' value
='<?php xl('Refresh
','e
'); ?>'>
145 <td height
="1" colspan
="2">
151 <table border
='0' cellpadding
='1' cellspacing
='2' width
='98%'>
153 <tr bgcolor
="#dddddd">
155  
;<?php
xl('Squad','e'); ?
>
158  
;<?php
xl('Player','e'); ?
>
163 for ($day = 0; $day < 8; ++
$day) {
164 echo " <td class='dehead' colspan='2' align='center'>";
165 echo date('D', $time);
167 $time +
= 60 * 60 * 24;
173 foreach ($ordres as $row) {
174 $squadvalue = $row['squad'];
175 $squadname = $squads[$squadvalue][3];
177 if (! acl_check('squads', $squadvalue)) continue;
181 $patient_id = $row['pid'];
185  
;<?php
echo ($squadname == $lastsquad) ?
"" : $squadname ?
>
188  
;<a href
='javascript:gopid(<?php echo $patient_id ?>)' style
='color:#000000'><?php
echo $row['lname'] . ", " . $row['fname'] ?
></a
>
192 for ($day = 0; $day < 8; ++
$day) {
193 $date = date('Y-m-d', $time);
194 $ymd = date('Ymd', $time);
196 $dfrow = sqlQuery("SELECT df.*, lf.title AS lf_title, lf.mapping AS lf_mapping " .
197 "FROM daily_fitness AS df " .
198 "LEFT JOIN list_options AS lf ON lf.list_id = 'fitness' AND lf.option_id = df.fitness " .
199 "WHERE df.pid = '$patient_id' AND df.date = '$date'");
203 'fitness' => $fdefault['option_id'],
204 'lf_title' => $fdefault['title'],
205 'lf_mapping' => $fdefault['mapping'],
211 $mapping = explode(':', $dfrow['lf_mapping']);
212 $bgcolor = $mapping[0];
214 // Compute percentage of participation.
217 $eres = getSquadEvents($date, $squadvalue, $patient_id);
219 while ($erow = sqlFetchArray($eres)) {
220 if (!eventMatchesDay($erow, $date)) continue;
221 $duration = (int) ($erow['pc_duration'] / 60);
222 $eventmins +
= $duration;
223 if (empty($erow['pid']) ||
$erow['minutes'] > $duration) {
224 $partmins +
= $duration;
227 $partmins +
= $erow['minutes'];
231 echo " <td class='detail' " .
232 "bgcolor='$bgcolor' " .
233 "onclick='rosdlgclick($patient_id,$ymd)' " .
234 "onmouseover='mov1(this,$patient_id)' " .
235 "onmouseout='ttMouseOut()' " .
239 echo " <td class='detail' align='right' " .
240 "bgcolor='$bgcolor' " .
241 "style='width:40pt;' " .
242 "onclick='rosdlgclick($patient_id,$ymd)' " .
243 "onmouseover='mov2(this,$patient_id,$ymd)' " .
244 "onmouseout='ttMouseOut()' " .
246 if ($partmins < $eventmins) {
247 echo ((int)($partmins * 100 / $eventmins)) . "%\n";
251 $time +
= 60 * 60 * 24;
256 $lastsquad = $squadname;
266 style
='position:absolute;width:500px;border:1px solid black;padding:2px;background-color:#ffffaa;visibility:hidden;z-index:1000;font-size:9pt;'
272 echo " alert('$alertmsg');\n";
276 <!-- stuff
for the popup calendar
-->
277 <style type
="text/css">@import
url(../../library
/dynarch_calendar
.css
);</style
>
278 <script type
="text/javascript" src
="../../library/dynarch_calendar.js"></script
>
279 <?php
include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?
>
280 <script type
="text/javascript" src
="../../library/dynarch_calendar_setup.js"></script
>
281 <script language
="Javascript">
282 Calendar
.setup({inputField
:"form_date", ifFormat
:"%Y-%m-%d", button
:"img_date"});