Rev 7 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
#!/usr/bin/perl -wuse strict;use lib "/home/rollerco/perl5/lib/perl5";use RollerCon;use CGI;use CGI::Cookie;my $cookie_string = authenticate(1) || die;my ($EML, $PWD, $LVL) = split /&/, $cookie_string;my $user = getUser($EML);my $RCAUTH_cookie = CGI::Cookie->new(-name=>'RCAUTH',-value=>"$cookie_string",-expires=>"+30m");my @shifts;print CGI::header(-cookie=>$RCAUTH_cookie);#foreach (sort keys %ENV) {# print "$_: $ENV{$_}\n<br>";#}use DBI;my $dsn = "DBI:mysql:database=rollerco_data;host=localhost;port=3306";my $dbh = DBI->connect($dsn, 'rollerco_www', 'www-data');my @everyone = ("<li><A HREF='/schedule/manage_user.pl?submit=New%20User'>Register a new user (which will log you out).</A></li>","<li><A HREF='/schedule/manage_user.pl?submit=View&RCid=$user->{RCid}'>View your profile.</a></li>","<li><A HREF='/schedule/password_reset.pl'>Reset a Password.</a></li>","<li><A HREF='/schedule/shifts.pl'>View and Sign Up for Officiating Shifts</a>");my @leads = ();if ($LVL > 1) {push @leads, "<li><A HREF='/schedule/scores.pl'>View / Update Game Scores</a></li>";push @leads, "<li><A HREF='https://www.volgistics.com/ex/touch.dll/?FROM=36211&PW=72160858'>Volgistics Sign In</a></li>";push @leads, "<li><A HREF='/schedule/user_report.pl'>View All Users.</a></li>";push @leads, "<li><A HREF='/schedule/lead_shifts.pl'>View and Sign Up for Track Lead Shifts.</a></li>";push @leads, "<li><a href='daily_print.pl'>Daily Print Report</a></li>";push @leads, "<li>What's happening right now on...<ul>";push @leads, "<li><a href='right_now.pl?t=C1'>Track C1</li>";push @leads, "<li><a href='right_now.pl?t=C2'>Track C2</li>";push @leads, "<li><a href='right_now.pl?t=C3'>Track C3</li>";push @leads, "<li><a href='right_now.pl?t=C4'>Track C4</li>";push @leads, "<li><a href='right_now.pl?t=B'>Track B</li></ul></li>";}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");$sth->execute($user->{RCid}, $user->{RCid});while (my $s = $sth->fetchrow_hashref) {push @shifts, $s;if ($s->{role} eq 'Track Lead') {$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>";} elsif ($s->{gtype} ne 'selected staffing') {$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>";}$s->{role} =~ s/\-\d$//;}my @managers;if ($LVL >= 3) {push @managers, "<li><a href=/schedule/log.pl>Activity Log</a></li>";my $sth = $dbh->prepare("select count(*) from official where access = 0");$sth->execute();my ($count) = $sth->fetchrow_array;my $counttxt = $count == 1 ? "is 1 user" : "are $count users";push @managers, "There $counttxt waiting to be activated.";if ($count) {push @managers, "<li><a href=/schedule/activate_users.pl>Activate New Users</a> (everyone in queue, all in one shot) PLEASE BE CAREFUL</li>";}# 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}printRCHeader("Home");use DateTime;my $dt = DateTime->today;$dt =~ s/T00\:00\:00$//;if (scalar @shifts) {print<<shifts;<TR><TD colspan=2> </TD></TR><TR><TD colspan=2>Your up-coming schedule ($dt):<center><table>shiftsforeach (@shifts) {if ($_->{date} eq $dt) {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";} else {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";}}print<<shifts_end<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></table></TD></TR>shifts_end}print<<page1;<TR><TD colspan=2> </TD></TR><TR><TD valign=top>Reference:</td><TD valign=top><ul><li><a href="http://rollercon.com/help-wanted/officiating/">RollerCon Officiating Details</a></ul></li></TD></TR><TR><TD colspan=2> </TD></TR><TR><TD valign=top>Things you can do:</td><TD valign=top><ul>@everyone</ul></TD></TR>page1if ($LVL > 1) {print<<page1a;<TR><TD colspan=2> </TD></TR><TR><TD valign=top>Things you can do as a Lead:</td><TD valign=top><ul>@leads</ul></TD></TR>page1a}if ($LVL > 2) {print<<page1b;<TR><TD colspan=2> </TD></TR><TR><TD valign=top>Things you can do as a Manager:</td><TD valign=top><ul>@managers</ul></TD></TR>page1b}my @activity_log;my $alog = $dbh->prepare("select timestamp, event from v_log where RCid = ? limit 10");$alog->execute($user->{RCid});print<<activitylog;<TR><TD colspan=2> </TD></TR><TR><TD valign=top>Your Latest Activity:</td><TD valign=top><table><tr><td>Date:</td><td> </td><td>Time (PDT):</td><td> </td><td>Event:</td></tr>activitylogwhile (my @logs = $alog->fetchrow_array) {my ($d, $t) = split /\s+/, $logs[0];print "<tr><td>$d</td><td> </td><td>$t</td><td> </td><td>$logs[1]</td></tr>";}print<<activitylog2;</table></td></TR>activitylog2print "</table></body></html>";