forked from khoegenauer/tickets-cad
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcourse_report.php
99 lines (92 loc) · 4.55 KB
/
course_report.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<?php
/**
* @package course_report.php
* @author John Doe <[email protected]>
* @since 2011-12-15
* @version 2011-12-19
*/
/*
12/15/11 - initial release
12/19/11 'group' => 'group_name'
*/
error_reporting(E_ALL);
require_once './incs/functions.inc.php';
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<TITLE><?php print gettext('Classes Taken Report');?></TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
<META HTTP-EQUIV="Expires" CONTENT="0">
<META HTTP-EQUIV="Cache-Control" CONTENT="NO-CACHE">
<META HTTP-EQUIV="Pragma" CONTENT="NO-CACHE">
<META HTTP-EQUIV="Content-Script-Type" CONTENT="text/javascript">
<LINK REL=StyleSheet HREF="stylesheet.php?version=<?php print time();?>" TYPE="text/css"> <!-- 3/15/11 -->
</HEAD>
<BODY>
<?php
// dump($_POST);
$where = (intval($_POST['user_id']) > 0)? " WHERE `t`.`user_id` = {$_POST['user_id']}" : "";
$query = "SELECT * FROM `$GLOBALS[mysql_prefix]courses_taken` `t`
LEFT JOIN `$GLOBALS[mysql_prefix]user` `u` ON `u`.`id`=`t`.`user_id`
LEFT JOIN `$GLOBALS[mysql_prefix]courses` `c` ON `t`.`courses_id`=`c`.`id`
{$where}
ORDER BY `u`.`name_l` ASC, `u`.`name_f` ASC, `c`.`group_name` ASC, `c`.`course` ASC";
$result = mysql_query($query) or do_error($query, 'mysql query failed', mysql_error(), __FILE__, __LINE__);
if (mysql_num_rows($result)==0) { // no results - get selected userid
$query = "SELECT * FROM `$GLOBALS[mysql_prefix]user` WHERE `id` = {$_POST['user_id']} LIMIT 1";
$result = mysql_query($query) or do_error($query,'mysql_query() failed',mysql_error(), basename( __FILE__), __LINE__);
$the_user_str = "";
if (mysql_num_rows($result)>0) { // got a name?
$row = stripslashes_deep(mysql_fetch_assoc($result));
$the_user_str = " for {$row['user']}";
}
echo "<BR /><BR /><center><H2>" . gettext('No class data') . "{$the_user_str}</H2><BR /><BR /><BR />";
}
else {
$evenodd = array ("even", "odd"); // CLASS names for alternating table row colors
$i = 0;
$cum_credits = 0;
$this_user= 0;
echo "<BR /><BR /><TABLE BORDER = 1 ALIGN=CENTER CELLPADDING = 2>
<TR CLASS = 'even'><TH COLSPAN=99>" . gettext('Classes Taken - <i><small>as of') . " " . date('M j, y', time()) . "</small></i></TH></TR>";
while ($row = stripslashes_deep(mysql_fetch_assoc($result))) {
if ($row['user_id'] == $this_user) {$cum_credits += $row['credits'];}
else {$cum_credits = $row['credits']; $this_user = $row['user_id'];}
echo "<TR CLASS='{$evenodd[($i+1)%2]}' VALIGN='baseline'>\n\t\t
<TD>{$row['name_l']}, {$row['name_f']} {$row['name_mi']}</TD>
<TD>{$row['email']}</TD>
<TD>{$row['group_name']}</TD>
<TD>{$row['course']}</TD>
<TD>{$row['ident']}</TD>
<TD>{$row['credits']}</TD>
<TD>{$cum_credits}</TD>
<TD>{$row['date']}</TD>
";
$i++;
}
?>
</TABLE>
<?php
} // end if/else
?>
<FORM NAME = 'course_form' METHOD = 'post' ACTION = '<?php echo basename(__FILE__)?>'>
<INPUT TYPE = 'hidden' NAME = 'user_id' VALUE = ''>
</FORM>
<SPAN STYLE='text-align: center; display: block;'><BR />
<?php print gettext('Another');?> » <SELECT NAME='frm_user_id' onChange = "document.course_form.user_id.value=this.options[this.selectedIndex].value; document.course_form.submit();">
<OPTION VALUE='' selected><?php print gettext('Select');?></OPTION>
<OPTION VALUE='0' ><?php print gettext('All users');?></OPTION>
<?php
$query = "SELECT * FROM `$GLOBALS[mysql_prefix]user` WHERE ((`name_l` IS NOT NULL) AND (LENGTH(`name_l`) > 0)) ORDER BY `name_l` ASC, `name_f` ASC";
$result = mysql_query($query) or do_error($query,'mysql_query() failed',mysql_error(), basename( __FILE__), __LINE__);
while ($row = stripslashes_deep(mysql_fetch_assoc($result))) {
$the_opt = shorten("({$row['user']}) {$row['name_l']}, {$row['name_f']} {$row['name_mi']} ", 48);
echo "\t\t<OPTION VALUE='{$row['id']}'>{$the_opt}</OPTION>\n";
} // end while()
?>
</SELECT>
<INPUT TYPE = 'button' VALUE= "<?php print gettext('Finished');?>" onClick = "window.close();" STYLE = 'margin-left: 40px;' />
</span>
</BODY>
</HTML>