| 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¬e=true&derby_name=true&filter-dept=$_&sortby=dayofweek&limit=All&page=1" }, "$DEPTS->{$_} Staff Schedule"));
|
|
|
82 |
}
|
|
|
83 |
|
| 7 |
- |
84 |
# 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
|
|
|
85 |
}
|
|
|
86 |
|
| 16 |
- |
87 |
my @sysadmins;
|
|
|
88 |
if ($LVL >= 5) {
|
|
|
89 |
push @sysadmins, $h->li ($h->a ({ href=>"/schedule/bulk_upload.pl" }, "Upload a CSV of Department Shifts"));
|
| 34 |
- |
90 |
push @sysadmins, $h->li ($h->a ({ href=>"/schedule/manage_shifts.pl" }, "Update department shift schedule"));
|
| 35 |
- |
91 |
|
|
|
92 |
my ($signupcount) = $dbh->selectrow_array ("select count(*) from v_shift where dept = ? and RCid <> ''", undef, "CLA");
|
|
|
93 |
my ($mvpcount) = $dbh->selectrow_array ("select count(*) from official where department REGEXP ?", undef, "CLA-1");
|
|
|
94 |
|
|
|
95 |
$mvpcount = 265 unless $mvpcount;
|
|
|
96 |
|
| 37 |
- |
97 |
push @sysadmins, $h->li ($mvpcount." MVP Passholders have signed up for ".$signupcount." spots (".sprintf("%.2f", ($signupcount / ($mvpcount*6)) * 100)."\%).");
|
| 35 |
- |
98 |
|
|
|
99 |
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%'");
|
|
|
100 |
#my ($active) = $dbh->selectrow_array ("select * from official where last_login > (now() - interval 150 minute) order by last_login desc");
|
|
|
101 |
push @sysadmins, $h->li ("There seem to be about $active user session(s) right now.");
|
| 29 |
- |
102 |
# push @sysadmins, $h->li ($h->a ({ href=>"/schedule/volhours.pl" }, "View Volunteer Hours by Department"));
|
| 16 |
- |
103 |
}
|
|
|
104 |
|
| 7 |
- |
105 |
my @activity_log;
|
|
|
106 |
my $alog = $dbh->prepare("select timestamp, event from v_log where RCid = ? limit 10");
|
|
|
107 |
$alog->execute($user->{RCid});
|
|
|
108 |
while (my @logs = $alog->fetchrow_array) {
|
|
|
109 |
my ($d, $t) = split /\s+/, $logs[0];
|
|
|
110 |
push @activity_log, $h->li ({ class=>"shaded" }, join " ", @logs);
|
|
|
111 |
}
|
|
|
112 |
|
|
|
113 |
my @reference;
|
| 8 |
- |
114 |
push @reference, $h->li ($h->a ({ href=>"/info.html" }, "Information about using this tool"));
|
| 7 |
- |
115 |
push @reference, $h->li ($h->a ({ href=>"http://rollercon.com/help-wanted/officiating/" }, "RollerCon Officiating Details"));
|
|
|
116 |
|
|
|
117 |
printRCHeader("Home");
|
|
|
118 |
print $h->close ("table");
|
|
|
119 |
|
|
|
120 |
print $h->form ({ name=>"Req", action=>url });
|
|
|
121 |
|
| 35 |
- |
122 |
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;
|
|
|
123 |
|
| 7 |
- |
124 |
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;
|
|
|
125 |
|
| 35 |
- |
126 |
print $h->div ({ class=>"index" }, [$h->p ({ class=>"heading" }, "MVP Pass Holders:"), $h->ul ([ @mvppass ]) ]) if (scalar @mvppass);
|
|
|
127 |
|
| 7 |
- |
128 |
print $h->div ({ class=>"index" }, [$h->p ({ class=>"heading" }, "Things you can do:"), $h->ul ([ @everyone ]) ]);
|
|
|
129 |
|
|
|
130 |
print $h->div ({ class=>"index" }, [$h->p ({ class=>"heading" }, "Things you can do as a Lead:"), $h->ul ([ @leads ]) ]) if ($LVL > 1);
|
|
|
131 |
|
| 16 |
- |
132 |
print $h->div ({ class=>"index" }, [$h->p ({ class=>"heading" }, "Things you can do as a Manager:"), $h->ul ([ @managers ]) ]) if ($LVL > 2);
|
| 7 |
- |
133 |
|
| 16 |
- |
134 |
print $h->div ({ class=>"index" }, [$h->p ({ class=>"heading" }, "Things you can do as a SysAdmin:"), $h->ul ([ @sysadmins ]) ]) if ($LVL >= 5);
|
|
|
135 |
|
| 8 |
- |
136 |
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×tamp=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 |
- |
137 |
|
|
|
138 |
print $h->div ({ class=>"index" }, [$h->p ({ class=>"heading" }, "Reference:"), $h->ul ([ @reference ]) ]);
|
|
|
139 |
|
|
|
140 |
print $h->close ("body"), $h->close ("html");
|
|
|
141 |
;
|
|
|
142 |
|