Subversion Repositories ORC

Rev

Rev 2 | Rev 8 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

#!/usr/bin/perl

use strict;
use RollerCon;
use CGI;
use CGI::Cookie;
use WebDB;
our $h = HTML::Tiny->new( mode => 'html' );

my $cookie_string = authenticate(1) || die;
my ($EML, $PWD, $LVL) = split /&/, $cookie_string;
my $user = getUser($EML);
$user->{department} = convertDepartments $user->{department};
my $RCAUTH_cookie = CGI::Cookie->new(-name=>'RCAUTH',-value=>"$cookie_string",-expires=>"+30m");
my $DEPTS = getDepartments;

print CGI::header(-cookie=>$RCAUTH_cookie);

#foreach (sort keys %ENV) {
#       print "$_: $ENV{$_}\n<br>";
#}

#use DBI;
my $dbh = WebDB->connect ();

use DateTime;
my $dt = DateTime->today;
$dt =~ s/T00\:00\:00$//;

my $schedule = getSchedule ($user->{RCid});

my @everyone;
my @printDEPTS = map { $DEPTS->{$_} } grep { $user->{department}->{$_} > 0 } grep { !/(ANN)|(OFF)/ } sort keys %{$user->{department}};
push @printDEPTS, "Officiating Lead" if $user->{department}->{"OFF"} > 1;
my $printDEPTS = join ", ", @printDEPTS;
push @everyone, $h->li ($h->a ({ href=>"/schedule/shifts.pl" }, "View and Sign Up for $printDEPTS Shifts")) if $printDEPTS;
push @everyone, $h->li ($h->a ({ href=>"/schedule/officiating_shifts.pl" }, "View and Sign Up for Officiating Shifts")) if $user->{department}->{OFF} > 0;
push @everyone, $h->li ($h->a ({ href=>"/schedule/announcer_shifts.pl" }, "View and Sign Up for Announcer Shifts")) if $user->{department}->{ANN} > 0;
push @everyone, $h->li ($h->a ({ href=>"/schedule/manage_personal_time.pl" }, "Block Personal Time"));
push @everyone, $h->li ($h->a ({ href=>"/schedule/manage_user.pl?submit=Edit&RCid=$user->{RCid}" }, "Edit your profile"));


my @leads = ();
if ($LVL > 1) {
        push @leads, $h->li ($h->a ({ href=>"/schedule/user_report.pl" }, "View Users in your Department(s)."));
        push @leads, $h->li ($h->a ({ href=>"/schedule/password_reset.pl" }, "Reset a Password."));

        # Officiating Leads:
        if ($user->{department}->{OFF} > 1) {
                unshift @leads, $h->li ($h->a ({ href=>"/schedule/scores.pl" }, "View / Update Game Scores"));
#                push @leads, $h->li ($h->a ({ href=>"daily_print.pl" }, "Daily Print Report"));
                push @leads, $h->li (["What's happening right now on...", $h->ul ([
                        $h->li ($h->a ({ href=>"right_now.pl?t=C1" }, "Track C1")),
                        $h->li ($h->a ({ href=>"right_now.pl?t=C2" }, "Track C2")),
                        $h->li ($h->a ({ href=>"right_now.pl?t=C3" }, "Track C3")),
                        $h->li ($h->a ({ href=>"right_now.pl?t=C4" }, "Track C4")),
                        $h->li ($h->a ({ href=>"right_now.pl?t=B"  }, "Track B")),
                ])]);
        }
}
        
my @managers;
if ($LVL >= 3) {
        my $manager_departments = join " or ", map { "department like '%$_-0%'" } grep { $user->{department}->{$_} > 2 } keys %{$user->{department}};
        my ($count) = $dbh->selectrow_array ("select count(*) from official where $manager_departments");
        my $counttxt = $count == 1 ? "is 1 user" : "are $count users";
        push @managers, $h->li ($h->a ({ href=>"user_report.pl?filter-access=0" }, "There $counttxt waiting to be activated")) if $count;
        push @managers, $h->li ($h->a ({ href=>"/schedule/manage_shifts.pl" }, "Update your department shift schedule"));
        push @managers, $h->li ($h->a ({ href=>"/schedule/log.pl" }, "Activity Log"));
        
        # 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
}

my @activity_log;
my $alog = $dbh->prepare("select timestamp, event from v_log where RCid = ? limit 10");
$alog->execute($user->{RCid});
while (my @logs = $alog->fetchrow_array) {
        my ($d, $t) = split /\s+/, $logs[0];
        push @activity_log, $h->li ({ class=>"shaded" }, join " ", @logs);
}

my @reference;
push @reference, $h->li ($h->a ({ href=>"http://rollercon.com/help-wanted/officiating/" }, "RollerCon Officiating Details"));

printRCHeader("Home");
print $h->close ("table");

print $h->form ({ name=>"Req", action=>url });

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;

print $h->div ({ class=>"index" }, [$h->p ({ class=>"heading" }, "Things you can do:"), $h->ul ([ @everyone ]) ]);

print $h->div ({ class=>"index" }, [$h->p ({ class=>"heading" }, "Things you can do as a Lead:"), $h->ul ([ @leads ]) ]) if ($LVL > 1);

print $h->div ({ class=>"index" }, [$h->p ({ class=>"heading" }, "Things you can do as a Manager:"), $h->ul ([ @managers ]) ]) if ($LVL > 1);

print $h->div ({ class=>"index" }, [$h->p ({ class=>"heading" }, "Your Latest Activity:"), $h->ul ([ @activity_log ]), $h->h5 ($h->a ({ href=>"log.pl?filter-RCid=".$user->{RCid} }, "[Your entire log history]")) ]);

print $h->div ({ class=>"index" }, [$h->p ({ class=>"heading" }, "Reference:"), $h->ul ([ @reference ]) ]);

print $h->close ("body"), $h->close ("html");
;