error message return if image processing fails
[sgn.git] / cgi-bin / solpeople / admin / stats.pl
blob96d2fcbcf4ca89b91adfb0048d923b2220866cbc
1 #!/usr/bin/perl -w
2 use strict;
3 use warnings;
5 use CXGN::DB::Connection;
6 use CXGN::Page;
7 use CXGN::Login;
8 use CXGN::Contact;
9 use CXGN::People;
11 my $page=CXGN::Page->new("SGN Stats","johnathon");
12 my $dbh = CXGN::DB::Connection->new("sgn_people");
14 my $logged_in_person_id=CXGN::Login->new($dbh)->verify_session();
15 my $logged_in_user=CXGN::People::Person->new($dbh, $logged_in_person_id);
16 my $logged_in_username=$logged_in_user->get_first_name()." ".$logged_in_user->get_last_name();
17 my $logged_in_user_type=$logged_in_user->get_user_type();
19 my $user_table;
20 my ($time_to_check) = $page->get_encoded_arguments("hours");
22 sub epoch_to_minutes{
23 my $people_logged_in = $_[0];
24 for my $person(@$people_logged_in){
25 $person->[2] = int($person->[2]/60);
27 return $people_logged_in;
30 $page->header("SGN Stats", "SGN Stats");
31 print <<html;
33 <script type='text/javascript' language='javascript'>
34 function lookup_person(id){
35 if(id > 0){
36 if(window.XMLHttpRequest){
37 http_request = new XMLHttpRequest();
39 else if(window.ActiveXObject){
40 http_request = new ActiveXObject("Microsoft.XMLHTTP");
42 if (!http_request) {
43 alert('Giving up :( Cannot create an XMLHTTP instance');
44 return false;
46 http_request.onreadystatechange = function() { writeData(http_request); };
47 http_request.open('GET', 'get_person.pl?id='+id, true);
48 http_request.send("id="+id);
50 function writeData(http_request){
51 if(http_request.readyState == 4){
52 if(http_request.status == 200){
53 var table = document.getElementById("idnumbers");
54 table.innerHTML += http_request.responseText;
56 else{
57 alert("Error " + http_request.status);
62 </script>
63 <br />
64 <form method="get" action="stats.pl" name="time" id="time"><label for="minutes">Time restraint (in hours): &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</label>
65 <input type="text" size="5" name="hours" id="hours" value="$time_to_check" />
66 <input type="submit" id="submit" value="Submit" /></form>
67 <form id="lookup" name="lookup" action="javascript:lookup_person(document.lookup.number.value)">
68 <span id="request" name="request"
69 style="cursor: pointer; text-decoration: underline"
70 onclick="javascript:lookup_person(document.lookup.number.value)">
71 Obtain user info on id number:
72 </span>
73 <input type="text" size="5" name="number" />
74 <input type="submit" id="sumbitnum" value="Submit" />
75 </form>
77 <script type="text/javascript" language="javascript">document.time.hours.focus();</script>
78 $user_table
80 <table style="width: 45%" name="idnumbers" id="idnumbers"><tr><th>Username:</th><th>Timestamp:</th></tr></table>
81 html
83 $page->footer();