Subversion Repositories ORC

Rev

Rev 2 | Rev 8 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
7 - 1
#!/usr/bin/perl
2
 
3
use strict;
4
use RollerCon;
5
use CGI;
6
use CGI::Cookie;
7
use WebDB;
8
our $h = HTML::Tiny->new( mode => 'html' );
9
 
10
my $cookie_string = authenticate(1) || die;
11
my ($EML, $PWD, $LVL) = split /&/, $cookie_string;
12
my $user = getUser($EML);
13
$user->{department} = convertDepartments $user->{department};
14
my $RCAUTH_cookie = CGI::Cookie->new(-name=>'RCAUTH',-value=>"$cookie_string",-expires=>"+30m");
15
my $DEPTS = getDepartments;
16
 
17
print CGI::header(-cookie=>$RCAUTH_cookie);
18
 
19
#foreach (sort keys %ENV) {
20
#	print "$_: $ENV{$_}\n<br>";
21
#}
22
 
23
#use DBI;
24
my $dbh = WebDB->connect ();
25
 
26
use DateTime;
27
my $dt = DateTime->today;
28
$dt =~ s/T00\:00\:00$//;
29
 
30
my $schedule = getSchedule ($user->{RCid});
31
 
32
my @everyone;
33
my @printDEPTS = map { $DEPTS->{$_} } grep { $user->{department}->{$_} > 0 } grep { !/(ANN)|(OFF)/ } sort keys %{$user->{department}};
34
push @printDEPTS, "Officiating Lead" if $user->{department}->{"OFF"} > 1;
35
my $printDEPTS = join ", ", @printDEPTS;
36
push @everyone, $h->li ($h->a ({ href=>"/schedule/shifts.pl" }, "View and Sign Up for $printDEPTS Shifts")) if $printDEPTS;
37
push @everyone, $h->li ($h->a ({ href=>"/schedule/officiating_shifts.pl" }, "View and Sign Up for Officiating Shifts")) if $user->{department}->{OFF} > 0;
38
push @everyone, $h->li ($h->a ({ href=>"/schedule/announcer_shifts.pl" }, "View and Sign Up for Announcer Shifts")) if $user->{department}->{ANN} > 0;
39
push @everyone, $h->li ($h->a ({ href=>"/schedule/manage_personal_time.pl" }, "Block Personal Time"));
40
push @everyone, $h->li ($h->a ({ href=>"/schedule/manage_user.pl?submit=Edit&RCid=$user->{RCid}" }, "Edit your profile"));
41
 
42
 
43
my @leads = ();
44
if ($LVL > 1) {
45
	push @leads, $h->li ($h->a ({ href=>"/schedule/user_report.pl" }, "View Users in your Department(s)."));
46
	push @leads, $h->li ($h->a ({ href=>"/schedule/password_reset.pl" }, "Reset a Password."));
47
 
48
	# Officiating Leads:
49
	if ($user->{department}->{OFF} > 1) {
50
		unshift @leads, $h->li ($h->a ({ href=>"/schedule/scores.pl" }, "View / Update Game Scores"));
51
#		 push @leads, $h->li ($h->a ({ href=>"daily_print.pl" }, "Daily Print Report"));
52
		push @leads, $h->li (["What's happening right now on...", $h->ul ([
53
			$h->li ($h->a ({ href=>"right_now.pl?t=C1" }, "Track C1")),
54
			$h->li ($h->a ({ href=>"right_now.pl?t=C2" }, "Track C2")),
55
			$h->li ($h->a ({ href=>"right_now.pl?t=C3" }, "Track C3")),
56
			$h->li ($h->a ({ href=>"right_now.pl?t=C4" }, "Track C4")),
57
			$h->li ($h->a ({ href=>"right_now.pl?t=B"  }, "Track B")),
58
		])]);
59
	}
60
}
61
 
62
my @managers;
63
if ($LVL >= 3) {
64
	my $manager_departments = join " or ", map { "department like '%$_-0%'" } grep { $user->{department}->{$_} > 2 } keys %{$user->{department}};
65
	my ($count) = $dbh->selectrow_array ("select count(*) from official where $manager_departments");
66
	my $counttxt = $count == 1 ? "is 1 user" : "are $count users";
67
	push @managers, $h->li ($h->a ({ href=>"user_report.pl?filter-access=0" }, "There $counttxt waiting to be activated")) if $count;
68
	push @managers, $h->li ($h->a ({ href=>"/schedule/manage_shifts.pl" }, "Update your department shift schedule"));
69
	push @managers, $h->li ($h->a ({ href=>"/schedule/log.pl" }, "Activity Log"));
70
 
71
	# Shift Report: select dayofweek, count(RCid) as filled_shifts, count(*) - count(RCid) as open_shifts, count(*) as total_shifts from v_shift group by date order by date
72
}
73
 
74
my @activity_log;
75
my $alog = $dbh->prepare("select timestamp, event from v_log where RCid = ? limit 10");
76
$alog->execute($user->{RCid});
77
while (my @logs = $alog->fetchrow_array) {
78
	my ($d, $t) = split /\s+/, $logs[0];
79
	push @activity_log, $h->li ({ class=>"shaded" }, join " ", @logs);
80
}
81
 
82
my @reference;
83
push @reference, $h->li ($h->a ({ href=>"http://rollercon.com/help-wanted/officiating/" }, "RollerCon Officiating Details"));
84
 
85
printRCHeader("Home");
86
print $h->close ("table");
87
 
88
print $h->form ({ name=>"Req", action=>url });
89
 
90
print $h->div ({ class=>"index" }, [$h->p ({ class=>"heading" }, "Your up-coming schedule (as of $dt):"), $schedule, $h->h5 ("[".$h->a ({ href=>"export_ics.pl?RCid=$user->{RCid}" }, "use this link for iCal")."]") ]) if $schedule;
91
 
92
print $h->div ({ class=>"index" }, [$h->p ({ class=>"heading" }, "Things you can do:"), $h->ul ([ @everyone ]) ]);
93
 
94
print $h->div ({ class=>"index" }, [$h->p ({ class=>"heading" }, "Things you can do as a Lead:"), $h->ul ([ @leads ]) ]) if ($LVL > 1);
95
 
96
print $h->div ({ class=>"index" }, [$h->p ({ class=>"heading" }, "Things you can do as a Manager:"), $h->ul ([ @managers ]) ]) if ($LVL > 1);
97
 
98
print $h->div ({ class=>"index" }, [$h->p ({ class=>"heading" }, "Your Latest Activity:"), $h->ul ([ @activity_log ]), $h->h5 ($h->a ({ href=>"log.pl?filter-RCid=".$user->{RCid} }, "[Your entire log history]")) ]);
99
 
100
print $h->div ({ class=>"index" }, [$h->p ({ class=>"heading" }, "Reference:"), $h->ul ([ @reference ]) ]);
101
 
102
print $h->close ("body"), $h->close ("html");
103
;
104