Subversion Repositories ORC

Rev

Rev 39 | 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};
35 - 15
my $activated = max (values %{ $user->{department} });
7 - 16
my $RCAUTH_cookie = CGI::Cookie->new(-name=>'RCAUTH',-value=>"$cookie_string",-expires=>"+30m");
17
my $DEPTS = getDepartments;
18
 
19
print CGI::header(-cookie=>$RCAUTH_cookie);
20
 
21
#foreach (sort keys %ENV) {
22
#	print "$_: $ENV{$_}\n<br>";
23
#}
24
 
25
#use DBI;
35 - 26
#my $dbh = WebDB->connect ();
27
my $dbh = getRCDBH;
7 - 28
 
29
use DateTime;
30
my $dt = DateTime->today;
31
$dt =~ s/T00\:00\:00$//;
32
 
33
my $schedule = getSchedule ($user->{RCid});
34
 
35
my @everyone;
36
my @printDEPTS = map { $DEPTS->{$_} } grep { $user->{department}->{$_} > 0 } grep { !/(ANN)|(OFF)/ } sort keys %{$user->{department}};
37
push @printDEPTS, "Officiating Lead" if $user->{department}->{"OFF"} > 1;
38
my $printDEPTS = join ", ", @printDEPTS;
39
push @everyone, $h->li ($h->a ({ href=>"/schedule/shifts.pl" }, "View and Sign Up for $printDEPTS Shifts")) if $printDEPTS;
40
push @everyone, $h->li ($h->a ({ href=>"/schedule/officiating_shifts.pl" }, "View and Sign Up for Officiating Shifts")) if $user->{department}->{OFF} > 0;
29 - 41
push @everyone, $h->li ($h->a ({ href=>"/schedule/announcer_shifts.pl" }, "View and Sign Up to Announce Games")) if $user->{department}->{ANN} > 0;
7 - 42
push @everyone, $h->li ($h->a ({ href=>"/schedule/manage_personal_time.pl" }, "Block Personal Time"));
43
push @everyone, $h->li ($h->a ({ href=>"/schedule/manage_user.pl?submit=Edit&RCid=$user->{RCid}" }, "Edit your profile"));
44
 
35 - 45
my @mvppass;
46
if ($user->{department}->{CLA} > 0) {
47
	push @mvppass, $h->li ($h->a ({ href=>"/schedule/mvpclasses.pl" }, "View and Sign Up for MVP Classes"))
48
}
7 - 49
 
50
my @leads = ();
51
if ($LVL > 1) {
52
	push @leads, $h->li ($h->a ({ href=>"/schedule/user_report.pl" }, "View Users in your Department(s)."));
53
	push @leads, $h->li ($h->a ({ href=>"/schedule/password_reset.pl" }, "Reset a Password."));
54
 
55
	# Officiating Leads:
56
	if ($user->{department}->{OFF} > 1) {
57
		unshift @leads, $h->li ($h->a ({ href=>"/schedule/scores.pl" }, "View / Update Game Scores"));
58
#		 push @leads, $h->li ($h->a ({ href=>"daily_print.pl" }, "Daily Print Report"));
59
		push @leads, $h->li (["What's happening right now on...", $h->ul ([
60
			$h->li ($h->a ({ href=>"right_now.pl?t=C1" }, "Track C1")),
61
			$h->li ($h->a ({ href=>"right_now.pl?t=C2" }, "Track C2")),
62
			$h->li ($h->a ({ href=>"right_now.pl?t=C3" }, "Track C3")),
63
			$h->li ($h->a ({ href=>"right_now.pl?t=C4" }, "Track C4")),
39 - 64
#			$h->li ($h->a ({ href=>"right_now.pl?t=B"  }, "Track B")),
7 - 65
		])]);
66
	}
67
}
68
 
69
my @managers;
70
if ($LVL >= 3) {
71
	my $manager_departments = join " or ", map { "department like '%$_-0%'" } grep { $user->{department}->{$_} > 2 } keys %{$user->{department}};
8 - 72
	if ($manager_departments) {
73
  	my ($count) = $dbh->selectrow_array ("select count(*) from official where $manager_departments");
74
  	my $counttxt = $count == 1 ? "is 1 user" : "are $count users";
75
  	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;
76
	}
77
 	push @managers, $h->li ($h->a ({ href=>"/schedule/log.pl" }, "Activity Log"));
29 - 78
  push @managers, $h->li ($h->a ({ href=>"/schedule/volhours.pl" }, "View Volunteer Hours by Department"));
39 - 79
 
80
  foreach (grep { $user->{department}->{$_} > 2 } keys %{$user->{department}}) {
81
    push @managers, $h->li ($h->a ({ href=>"/schedule/shifts.pl?autoload=1&dept=true&role=true&dayofweek=true&location=true&time=true&note=true&derby_name=true&filter-dept=$_&sortby=dayofweek&limit=All&page=1" }, "$DEPTS->{$_} Staff Schedule"));
82
  }
83
 
46 - 84
  if ($user->{department}->{VCI} > 2 or $user->{department}->{MVP} > 2 or $LVL > 4) {
85
    push @managers, $h->li ($h->a ({ href=>"/schedule/mvp_class_report.pl", target=>"_new" }, "Daily MVP Class Report (for print)"));
86
    push @managers, $h->li ($h->a ({ href=>"/schedule/daily_print.pl", target=>"_new" }, "Daily Officiating Report (for print)"));
87
    push @managers, $h->li ($h->a ({ href=>"/schedule/daily_print_announcers.pl", target=>"_new" }, "Daily Announcers Report (for print)"));
88
    push @managers, $h->li ($h->a ({ href=>"/schedule/print_dept_by_day.pl", target=>"_new" }, "BETA: Daily Shift Report (for print)"));
89
  }
90
 
7 - 91
	# 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
92
}
93
 
