| 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)
|
| 180 |
- |
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): $!";
|
| 56 |
bgadell |
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' );
|
| 138 |
- |
16 |
my $dbh = getRCDBH ();
|
| 7 |
- |
17 |
|
| 50 |
bgadell |
18 |
my $cookie_string = authenticate (1) || die;
|
| 7 |
- |
19 |
my ($EML, $PWD, $LVL) = split /&/, $cookie_string;
|
| 50 |
bgadell |
20 |
#my $user = getUser($EML);
|
|
|
21 |
my $user = $ORCUSER;
|
|
|
22 |
#$user->{department} = convertDepartments $user->{department};
|
| 65 |
bgadell |
23 |
#my $activated = max (values %{ $user->{department} });
|
|
|
24 |
my $activated = $ORCUSER->{access};
|
| 50 |
bgadell |
25 |
my $DEPTS = getDepartments ();
|
| 7 |
- |
26 |
|
| 138 |
- |
27 |
print header (-cookie=>CGI::Cookie->new(-name=>'RCAUTH',-value=>"$cookie_string",-expires=>"+30m"));
|
| 7 |
- |
28 |
|
|
|
29 |
#foreach (sort keys %ENV) {
|
|
|
30 |
# print "$_: $ENV{$_}\n<br>";
|
|
|
31 |
#}
|
|
|
32 |
|
|
|
33 |
|
|
|
34 |
use DateTime;
|
|
|
35 |
my $dt = DateTime->today;
|
|
|
36 |
$dt =~ s/T00\:00\:00$//;
|
|
|
37 |
|
| 50 |
bgadell |
38 |
my @announcements;
|
| 134 |
- |
39 |
#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};
|
|
|
40 |
|
|
|
41 |
if ($user->{department}->{EMT} >= RollerCon::USER and !$user->{emt_verified}) {
|
| 135 |
- |
42 |
push @announcements, $h->li ("NOTE: Anyone in the EMT department can see shifts, but you cannot sign up for them until your credentials have been verified. Start here: ".$h->a ({ href => "https://rollercon.com/help-wanted/emts/", target => "_blank" }, "https://rollercon.com/help-wanted/emts/"));
|
| 134 |
- |
43 |
}
|
|
|
44 |
|
| 180 |
- |
45 |
my $volhours = getSchedule ($user->{RCid}, 'all', 'hours');
|
|
|
46 |
if ($volhours) {
|
|
|
47 |
push @announcements, $h->li ("Volunteer Hours: You currently have credit for $volhours hour(s) of volunteer time.");
|
|
|
48 |
}
|
|
|
49 |
|
| 56 |
bgadell |
50 |
my ($announcement) = $dbh->selectrow_array ("select value from setting where setting.key = ?", undef, "ANNOUNCEMENT");
|
|
|
51 |
push @announcements, $h->li ($announcement) if $announcement;
|
| 50 |
bgadell |
52 |
|
| 180 |
- |
53 |
if ($user->{department}->{OFF} > 0) {
|
|
|
54 |
my @days = ("Thursday", "Friday", "Saturday");
|
|
|
55 |
my @dayschecked;
|
|
|
56 |
foreach my $day (@{$dbh->selectall_arrayref ("select dayofweek from v_shift where year(date) = year(now()) and RCid = ? and role = 'Officiating Huddle'", undef, $user->{RCid})}) {
|
|
|
57 |
push @dayschecked, @{$day};
|
|
|
58 |
}
|
|
|
59 |
|
|
|
60 |
use tableViewer qw/inArray/;
|
|
|
61 |
push @announcements, $h->li ("Did you attend the Officiating Huddle on:"),
|
|
|
62 |
$h->form ({ action => "add_officiating_huddle_time.pl", target => "_blank" }, [
|
|
|
63 |
map ({ inArray($_, \@dayschecked) ? $h->input ({ type => "checkbox", name => $_, checked => [] }).$_.$h->br : $h->input ({ type => "checkbox", name => $_ }).$_.$h->br } @days),
|
|
|
64 |
$h->input ({ type => "submit", value => scalar @dayschecked ? "Update my hours." : "Give me credit!" })
|
|
|
65 |
]);
|
|
|
66 |
}
|
| 56 |
bgadell |
67 |
|
| 112 |
- |
68 |
|
| 7 |
- |
69 |
my $schedule = getSchedule ($user->{RCid});
|
|
|
70 |
|
|
|
71 |
my @everyone;
|
|
|
72 |
my @printDEPTS = map { $DEPTS->{$_} } grep { $user->{department}->{$_} > 0 } grep { !/(ANN)|(OFF)/ } sort keys %{$user->{department}};
|
|
|
73 |
push @printDEPTS, "Officiating Lead" if $user->{department}->{"OFF"} > 1;
|
|
|
74 |
my $printDEPTS = join ", ", @printDEPTS;
|
|
|
75 |
push @everyone, $h->li ($h->a ({ href=>"/schedule/shifts.pl" }, "View and Sign Up for $printDEPTS Shifts")) if $printDEPTS;
|
|
|
76 |
push @everyone, $h->li ($h->a ({ href=>"/schedule/officiating_shifts.pl" }, "View and Sign Up for Officiating Shifts")) if $user->{department}->{OFF} > 0;
|
| 183 |
- |
77 |
|
|
|
78 |
if ($user->{department}->{OFF} > 0) {
|
|
|
79 |
foreach my $officiating_year (@{$dbh->selectall_arrayref ("select distinct year(date) as year from v_shift_officiating where RCid = ? and gtype in ('challenge', 'full length', 'selected', 'challenge-rs1', 'challenge-rs2') order by year desc", undef, $user->{RCid})}) {
|
|
|
80 |
push @everyone, $h->li ($h->a ({ href=>"/schedule/ohd.pl?year=".$officiating_year->[0] }, "Export your $officiating_year->[0] games in WFTDA OHD Format (CSV file)"));
|
|
|
81 |
}
|
|
|
82 |
}
|
|
|
83 |
|
| 29 |
- |
84 |
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 |
85 |
push @everyone, $h->li ($h->a ({ href=>"/schedule/games.pl" }, "View Games"));
|
|
|
86 |
push @everyone, $h->li ($h->a ({ href=>"/schedule/personal_time.pl" }, "Block Personal Time"));
|
|
|
87 |
push @everyone, $h->li ($h->a ({ href=>"/schedule/view_user.pl?submit=Edit&RCid=$user->{RCid}" }, "Edit your profile"));
|
| 7 |
- |
88 |
|
| 35 |
- |
89 |
my @mvppass;
|
| 105 |
bgadell |
90 |
my $reviews;
|
|
|
91 |
if ($user->{MVPid} or $user->{department}->{MVP} >= RollerCon::USER or $user->{department}->{COA} >= RollerCon::USER or $LVL >= RollerCon::SYSADMIN) {
|
|
|
92 |
push @mvppass, $h->li ($h->a ({ href=>"/schedule/classes.pl" }, "View and Sign Up for MVP Classes"));
|
|
|
93 |
|
|
|
94 |
# Get a list of classes attended to ask for reviews...
|
| 112 |
- |
95 |
my (@reviews_done, @reviews_tbd);
|
|
|
96 |
foreach my $class (@{$dbh->selectall_arrayref ("select id, date, time, name, coach, count(*) as answers from v_class_signup left join v_survey_answer on id = classid and v_class_signup.RCid = v_survey_answer.RCid where v_class_signup.RCid = ? and year(date) = year(now()) and concat_ws(' ', date, end_time) < date_sub(now(), interval 2 hour) group by id order by date, start_time", undef, $user->{RCid})}) {
|
| 105 |
bgadell |
97 |
my ($id, $date, $time, $name, $coach, $answers) = @{$class};
|
|
|
98 |
next unless $id;
|
|
|
99 |
$time = convertTime $time;
|
|
|
100 |
|
|
|
101 |
if ($answers > 1) {
|
|
|
102 |
push @reviews_done, $h->li ("$date $time: ".$h->a ({ href=>"/schedule/survey.pl?classid=$id" }, "$name [".getUserDerbyName ($coach)."]"));
|
|
|
103 |
} else {
|
|
|
104 |
push @reviews_tbd, $h->li ("$date $time: ".$h->a ({ href=>"/schedule/survey.pl?classid=$id" }, "$name [".getUserDerbyName ($coach)."]"));
|
| 112 |
- |
105 |
}
|
| 105 |
bgadell |
106 |
}
|
| 112 |
- |
107 |
$reviews = $h->li (["Please submit feedback:", $h->ul ([@reviews_tbd])]) unless !scalar @reviews_tbd;
|
|
|
108 |
$reviews .= $h->li (["View the feedback you've submitted:", $h->ul ([@reviews_done])]) unless !scalar @reviews_done;
|
| 35 |
- |
109 |
}
|
| 7 |
- |
110 |
|
|
|
111 |
my @leads = ();
|
|
|
112 |
if ($LVL > 1) {
|
| 56 |
bgadell |
113 |
push @leads, $h->li ($h->a ({ href=>"/schedule/users.pl" }, "View Users in your Department(s)."));
|
| 7 |
- |
114 |
push @leads, $h->li ($h->a ({ href=>"/schedule/password_reset.pl" }, "Reset a Password."));
|
|
|
115 |
|
|
|
116 |
# Officiating Leads:
|
|
|
117 |
if ($user->{department}->{OFF} > 1) {
|
|
|
118 |
unshift @leads, $h->li ($h->a ({ href=>"/schedule/scores.pl" }, "View / Update Game Scores"));
|
|
|
119 |
# push @leads, $h->li ($h->a ({ href=>"daily_print.pl" }, "Daily Print Report"));
|
|
|
120 |
push @leads, $h->li (["What's happening right now on...", $h->ul ([
|
|
|
121 |
$h->li ($h->a ({ href=>"right_now.pl?t=C1" }, "Track C1")),
|
|
|
122 |
$h->li ($h->a ({ href=>"right_now.pl?t=C2" }, "Track C2")),
|
|
|
123 |
$h->li ($h->a ({ href=>"right_now.pl?t=C3" }, "Track C3")),
|
| 141 |
- |
124 |
$h->li ($h->a ({ href=>"right_now.pl?t=C5" }, "Track C5")),
|
|
|
125 |
$h->li ($h->a ({ href=>"right_now.pl?t=BT" }, "Banked Track")),
|
| 7 |
- |
126 |
])]);
|
|
|
127 |
}
|
|
|
128 |
}
|
|
|
129 |
|
|
|
130 |
my @managers;
|
|
|
131 |
if ($LVL >= 3) {
|
|
|
132 |
my $manager_departments = join " or ", map { "department like '%$_-0%'" } grep { $user->{department}->{$_} > 2 } keys %{$user->{department}};
|
| 8 |
- |
133 |
if ($manager_departments) {
|
|
|
134 |
my ($count) = $dbh->selectrow_array ("select count(*) from official where $manager_departments");
|
|
|
135 |
my $counttxt = $count == 1 ? "is 1 user" : "are $count users";
|
| 56 |
bgadell |
136 |
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 |
- |
137 |
}
|
|
|
138 |
push @managers, $h->li ($h->a ({ href=>"/schedule/log.pl" }, "Activity Log"));
|
| 29 |
- |
139 |
push @managers, $h->li ($h->a ({ href=>"/schedule/volhours.pl" }, "View Volunteer Hours by Department"));
|
| 39 |
- |
140 |
|
|
|
141 |
foreach (grep { $user->{department}->{$_} > 2 } keys %{$user->{department}}) {
|
|
|
142 |
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"));
|
|
|
143 |
}
|
|
|
144 |
|
| 46 |
- |
145 |
if ($user->{department}->{VCI} > 2 or $user->{department}->{MVP} > 2 or $LVL > 4) {
|
| 56 |
bgadell |
146 |
push @managers, $h->li ($h->a ({ href=>"/schedule/classes.pl" }, "View MVP Classes"));
|
| 46 |
- |
147 |
push @managers, $h->li ($h->a ({ href=>"/schedule/mvp_class_report.pl", target=>"_new" }, "Daily MVP Class Report (for print)"));
|
| 112 |
- |
148 |
push @managers, $h->li ($h->a ({ href=>"/schedule/mvp_class_report_without_skaters.pl", target=>"_new" }, "Daily MVP Class Report without Skaters (for print)"));
|
| 46 |
- |
149 |
push @managers, $h->li ($h->a ({ href=>"/schedule/daily_print.pl", target=>"_new" }, "Daily Officiating Report (for print)"));
|
|
|
150 |
push @managers, $h->li ($h->a ({ href=>"/schedule/daily_print_announcers.pl", target=>"_new" }, "Daily Announcers Report (for print)"));
|
|
|
151 |
push @managers, $h->li ($h->a ({ href=>"/schedule/print_dept_by_day.pl", target=>"_new" }, "BETA: Daily Shift Report (for print)"));
|
|
|
152 |
}
|
|
|
153 |
|
| 7 |
- |
154 |
# 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
|
|
|
155 |
}
|
|
|
156 |
|
| 90 |
bgadell |
157 |
my (@sysadmins, @mvpcounts);
|
| 16 |
- |
158 |
if ($LVL >= 5) {
|
|
|
159 |
push @sysadmins, $h->li ($h->a ({ href=>"/schedule/bulk_upload.pl" }, "Upload a CSV of Department Shifts"));
|
| 60 |
bgadell |
160 |
push @sysadmins, $h->li ($h->a ({ href=>"/schedule/shifts.pl" }, "Update department shift schedule"));
|
| 58 |
bgadell |
161 |
push @sysadmins, $h->li ($h->a ({ href=>"/schedule/tickets.pl" }, "Manage MVP Ticket Matches"));
|
| 56 |
bgadell |
162 |
push @sysadmins, $h->li ($h->a ({ href=>"/schedule/classes.pl" }, "Manage MVP Classes"));
|
|
|
163 |
push @sysadmins, $h->li ($h->a ({ href=>"/schedule/games.pl" }, "Manage Games"));
|
|
|
164 |
push @sysadmins, $h->li ($h->a ({ href=>"/schedule/departments.pl" }, "Manage Department Settings"));
|
|
|
165 |
push @sysadmins, $h->li ($h->a ({ href=>"/schedule/settings.pl" }, "System Settings"));
|
| 50 |
bgadell |
166 |
push @sysadmins, $h->li ($h->a ({ href=>"/schedule/volhours_report.pl?limit=All" }, "YEAR END VOLUNTEER HOURS REPORT"));
|
| 90 |
bgadell |
167 |
|
|
|
168 |
|
| 35 |
- |
169 |
|
| 90 |
bgadell |
170 |
my ($unclaimed_tix) = $dbh->selectrow_array ("select count(*) from v_ticket where isnull(RCid) = 1");
|
|
|
171 |
my ($mvpcount) = $dbh->selectrow_array ("select count(*) from v_ticket where isnull(RCid) = 0");
|
| 62 |
bgadell |
172 |
$mvpcount = 1 unless $mvpcount;
|
| 90 |
bgadell |
173 |
my $class_limit = getSetting ("MAX_CLASS_SIGNUP");
|
| 35 |
- |
174 |
|
| 90 |
bgadell |
175 |
push @mvpcounts, $h->li ($mvpcount." MVP Tickets have been matched in VORC. ($unclaimed_tix remain unmatched.)");
|
|
|
176 |
push @mvpcounts, $h->li ("They could (in theory) sign up for ".$mvpcount*$class_limit." class spots.");
|
|
|
177 |
|
| 35 |
- |
178 |
|
| 90 |
bgadell |
179 |
my ($signupcount, $total_class_count, $available_count) = $dbh->selectrow_array ("select sum(count), sum(capacity), sum(available) from v_class where year(date) = year(now())");
|
|
|
180 |
|
| 116 |
- |
181 |
$total_class_count //= 0;
|
| 90 |
bgadell |
182 |
push @mvpcounts, $h->li ($total_class_count." Total Class Spots");
|
| 116 |
- |
183 |
push @mvpcounts, $h->li ($signupcount." Filled Class Spots (".sprintf("%.2f", ($signupcount / $total_class_count) * 100)."\%)") unless !$total_class_count;
|
|
|
184 |
push @mvpcounts, $h->li ($available_count." Available Class Spots (".sprintf("%.2f", ($available_count / $total_class_count) * 100)."\%)") unless !$total_class_count;
|
| 90 |
bgadell |
185 |
|
|
|
186 |
|
|
|
187 |
# push @sysadmins, $h->li ($mvpcount." MVP Passholders have signed up for ".$signupcount." spots (".sprintf("%.2f", ($signupcount / ($mvpcount*getSetting("MAX_CLASS_SIGNUP"))) * 100)."\% of allowable signups).");
|
|
|
188 |
# push @sysadmins, $h->li (sprintf("%.2f", ($signupcount / $total_class_count) * 100)."\% of total class spaces are filled.");
|
|
|
189 |
|
| 138 |
- |
190 |
my ($active) = $dbh->selectrow_array ("select count(*) from official where last_active > (now() - interval 30 minute)");
|
| 35 |
- |
191 |
#my ($active) = $dbh->selectrow_array ("select * from official where last_login > (now() - interval 150 minute) order by last_login desc");
|
|
|
192 |
push @sysadmins, $h->li ("There seem to be about $active user session(s) right now.");
|
| 29 |
- |
193 |
# push @sysadmins, $h->li ($h->a ({ href=>"/schedule/volhours.pl" }, "View Volunteer Hours by Department"));
|
| 16 |
- |
194 |
}
|
|
|
195 |
|
| 7 |
- |
196 |
my @activity_log;
|
|
|
197 |
my $alog = $dbh->prepare("select timestamp, event from v_log where RCid = ? limit 10");
|
|
|
198 |
$alog->execute($user->{RCid});
|
|
|
199 |
while (my @logs = $alog->fetchrow_array) {
|
|
|
200 |
my ($d, $t) = split /\s+/, $logs[0];
|
|
|
201 |
push @activity_log, $h->li ({ class=>"shaded" }, join " ", @logs);
|
|
|
202 |
}
|
|
|
203 |
|
|
|
204 |
my @reference;
|
| 8 |
- |
205 |
push @reference, $h->li ($h->a ({ href=>"/info.html" }, "Information about using this tool"));
|
| 7 |
- |
206 |
push @reference, $h->li ($h->a ({ href=>"http://rollercon.com/help-wanted/officiating/" }, "RollerCon Officiating Details"));
|
|
|
207 |
|
|
|
208 |
printRCHeader("Home");
|
|
|
209 |
print $h->close ("table");
|
|
|
210 |
|
| 50 |
bgadell |
211 |
print $h->form ({ name => "Req", action => url });
|
| 7 |
- |
212 |
|
| 50 |
bgadell |
213 |
print $h->div ({ class=>"index" }, [$h->p ({ class=>"heading" }, "Announcement:"), $h->ul ([ @announcements ]) ]) if (scalar @announcements);
|
|
|
214 |
|
| 35 |
- |
215 |
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;
|
|
|
216 |
|
| 7 |
- |
217 |
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;
|
|
|
218 |
|
| 105 |
bgadell |
219 |
print $h->div ({ class=>"index" }, [$h->p ({ class=>"heading" }, "MVP Classes:"), $h->ul ([ @mvppass, $reviews ]) ]) if (scalar @mvppass);
|
| 35 |
- |
220 |
|
| 7 |
- |
221 |
print $h->div ({ class=>"index" }, [$h->p ({ class=>"heading" }, "Things you can do:"), $h->ul ([ @everyone ]) ]);
|
|
|
222 |
|
|
|
223 |
print $h->div ({ class=>"index" }, [$h->p ({ class=>"heading" }, "Things you can do as a Lead:"), $h->ul ([ @leads ]) ]) if ($LVL > 1);
|
|
|
224 |
|
| 16 |
- |
225 |
print $h->div ({ class=>"index" }, [$h->p ({ class=>"heading" }, "Things you can do as a Manager:"), $h->ul ([ @managers ]) ]) if ($LVL > 2);
|
| 7 |
- |
226 |
|
| 16 |
- |
227 |
print $h->div ({ class=>"index" }, [$h->p ({ class=>"heading" }, "Things you can do as a SysAdmin:"), $h->ul ([ @sysadmins ]) ]) if ($LVL >= 5);
|
|
|
228 |
|
| 90 |
bgadell |
229 |
print $h->div ({ class=>"index" }, [$h->p ({ class=>"heading" }, "MVP Class and Ticket Status:"), $h->ul ([ @mvpcounts ]) ]) if (scalar @mvpcounts);
|
|
|
230 |
|
| 8 |
- |
231 |
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 |
- |
232 |
|
|
|
233 |
print $h->div ({ class=>"index" }, [$h->p ({ class=>"heading" }, "Reference:"), $h->ul ([ @reference ]) ]);
|
|
|
234 |
|
|
|
235 |
print $h->close ("body"), $h->close ("html");
|
|
|
236 |
|
| 50 |
bgadell |
237 |
|