| 2 |
- |
1 |
#!/usr/bin/perl -w
|
|
|
2 |
|
|
|
3 |
use strict;
|
|
|
4 |
use lib "/home/rollerco/perl5/lib/perl5";
|
|
|
5 |
use RollerCon;
|
|
|
6 |
use CGI;
|
|
|
7 |
use CGI::Cookie;
|
|
|
8 |
|
|
|
9 |
my $cookie_string = authenticate(1) || die;
|
|
|
10 |
my ($EML, $PWD, $LVL) = split /&/, $cookie_string;
|
|
|
11 |
my $user = getUser($EML);
|
|
|
12 |
my $RCAUTH_cookie = CGI::Cookie->new(-name=>'RCAUTH',-value=>"$cookie_string",-expires=>"+30m");
|
|
|
13 |
my @shifts;
|
|
|
14 |
|
|
|
15 |
print CGI::header(-cookie=>$RCAUTH_cookie);
|
|
|
16 |
|
|
|
17 |
#foreach (sort keys %ENV) {
|
|
|
18 |
# print "$_: $ENV{$_}\n<br>";
|
|
|
19 |
#}
|
|
|
20 |
|
|
|
21 |
use DBI;
|
|
|
22 |
my $dsn = "DBI:mysql:database=rollerco_data;host=localhost;port=3306";
|
|
|
23 |
my $dbh = DBI->connect($dsn, 'rollerco_www', 'www-data');
|
|
|
24 |
|
|
|
25 |
my @everyone = ("<li><A HREF='/schedule/manage_user.pl?submit=New%20User'>Register a new user (which will log you out).</A></li>",
|
|
|
26 |
"<li><A HREF='/schedule/manage_user.pl?submit=View&RCid=$user->{RCid}'>View your profile.</a></li>",
|
|
|
27 |
"<li><A HREF='/schedule/password_reset.pl'>Reset a Password.</a></li>",
|
|
|
28 |
"<li><A HREF='/schedule/shifts.pl'>View and Sign Up for Officiating Shifts</a>"
|
|
|
29 |
);
|
|
|
30 |
my @leads = ();
|
|
|
31 |
|
|
|
32 |
if ($LVL > 1) {
|
|
|
33 |
push @leads, "<li><A HREF='/schedule/scores.pl'>View / Update Game Scores</a></li>";
|
|
|
34 |
push @leads, "<li><A HREF='https://www.volgistics.com/ex/touch.dll/?FROM=36211&PW=72160858'>Volgistics Sign In</a></li>";
|
|
|
35 |
push @leads, "<li><A HREF='/schedule/user_report.pl'>View All Users.</a></li>";
|
|
|
36 |
push @leads, "<li><A HREF='/schedule/lead_shifts.pl'>View and Sign Up for Track Lead Shifts.</a></li>";
|
|
|
37 |
push @leads, "<li><a href='daily_print.pl'>Daily Print Report</a></li>";
|
|
|
38 |
push @leads, "<li>What's happening right now on...<ul>";
|
|
|
39 |
push @leads, "<li><a href='right_now.pl?t=C1'>Track C1</li>";
|
|
|
40 |
push @leads, "<li><a href='right_now.pl?t=C2'>Track C2</li>";
|
|
|
41 |
push @leads, "<li><a href='right_now.pl?t=C3'>Track C3</li>";
|
|
|
42 |
push @leads, "<li><a href='right_now.pl?t=C4'>Track C4</li>";
|
|
|
43 |
push @leads, "<li><a href='right_now.pl?t=B'>Track B</li></ul></li>";
|
|
|
44 |
}
|
|
|
45 |
|
|
|
46 |
my $sth = $dbh->prepare("select * from (select id, date, dayofweek, track, time, role, teams, gtype from v_shift where RCid = ? union select id, date, dayofweek, track , time, 'Track Lead' as role, '' as teams, '' as gtype from v_lead_shift where assignee_id = ?) temp where date >= date(now()) order by date, time");
|
|
|
47 |
$sth->execute($user->{RCid}, $user->{RCid});
|
|
|
48 |
while (my $s = $sth->fetchrow_hashref) {
|
|
|
49 |
push @shifts, $s;
|
|
|
50 |
if ($s->{role} eq 'Track Lead') {
|
|
|
51 |
$s->{drop} = "<A HREF='#' onClick=\"window.open('make_lead_shift_change.pl?change=del&shift=$s->{id}','Confirm Shift Change','resizable,height=260,width=370'); return false;\">[DROP]</a>";
|
|
|
52 |
} elsif ($s->{gtype} ne 'selected staffing') {
|
|
|
53 |
$s->{drop} = "<A HREF='#' onClick=\"window.open('make_shift_change.pl?change=del&RCid=$user->{RCid}&id=$s->{id}&role=$s->{role}','Confirm Shift Change','resizable,height=260,width=370'); return false;\">[DROP]</a>";
|
|
|
54 |
}
|
|
|
55 |
$s->{role} =~ s/\-\d$//;
|
|
|
56 |
}
|
|
|
57 |
|
|
|
58 |
my @managers;
|
|
|
59 |
if ($LVL >= 3) {
|
|
|
60 |
push @managers, "<li><a href=/schedule/log.pl>Activity Log</a></li>";
|
|
|
61 |
my $sth = $dbh->prepare("select count(*) from official where access = 0");
|
|
|
62 |
$sth->execute();
|
|
|
63 |
my ($count) = $sth->fetchrow_array;
|
|
|
64 |
my $counttxt = $count == 1 ? "is 1 user" : "are $count users";
|
|
|
65 |
push @managers, "There $counttxt waiting to be activated.";
|
|
|
66 |
if ($count) {
|
|
|
67 |
push @managers, "<li><a href=/schedule/activate_users.pl>Activate New Users</a> (everyone in queue, all in one shot) PLEASE BE CAREFUL</li>";
|
|
|
68 |
}
|
|
|
69 |
|
|
|
70 |
# 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
|
|
|
71 |
}
|
|
|
72 |
|
|
|
73 |
printRCHeader("Home");
|
|
|
74 |
|
|
|
75 |
use DateTime;
|
|
|
76 |
my $dt = DateTime->today;
|
|
|
77 |
$dt =~ s/T00\:00\:00$//;
|
|
|
78 |
|
|
|
79 |
if (scalar @shifts) {
|
|
|
80 |
print<<shifts;
|
|
|
81 |
<TR><TD colspan=2> </TD></TR>
|
|
|
82 |
<TR>
|
|
|
83 |
<TD colspan=2>Your up-coming schedule ($dt):<center>
|
|
|
84 |
<table>
|
|
|
85 |
shifts
|
|
|
86 |
|
|
|
87 |
foreach (@shifts) {
|
|
|
88 |
if ($_->{date} eq $dt) {
|
|
|
89 |
print "<tr><td><b>$_->{date}</td><td> </td><td><b>$_->{dayofweek}</td><td> </td><td><b>$_->{track}</td><td> </td><td><b>$_->{time}</td><td> </td><td><b>$_->{role}</td><td> </td><td><b>$_->{teams}</td><td><b> </td><td>$_->{drop}</td></tr>\n";
|
|
|
90 |
} else {
|
|
|
91 |
print "<tr><td>$_->{date}</td><td> </td><td>$_->{dayofweek}</td><td> </td><td>$_->{track}</td><td> </td><td>$_->{time}</td><td> </td><td>$_->{role}</td><td> </td><td>$_->{teams}</td><td> </td><td>$_->{drop}</td></tr>\n";
|
|
|
92 |
}
|
|
|
93 |
}
|
|
|
94 |
|
|
|
95 |
print<<shifts_end
|
|
|
96 |
<tr><td colspan=13><center><small>[<i><a href=export_ics.pl?RCid=$user->{RCid}>use this link for iCal</a></i>]</small></td></tr>
|
|
|
97 |
</table>
|
|
|
98 |
</TD>
|
|
|
99 |
</TR>
|
|
|
100 |
shifts_end
|
|
|
101 |
}
|
|
|
102 |
|
|
|
103 |
print<<page1;
|
|
|
104 |
|
|
|
105 |
<TR><TD colspan=2> </TD></TR>
|
|
|
106 |
<TR>
|
|
|
107 |
<TD valign=top>Reference:</td>
|
|
|
108 |
<TD valign=top><ul><li><a href="http://rollercon.com/help-wanted/officiating/">RollerCon Officiating Details</a></ul></li></TD>
|
|
|
109 |
</TR>
|
|
|
110 |
<TR><TD colspan=2> </TD></TR>
|
|
|
111 |
<TR>
|
|
|
112 |
<TD valign=top>Things you can do:</td>
|
|
|
113 |
<TD valign=top><ul>@everyone</ul></TD>
|
|
|
114 |
</TR>
|
|
|
115 |
page1
|
|
|
116 |
|
|
|
117 |
if ($LVL > 1) {
|
|
|
118 |
print<<page1a;
|
|
|
119 |
<TR><TD colspan=2> </TD></TR>
|
|
|
120 |
<TR>
|
|
|
121 |
<TD valign=top>Things you can do as a Lead:</td>
|
|
|
122 |
<TD valign=top><ul>@leads</ul></TD>
|
|
|
123 |
</TR>
|
|
|
124 |
|
|
|
125 |
|
|
|
126 |
page1a
|
|
|
127 |
}
|
|
|
128 |
|
|
|
129 |
if ($LVL > 2) {
|
|
|
130 |
print<<page1b;
|
|
|
131 |
<TR><TD colspan=2> </TD></TR>
|
|
|
132 |
<TR>
|
|
|
133 |
<TD valign=top>Things you can do as a Manager:</td>
|
|
|
134 |
<TD valign=top><ul>@managers</ul></TD>
|
|
|
135 |
</TR>
|
|
|
136 |
|
|
|
137 |
|
|
|
138 |
page1b
|
|
|
139 |
}
|
|
|
140 |
|
|
|
141 |
my @activity_log;
|
|
|
142 |
my $alog = $dbh->prepare("select timestamp, event from v_log where RCid = ? limit 10");
|
|
|
143 |
$alog->execute($user->{RCid});
|
|
|
144 |
print<<activitylog;
|
|
|
145 |
<TR><TD colspan=2> </TD></TR>
|
|
|
146 |
<TR>
|
|
|
147 |
<TD valign=top>Your Latest Activity:</td>
|
|
|
148 |
<TD valign=top>
|
|
|
149 |
<table>
|
|
|
150 |
<tr><td>Date:</td><td> </td><td>Time (PDT):</td><td> </td><td>Event:</td></tr>
|
|
|
151 |
activitylog
|
|
|
152 |
|
|
|
153 |
while (my @logs = $alog->fetchrow_array) {
|
|
|
154 |
my ($d, $t) = split /\s+/, $logs[0];
|
|
|
155 |
print "<tr><td>$d</td><td> </td><td>$t</td><td> </td><td>$logs[1]</td></tr>";
|
|
|
156 |
}
|
|
|
157 |
|
|
|
158 |
print<<activitylog2;
|
|
|
159 |
</table>
|
|
|
160 |
</td>
|
|
|
161 |
</TR>
|
|
|
162 |
activitylog2
|
|
|
163 |
|
|
|
164 |
|
|
|
165 |
print "</table></body></html>";
|