16 - 94
my @sysadmins;
95
if ($LVL >= 5) {
96
  push @sysadmins, $h->li ($h->a ({ href=>"/schedule/bulk_upload.pl" }, "Upload a CSV of Department Shifts"));
34 - 97
 	push @sysadmins, $h->li ($h->a ({ href=>"/schedule/manage_shifts.pl" }, "Update department shift schedule"));
35 - 98
 
99
 	my ($signupcount) = $dbh->selectrow_array ("select count(*) from v_shift where dept = ? and RCid <> ''", undef, "CLA");
100
 	my ($mvpcount)    = $dbh->selectrow_array ("select count(*) from official where department REGEXP ?", undef, "CLA-1");
101
 
102
 	$mvpcount = 265 unless $mvpcount;
103
 
37 - 104
 	push @sysadmins, $h->li ($mvpcount." MVP Passholders have signed up for ".$signupcount." spots (".sprintf("%.2f", ($signupcount / ($mvpcount*6)) * 100)."\%).");
35 - 105
 
106
 	my ($active) = $dbh->selectrow_array ("select count(distinct RCid) as users from log where timestamp > (now() - interval 30 minute) and event not like 'Updated User Details%' and event not like 'Activated to work%'");
107
 	#my ($active) = $dbh->selectrow_array ("select * from official where last_login > (now() - interval 150 minute) order by last_login desc");
108
 	push @sysadmins, $h->li ("There seem to be about $active user session(s) right now.");
29 - 109
#  push @sysadmins, $h->li ($h->a ({ href=>"/schedule/volhours.pl" }, "View Volunteer Hours by Department"));
16 - 110
}
111
 
7 - 112
my @activity_log;
113
my $alog = $dbh->prepare("select timestamp, event from v_log where RCid = ? limit 10");
114
$alog->execute($user->{RCid});
115
while (my @logs = $alog->fetchrow_array) {
116
	my ($d, $t) = split /\s+/, $logs[0];
117
	push @activity_log, $h->li ({ class=>"shaded" }, join " ", @logs);
118
}
119
 
120
my @reference;
8 - 121
push @reference, $h->li ($h->a ({ href=>"/info.html" }, "Information about using this tool"));
7 - 122
push @reference, $h->li ($h->a ({ href=>"http://rollercon.com/help-wanted/officiating/" }, "RollerCon Officiating Details"));
123
 
124
printRCHeader("Home");
125
print $h->close ("table");
126
 
127
print $h->form ({ name=>"Req", action=>url });
128
 
35 - 129
print $h->div ({ class=>"index" }, [$h->p ({ class=>"heading" }, "Note:"), "<b>Your account is being reviewed.</b>", $h->br, "You won't have access to view or sign-up for things until you've been approved / added to a department.", $h->br, "Please watch your email for notifications." ]) unless $activated;
130
 
7 - 131
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;
132
 
35 - 133
print $h->div ({ class=>"index" }, [$h->p ({ class=>"heading" }, "MVP Pass Holders:"), $h->ul ([ @mvppass ]) ]) if (scalar @mvppass);
134
 
7 - 135
print $h->div ({ class=>"index" }, [$h->p ({ class=>"heading" }, "Things you can do:"), $h->ul ([ @everyone ]) ]);
136
 
137
print $h->div ({ class=>"index" }, [$h->p ({ class=>"heading" }, "Things you can do as a Lead:"), $h->ul ([ @leads ]) ]) if ($LVL > 1);
138
 
16 - 139
print $h->div ({ class=>"index" }, [$h->p ({ class=>"heading" }, "Things you can do as a Manager:"), $h->ul ([ @managers ]) ]) if ($LVL > 2);
7 - 140
 
16 - 141
print $h->div ({ class=>"index" }, [$h->p ({ class=>"heading" }, "Things you can do as a SysAdmin:"), $h->ul ([ @sysadmins ]) ]) if ($LVL >= 5);
142
 
8 - 143
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 - 144
 
145
print $h->div ({ class=>"index" }, [$h->p ({ class=>"heading" }, "Reference:"), $h->ul ([ @reference ]) ]);
146
 
147
print $h->close ("body"), $h->close ("html");
148
;
149