Subversion Repositories ORC

Rev

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