Subversion Repositories VORC

Rev

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