| 7 |
- |
1 |
#!/usr/bin/perl
|
|
|
2 |
|
| 56 |
bgadell |
3 |
# Redirect error messages to a log of my choosing. (it's annoying to filter for errors in the shared env)
|
|
|
4 |
my $error_log_path = $ENV{SERVER_NAME} eq "volunteers.rollercon.com" ? "/home3/rollerco/logs/" : "/tmp/";
|
|
|
5 |
close STDERR;
|
|
|
6 |
open STDERR, '>>', $error_log_path.'vorc_error.log' or warn "Failed to open redirected logfile ($0): $!";
|
|
|
7 |
#warn "Redirecting errors to ${error_log_path}vorc_error.log";
|
|
|
8 |
|
| 7 |
- |
9 |
use strict;
|
| 8 |
- |
10 |
use cPanelUserConfig;
|
| 7 |
- |
11 |
use RollerCon;
|
| 50 |
bgadell |
12 |
use CGI qw/param header start_html url/;
|
| 7 |
- |
13 |
use CGI::Cookie;
|
| 50 |
bgadell |
14 |
#use WebDB;
|
| 7 |
- |
15 |
our $h = HTML::Tiny->new( mode => 'html' );
|
|
|
16 |
|
| 50 |
bgadell |
17 |
my $cookie_string = authenticate (1) || die;
|
| 7 |
- |
18 |
my ($EML, $PWD, $LVL) = split /&/, $cookie_string;
|
| 50 |
bgadell |
19 |
#my $user = getUser($EML);
|
|
|
20 |
my $user = $ORCUSER;
|
|
|
21 |
#$user->{department} = convertDepartments $user->{department};
|
| 65 |
bgadell |
22 |
#my $activated = max (values %{ $user->{department} });
|
|
|
23 |
my $activated = $ORCUSER->{access};
|
| 7 |
- |
24 |
my $RCAUTH_cookie = CGI::Cookie->new(-name=>'RCAUTH',-value=>"$cookie_string",-expires=>"+30m");
|
| 50 |
bgadell |
25 |
my $DEPTS = getDepartments ();
|
| 7 |
- |
26 |
|
| 50 |
bgadell |
27 |
print header (-cookie=>$RCAUTH_cookie);
|
| 7 |
- |
28 |
|
|
|
29 |
#foreach (sort keys %ENV) {
|
|
|
30 |
# print "$_: $ENV{$_}\n<br>";
|
|
|
31 |
#}
|
|
|
32 |
|
|
|
33 |
#use DBI;
|
| 35 |
- |
34 |
#my $dbh = WebDB->connect ();
|
| 50 |
bgadell |
35 |
my $dbh = getRCDBH ();
|
| 7 |
- |
36 |
|
|
|
37 |
use DateTime;
|
|
|
38 |
my $dt = DateTime->today;
|
|
|
39 |
$dt =~ s/T00\:00\:00$//;
|
|
|
40 |
|
| 50 |
bgadell |
41 |
my @announcements;
|
|
|
42 |
push @announcements, $h->li ($h->a ({ href=>'__LINK__?'.$user->{discount_code} }, "THANK YOU! You've earned a discounted pass for next year. Click here to redeem.")) if $user->{discount_code};
|
| 56 |
bgadell |
43 |
my ($announcement) = $dbh->selectrow_array ("select value from setting where setting.key = ?", undef, "ANNOUNCEMENT");
|
|
|
44 |
push @announcements, $h->li ($announcement) if $announcement;
|
| 50 |
bgadell |
45 |
|
| 56 |
bgadell |
46 |
|
| 7 |
- |
47 |
my $schedule = getSchedule ($user->{RCid});
|
|
|
48 |
|
|
|
49 |
my @everyone;
|
|
|
50 |
my @printDEPTS = map { $DEPTS->{$_} } grep { $user->{department}->{$_} > 0 } grep { !/(ANN)|(OFF)/ } sort keys %{$user->{department}};
|
|
|
51 |
push @printDEPTS, "Officiating Lead" if $user->{department}->{"OFF"} > 1;
|
|
|
52 |
my $printDEPTS = join ", ", @printDEPTS;
|
|
|
53 |
push @everyone, $h->li ($h->a ({ href=>"/schedule/shifts.pl" }, "View and Sign Up for $printDEPTS Shifts")) if $printDEPTS;
|
|
|
54 |
push @everyone, $h->li ($h->a ({ href=>"/schedule/officiating_shifts.pl" }, "View and Sign Up for Officiating Shifts")) if $user->{department}->{OFF} > 0;
|
| 29 |
- |
55 |
push @everyone, $h->li ($h->a ({ href=>"/schedule/announcer_shifts.pl" }, "View and Sign Up to Announce Games")) if $user->{department}->{ANN} > 0;
|
| 56 |
bgadell |
56 |
push @everyone, $h->li ($h->a ({ href=>"/schedule/games.pl" }, "View Games"));
|
|
|
57 |
push @everyone, $h->li ($h->a ({ href=>"/schedule/personal_time.pl" }, "Block Personal Time"));
|
|
|
58 |
push @everyone, $h->li ($h->a ({ href=>"/schedule/view_user.pl?submit=Edit&RCid=$user->{RCid}" }, "Edit your profile"));
|
| 7 |
- |
59 |
|
| 35 |
- |
60 |
my @mvppass;
|
| 70 |
bgadell |
61 |
if ($user->{MVPid} or $LVL >= 5) {
|
| 56 |
bgadell |
62 |
push @mvppass, $h->li ($h->a ({ href=>"/schedule/classes.pl" }, "View and Sign Up for MVP Classes"))
|
| 35 |
- |
63 |
}
|
| 7 |
- |
64 |
|
|
|
65 |
my @leads = ();
|
|
|
66 |
if ($LVL > 1) {
|
| 56 |
bgadell |
67 |
push @leads, $h->li ($h->a ({ href=>"/schedule/users.pl" }, "View Users in your Department(s)."));
|
| 7 |
- |
68 |
push @leads, $h->li ($h->a ({ href=>"/schedule/password_reset.pl" }, "Reset a Password."));
|
|
|
69 |
|
|
|
70 |
# Officiating Leads:
|
|
|
71 |
if ($user->{department}->{OFF} > 1) {
|
|
|
72 |
unshift @leads, $h->li ($h->a ({ href=>"/schedule/scores.pl" }, "View / Update Game Scores"));
|
|
|
73 |
# push @leads, $h->li ($h->a ({ href=>"daily_print.pl" }, "Daily Print Report"));
|
|
|
74 |
push @leads, $h->li (["What's happening right now on...", $h->ul ([
|
|
|
75 |
$h->li ($h->a ({ href=>"right_now.pl?t=C1" }, "Track C1")),
|
|
|
76 |
$h->li ($h->a ({ href=>"right_now.pl?t=C2" }, "Track C2")),
|
|
|
77 |
$h->li ($h->a ({ href=>"right_now.pl?t=C3" }, "Track C3")),
|
|
|
78 |
$h->li ($h->a ({ href=>"right_now.pl?t=C4" }, "Track C4")),
|
| 39 |
- |
79 |
# $h->li ($h->a ({ href=>"right_now.pl?t=B" }, "Track B")),
|
| 7 |
- |
80 |
])]);
|
|
|
81 |
}
|
|
|
82 |
}
|
|
|
83 |
|
|
|
84 |
my @managers;
|
|
|
85 |
if ($LVL >= 3) {
|
|
|
86 |
my $manager_departments = join " or ", map { "department like '%$_-0%'" } grep { $user->{department}->{$_} > 2 } keys %{$user->{department}};
|
| 8 |
- |
87 |
if ($manager_departments) {
|
|
|
88 |
my ($count) = $dbh->selectrow_array ("select count(*) from official where $manager_departments");
|
|
|
89 |
my $counttxt = $count == 1 ? "is 1 user" : "are $count users";
|
| 56 |
bgadell |
90 |
push @managers, $h->li ($h->a ({ href=>"users.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;
|
| 8 |
- |
91 |
}
|
|
|
92 |
push @managers, $h->li ($h->a ({ href=>"/schedule/log.pl" }, "Activity Log"));
|
| 29 |
- |
93 |
push @managers, $h->li ($h->a ({ href=>"/schedule/volhours.pl" }, "View Volunteer Hours by Department"));
|
| 39 |
- |
94 |
|
|
|
95 |
foreach (grep { $user->{department}->{$_} > 2 } keys %{$user->{department}}) {
|
|
|
96 |
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"));
|
|
|
97 |
}
|
|
|
98 |
|
| 46 |
- |
99 |
if ($user->{department}->{VCI} > 2 or $user->{department}->{MVP} > 2 or $LVL > 4) {
|
| 56 |
bgadell |
100 |
push @managers, $h->li ($h->a ({ href=>"/schedule/classes.pl" }, "View MVP Classes"));
|
| 46 |
- |
101 |
push @managers, $h->li ($h->a ({ href=>"/schedule/mvp_class_report.pl", target=>"_new" }, "Daily MVP Class Report (for print)"));
|
|
|
102 |
push @managers, $h->li ($h->a ({ href=>"/schedule/daily_print.pl", target=>"_new" }, "Daily Officiating Report (for print)"));
|
|
|
103 |
push @managers, $h->li ($h->a ({ href=>"/schedule/daily_print_announcers.pl", target=>"_new" }, "Daily Announcers Report (for print)"));
|
|
|
104 |
push @managers, $h->li ($h->a ({ href=>"/schedule/print_dept_by_day.pl", target=>"_new" }, "BETA: Daily Shift Report (for print)"));
|
|
|
105 |
}
|
|
|
106 |
|
| 7 |
- |
107 |
# 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
|
|
|
108 |
}
|
|
|
109 |
|
| 16 |
- |
110 |
my @sysadmins;
|
|
|
111 |
if ($LVL >= 5) {
|
|
|
112 |
push @sysadmins, $h->li ($h->a ({ href=>"/schedule/bulk_upload.pl" }, "Upload a CSV of Department Shifts"));
|
| 60 |
bgadell |
113 |
push @sysadmins, $h->li ($h->a ({ href=>"/schedule/shifts.pl" }, "Update department shift schedule"));
|
| 58 |
bgadell |
114 |
push @sysadmins, $h->li ($h->a ({ href=>"/schedule/tickets.pl" }, "Manage MVP Ticket Matches"));
|
| 56 |
bgadell |
115 |
push @sysadmins, $h->li ($h->a ({ href=>"/schedule/classes.pl" }, "Manage MVP Classes"));
|
|
|
116 |
push @sysadmins, $h->li ($h->a ({ href=>"/schedule/games.pl" }, "Manage Games"));
|
|
|
117 |
push @sysadmins, $h->li ($h->a ({ href=>"/schedule/departments.pl" }, "Manage Department Settings"));
|
|
|
118 |
push @sysadmins, $h->li ($h->a ({ href=>"/schedule/settings.pl" }, "System Settings"));
|
| 50 |
bgadell |
119 |
push @sysadmins, $h->li ($h->a ({ href=>"/schedule/volhours_report.pl?limit=All" }, "YEAR END VOLUNTEER HOURS REPORT"));
|
| 35 |
- |
120 |
|
| 80 |
bgadell |
121 |
my ($signupcount) = $dbh->selectrow_array ("select sum(count) from v_class where year(date) = year(now())");
|
| 58 |
bgadell |
122 |
my ($mvpcount) = $dbh->selectrow_array ("select count(*) from v_official where isnull(MVPid) = false");
|
| 35 |
- |
123 |
|
| 62 |
bgadell |
124 |
$mvpcount = 1 unless $mvpcount;
|
| 35 |
- |
125 |
|
| 37 |
- |
126 |
push @sysadmins, $h->li ($mvpcount." MVP Passholders have signed up for ".$signupcount." spots (".sprintf("%.2f", ($signupcount / ($mvpcount*6)) * 100)."\%).");
|
| 35 |
- |
127 |
|
| 84 |
bgadell |
128 |
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%' and event not like 'New User Registration' and event not like 'Login attempted without activation code.'");
|
| 35 |
- |
129 |
#my ($active) = $dbh->selectrow_array ("select * from official where last_login > (now() - interval 150 minute) order by last_login desc");
|
|
|
130 |
push @sysadmins, $h->li ("There seem to be about $active user session(s) right now.");
|
| 29 |
- |
131 |
# push @sysadmins, $h->li ($h->a ({ href=>"/schedule/volhours.pl" }, "View Volunteer Hours by Department"));
|
| 16 |
- |
132 |
}
|
|
|
133 |
|
| 7 |
- |
134 |
my @activity_log;
|
|
|
135 |
my $alog = $dbh->prepare("select timestamp, event from v_log where RCid = ? limit 10");
|
|
|
136 |
$alog->execute($user->{RCid});
|
|
|
137 |
while (my @logs = $alog->fetchrow_array) {
|
|
|
138 |
my ($d, $t) = split /\s+/, $logs[0];
|
|
|
139 |
push @activity_log, $h->li ({ class=>"shaded" }, join " ", @logs);
|
|
|
140 |
}
|
|
|
141 |
|
|
|
142 |
my @reference;
|
| 8 |
- |
143 |
push @reference, $h->li ($h->a ({ href=>"/info.html" }, "Information about using this tool"));
|
| 7 |
- |
144 |
push @reference, $h->li ($h->a ({ href=>"http://rollercon.com/help-wanted/officiating/" }, "RollerCon Officiating Details"));
|
|
|
145 |
|
|
|
146 |
printRCHeader("Home");
|
|
|
147 |
print $h->close ("table");
|
|
|
148 |
|
| 50 |
bgadell |
149 |
print $h->form ({ name => "Req", action => url });
|
| 7 |
- |
150 |
|
| 50 |
bgadell |
151 |
print $h->div ({ class=>"index" }, [$h->p ({ class=>"heading" }, "Announcement:"), $h->ul ([ @announcements ]) ]) if (scalar @announcements);
|
|
|
152 |
|
| 35 |
- |
153 |
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;
|
|
|
154 |
|
| 7 |
- |
155 |
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;
|
|
|
156 |
|
| 35 |
- |
157 |
print $h->div ({ class=>"index" }, [$h->p ({ class=>"heading" }, "MVP Pass Holders:"), $h->ul ([ @mvppass ]) ]) if (scalar @mvppass);
|
|
|
158 |
|
| 7 |
- |
159 |
print $h->div ({ class=>"index" }, [$h->p ({ class=>"heading" }, "Things you can do:"), $h->ul ([ @everyone ]) ]);
|
|
|
160 |
|
|
|
161 |
print $h->div ({ class=>"index" }, [$h->p ({ class=>"heading" }, "Things you can do as a Lead:"), $h->ul ([ @leads ]) ]) if ($LVL > 1);
|
|
|
162 |
|
| 16 |
- |
163 |
print $h->div ({ class=>"index" }, [$h->p ({ class=>"heading" }, "Things you can do as a Manager:"), $h->ul ([ @managers ]) ]) if ($LVL > 2);
|
| 7 |
- |
164 |
|
| 16 |
- |
165 |
print $h->div ({ class=>"index" }, [$h->p ({ class=>"heading" }, "Things you can do as a SysAdmin:"), $h->ul ([ @sysadmins ]) ]) if ($LVL >= 5);
|
|
|
166 |
|
| 8 |
- |
167 |
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 |
- |
168 |
|
|
|
169 |
print $h->div ({ class=>"index" }, [$h->p ({ class=>"heading" }, "Reference:"), $h->ul ([ @reference ]) ]);
|
|
|
170 |
|
|
|
171 |
print $h->close ("body"), $h->close ("html");
|
|
|
172 |
|
| 50 |
bgadell |
173 |
|