2 /****************************************************************/
4 /****************************************************************/
5 /* Copyright (c) 2002-2010 */
6 /* Inclusive Design Institute */
9 /* This program is free software. You can redistribute it and/or*/
10 /* modify it under the terms of the GNU General Public License */
11 /* as published by the Free Software Foundation. */
12 /****************************************************************/
15 define('AT_INCLUDE_PATH', '../../../include/');
16 require(AT_INCLUDE_PATH.'vitals.inc.php');
17 authenticate(AT_PRIV_ADMIN, AT_PRIV_RETURN);
19 $year = intval($_GET['year']);
20 $month = intval($_GET['month']);
28 $sql = "SELECT * FROM ".TABLE_PREFIX."course_stats WHERE course_id=$_SESSION[course_id] AND MONTH(login_date)=$month AND YEAR(login_date)=$year ORDER BY login_date ASC";
29 $result = mysql_query($sql, $db);
30 //$today = 1; /* we start on the 1st of the month */
31 $max_total_logins = 0;
32 $min_total_logins = (int) 99999999;
36 while ($row = mysql_fetch_array($result)) {
38 $row_day = substr($row['login_date'], 8, 2);
40 if (substr($row_day, 0,1) == '0') {
41 $row_day = substr($row_day, 1, 1);
44 while ($today < $row_day-1) {
46 $days[$today] = array(0, 0);
47 $min_total_logins = 0;
50 $today = $row_day; /* skip this day in the fill-in-the-blanks-loop */
52 $days[$row_day] = array($row['guests'], $row['members']);
54 if ($max_total_logins < $row['guests']+$row['members']) {
55 $max_total_logins = $row['guests']+$row['members'];
58 if ($min_total_logins > $row['guests']+$row['members']) {
59 $min_total_logins = $row['guests']+$row['members'];
62 $total_logins += $row['guests']+$row['members'];
65 /* add zeros to the end of the month, only if it isn't the current month */
66 $now_month = date('m');
67 $now_year = date('Y');
68 if ( (($month < $now_month) && ($now_year == $year)) || ($now_year < $year) ) {
70 while (checkdate($month, $today,$year)) {
71 $days[$today] = array(0, 0);
75 $num_days = count($days);
77 if ($total_logins > 0) {
78 $avg_total_logins = $total_logins/$num_days;
80 $avg_total_logins = 0;
84 $multiplyer_height = 5; /* should be multiples of 5 */
88 $next_year = $year + 1;
90 $next_month = $month + 1;
96 $last_year = $year - 1;
98 $last_month = $month - 1;
102 require(AT_INCLUDE_PATH.'header.inc.php');
105 <table cellspacing="1" cellpadding="1" border="0" class="bodyline" summary="" align="center">
107 <th colspan="2" class="cyan"><small class="bigspacer"><?php
108 echo '<a href="'.$_SERVER['PHP_SELF'].'?month='.($last_month).SEP.'year='.$last_year.'">';
109 echo ' '.AT_date('%F', $last_month, AT_DATE_INDEX_VALUE ); ?></a> |</small>
110 <?php echo AT_date('%F', $month, AT_DATE_INDEX_VALUE ); ?> <small class="bigspacer">| <?php
111 echo '<a href="'.$_SERVER['PHP_SELF'].'?month='.$next_month.SEP.'year='.$next_year.'">';
112 echo AT_date('%F', $next_month, AT_DATE_INDEX_VALUE); ?> </a></small></th>
115 if (($num_days == 0) || ($empty)) {
117 echo '<td class="row1" colspan="2">'._AT('no_month_data').'</td>';
120 require(AT_INCLUDE_PATH.'footer.inc.php');
125 <td class="row1" valign="top" align="right"><strong><?php echo _AT('total'); ?>:</strong></td>
126 <td class="row1"><?php echo $total_logins; ?></td>
128 <tr><td height="1" class="row2" colspan="2"></td></tr>
130 <td class="row1" valign="top" align="right"><strong><?php echo _AT('maximum'); ?>:</strong></td>
131 <td class="row1"><?php echo $max_total_logins; ?></td>
133 <tr><td height="1" class="row2" colspan="2"></td></tr>
136 <td class="row1" valign="top" align="right"><strong><?php echo _AT('minimum'); ?>:</strong></td>
137 <td class="row1"><?php
138 if ($min_total_logins < 99999999) {
139 echo $min_total_logins;
144 <tr><td height="1" class="row2" colspan="2"></td></tr>
146 <td class="row1" valign="top" align="right"><strong><?php echo _AT('average'); ?>:</strong></td>
147 <td class="row1"><?php echo number_format($avg_total_logins, 1); ?> <?php echo _AT('per_day'); ?></td>
149 <tr><td height="1" class="row2" colspan="2"></td></tr>
152 <td class="row1" valign="top" align="right"><strong><?php echo _AT('graph'); ?>:</strong></td>
154 <table border="0" cellspacing="0" cellpadding="0">
156 <td valign="top" class="graph1"><small><?php echo $max_total_logins; ?></small></td>
159 foreach ($days as $day => $logins) {
161 echo '<td valign="bottom" class="graph"><img src="images/clr.gif" height="'.(($max_total_logins*$multiplyer_height) % $block_height + $block_height).'" width="10" alt="" /><br /><img src="images/blue.gif" height="'.($logins[0]*$multiplyer_height).'" width="9" alt="'.$logins[0].' '._AT('guests').' ('.($logins[0]+$logins[1]).' '._AT('total').')" /><br /><img src="images/red.gif" height="'.($logins[1]*$multiplyer_height).'" width="9" alt="'.$logins[1].' '._AT('members').' ('.($logins[1]+$logins[0]).' '._AT('total').')" /><br /><small>'.$dd.' </small></td>';
163 } while ($row = mysql_fetch_array($result));
168 <td valign="top"><small>0</small></td>
172 <small><?php echo _AT('legend'); ?>: <img src="images/red.gif" height="10" width="10" alt="<?php echo _AT('red_members'); ?>" /> <?php echo _AT('members'); ?>,
173 <img src="images/blue.gif" height="10" width="10" alt="<?php echo _AT('blue_guests'); ?>" /> <?php echo _AT('guests'); ?>.</small>
176 <tr><td height="1" class="row2" colspan="2"></td></tr>
178 <td class="row1" valign="top" align="right"><strong><?php echo _AT('raw_data'); ?>:</strong></td>
179 <td class="row1" align="center">
181 <table class="data static" summary="" rules="cols">
184 <th scope="col"><?php echo _AT('date'); ?></th>
185 <th scope="col"><?php echo _AT('guests'); ?></th>
186 <th scope="col"><?php echo _AT('members'); ?></th>
190 <?php $short_name = $month_name_con['en'][$month-1]; ?>
191 <?php foreach ($days as $day => $logins):?>
193 <td><?php echo $short_name.' '.$day; ?></td>
194 <td><?php echo $logins[0]; ?></td>
195 <td><?php echo $logins[1]; ?></td>
204 <?php require(AT_INCLUDE_PATH.'footer.inc.php'); ?>