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";
85 echo " $maintop.location = '../patient_file/patient_file.php?set_pid=' + pid;\n";
87 if (empty($_GET['embed'])) echo " window.close();\n";
91 // Process click to pop up the dialog window.
92 function rosdlgclick(pid
, date
) {
93 cascwin('players_report_dialog.php?plid=' + pid +
'&date=' + date
,
94 '_blank', 850, 550, "resizable=1,scrollbars=1");
97 function mov1(elem
, plid
) {
98 ttMouseOver(elem
, "players_report_ajax.php?plid=" + plid
);
101 function mov2(elem
, plid
, date
) {
102 ttMouseOver(elem
, "players_report_ajax.php?plid=" + plid +
"&date=" + date
);
105 function refreshme() {
106 // location.reload();
107 document
.forms
[0].submit();
112 <title
><?php
xl('Weekly Exposures','e'); ?
></title
>
115 <body leftmargin
='0' topmargin
='0' marginwidth
='0' marginheight
='0'>
118 <form method
='post' action
='players_report.php<?php if (!empty($_GET['embed
'])) echo "?embed=1"; ?>'>
120 <table border
='0' cellpadding
='5' cellspacing
='0' width
='98%'>
123 <td height
="1" colspan
="2">
127 <tr bgcolor
='#ddddff'>
129 <h2
><?php
xl('Weekly Exposures','e'); ?
></h2
>
132 <b
><?php
echo date('l, F j, Y', $now) ?
></b
> 
;
133 <input type
='text' name
='form_date' id
='form_date' size
='10' value
='<?php echo date('Y
-m
-d
', $now) ?>'
134 onkeyup
='datekeyup(this,mypcc)' onblur
='dateblur(this,mypcc)' title
='yyyy-mm-dd'>
135 <img src
='../pic/show_calendar.gif' align
='absbottom' width
='24' height
='22'
136 id
='img_date' border
='0' alt
='[?]' style
='cursor:pointer'
137 title
='<?php xl('Click here to choose a start date
','e
'); ?>'>
139 <input type
='submit' name
='form_refresh' value
='<?php xl('Refresh
','e
'); ?>'>
144 <td height
="1" colspan
="2">
150 <table border
='0' cellpadding
='1' cellspacing
='2' width
='98%'>
152 <tr bgcolor
="#dddddd">
154  
;<?php
xl('Squad','e'); ?
>
157  
;<?php
xl('Player','e'); ?
>
162 for ($day = 0; $day < 8; ++
$day) {
163 echo " <td class='dehead' colspan='2' align='center'>";
164 echo date('D', $time);
166 $time +
= 60 * 60 * 24;
172 foreach ($ordres as $row) {
173 $squadvalue = $row['squad'];
174 $squadname = $squads[$squadvalue][3];
176 if (! acl_check('squads', $squadvalue)) continue;
180 $patient_id = $row['pid'];
184  
;<?php
echo ($squadname == $lastsquad) ?
"" : $squadname ?
>
187  
;<a href
='javascript:gopid(<?php echo $patient_id ?>)' style
='color:#000000'><?php
echo $row['lname'] . ", " . $row['fname'] ?
></a
>
191 for ($day = 0; $day < 8; ++
$day) {
192 $date = date('Y-m-d', $time);
193 $ymd = date('Ymd', $time);
195 $dfrow = sqlQuery("SELECT df.*, lf.title AS lf_title, lf.mapping AS lf_mapping " .
196 "FROM daily_fitness AS df " .
197 "LEFT JOIN list_options AS lf ON lf.list_id = 'fitness' AND lf.option_id = df.fitness " .
198 "WHERE df.pid = '$patient_id' AND df.date = '$date'");
202 'fitness' => $fdefault['option_id'],
203 'lf_title' => $fdefault['title'],
204 'lf_mapping' => $fdefault['mapping'],
210 $mapping = explode(':', $dfrow['lf_mapping']);
211 $bgcolor = $mapping[0];
213 // Compute percentage of participation.
216 $eres = getSquadEvents($date, $squadvalue, $patient_id);
218 while ($erow = sqlFetchArray($eres)) {
219 if (!eventMatchesDay($erow, $date)) continue;
220 $duration = (int) ($erow['pc_duration'] / 60);
221 $eventmins +
= $duration;
222 if (empty($erow['pid']) ||
$erow['minutes'] > $duration) {
223 $partmins +
= $duration;
226 $partmins +
= $erow['minutes'];
230 echo " <td class='detail' " .
231 "bgcolor='$bgcolor' " .
232 "onclick='rosdlgclick($patient_id,$ymd)' " .
233 "onmouseover='mov1(this,$patient_id)' " .
234 "onmouseout='ttMouseOut()' " .
238 echo " <td class='detail' align='right' " .
239 "bgcolor='$bgcolor' " .
240 "style='width:40pt;' " .
241 "onclick='rosdlgclick($patient_id,$ymd)' " .
242 "onmouseover='mov2(this,$patient_id,$ymd)' " .
243 "onmouseout='ttMouseOut()' " .
245 if ($partmins < $eventmins) {
246 echo ((int)($partmins * 100 / $eventmins)) . "%\n";
250 $time +
= 60 * 60 * 24;
255 $lastsquad = $squadname;
265 style
='position:absolute;width:500px;border:1px solid black;padding:2px;background-color:#ffffaa;visibility:hidden;z-index:1000;font-size:9pt;'
271 echo " alert('$alertmsg');\n";
275 <!-- stuff
for the popup calendar
-->
276 <style type
="text/css">@import
url(../../library
/dynarch_calendar
.css
);</style
>
277 <script type
="text/javascript" src
="../../library/dynarch_calendar.js"></script
>
278 <script type
="text/javascript" src
="../../library/dynarch_calendar_en.js"></script
>
279 <script type
="text/javascript" src
="../../library/dynarch_calendar_setup.js"></script
>
280 <script language
="Javascript">
281 Calendar
.setup({inputField
:"form_date", ifFormat
:"%Y-%m-%d", button
:"img_date"});