Subversion Repositories ORC

Rev

Blame | Last modification | View Log | RSS feed

#!/usr/bin/perl

use strict;
use cPanelUserConfig;
use RollerCon;
use WebDB;
use tableViewer;
use CGI;
use CGI::Cookie;
use DateTime;

my $cookie_string = authenticate(2) || 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 $date = param ("date");
my $dt;
if ($date =~ /^\d{4}-\d{2}-\d{2}$/) {
  my ($YYYY, $MM, $DD) = split /-/, $date;
  $dt = DateTime->new(
    year  => $YYYY,
    month => $MM,
    day   => $DD
  );
} else {
  $dt = DateTime->today;
  $date = $dt->date;
}
my $day = $dt->day_name;

my %class = qw(
        U Unrestricted
        M Mens
        W Womens
        SS Single-Gender
);

my $dbh = WebDB::connect ();

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




print<<output;
<html><head><title>RollerCon VORC - Daily Announcer Schedule - $day ($date)</title>
<link rel="stylesheet" type="text/css" href="/rollercon.css">
</head>
<body text="#000000" bgcolor="#FFFFFF" link="#0000EE" vlink="#551A8B" alink="#FF0000">
output

my $gcount = 1; my $tcount = '';
my $sth = $dbh->prepare("select distinct teams, track, level, time, gtype, restrictions from v_shift_announcer where date = ? order by track, time");
my $crewhan = $dbh->prepare("select role, derby_name from v_shift_announcer where date = ? and track = ? and time = ?");
my $leadhan = $dbh->prepare("select location, time, derby_name from v_shift where dept = 'ANN' and date = ? order by location, time");
my $openshifthan = $dbh->prepare("select time, level, restrictions, gtype, teams, tla, name from v_shift_announcer where tla <> 'ALT' and isNull(derby_name) = 1 and date = ? and track = ? order by time");

my @leads = ("<table>\n", "<tr><td colspan=5><b>Lead Shifts</b></td></tr>\n");
$leadhan->execute($date);
my $tc = 'C1';
while (my $lshift = $leadhan->fetchrow_hashref()) {
        if ($tc ne $lshift->{location}) {
                push @leads, "<tr><td colspan=5>&nbsp;</td></tr>\n";
                $tc = $lshift->{location};
        }
        push @leads, "<tr><td>$lshift->{location}</td><td>&nbsp;</td><td>$lshift->{time}</td><td>&nbsp;</td><td>$lshift->{derby_name}</td></tr>\n";
}
push @leads, "</table>\n";

$sth->execute($date);
while (my $g = $sth->fetchrow_hashref()) {
        if ($tcount ne $g->{track}) { #pagebreak whenever we change tracks
                print "<div class='pagebreak'><hr></div>\n" unless !$tcount;
                print @leads;
                
                my @openshifts = ("<table>\n", "<tr><td colspan=5><b>Open Shifts on $g->{track}</b></td></tr>\n");
                $openshifthan->execute($date, $g->{track});
                while (my @oshift = $openshifthan->fetchrow_array()) {
                        my $sh = join "</td><td>&nbsp;</td><td>", @oshift;
                        push @openshifts, "<tr><td>$sh</td></tr>\n";
                }
                push @openshifts, "</table>\n";
                print "<br><br><br><br>";
                print @openshifts;
                
                print "<div class='pagebreak'><hr></div>\n";
                $gcount = 1;
                $tcount = $g->{track};
        }
        
        $g->{gtype} = join '', map { ucfirst lc } split /(\s+)/, $g->{gtype}; # Capitalize the game time to look nicer

        my %crew;
        $crewhan->execute($date, $g->{track}, $g->{time});
        while (my ($k, $v) = $crewhan->fetchrow_array()) {
                $crew{$k} = $v;
        }
                
        my $A = '';
        if (defined $crew{'ALT'}) {
                $A = "ALT:";
        } else {
                $crew{'ALT'} = '';
        }
        
        print<<game;
<table>
        <tr><td>Date:</td><td>$day ($date)</td><td>&nbsp;</td><td>Track:</td><td>$g->{track}</td></tr>
        <tr><td>Time:</td><td>$g->{time}</td><td>&nbsp;</td><td>Class:</td><td>$class{$g->{restrictions}} $g->{level} $g->{gtype}</td></tr>
        <tr><td>Game:</td><td colspan=4>$g->{teams}</td></tr>
        <tr><td colspan=5>&nbsp;</td></tr>
        <tr><td>Color:</td><td colspan=4>$crew{'COL'}</td></tr>
        <tr><td>Play-by-play:</td><td colspan=4>$crew{'PBP'}</td></tr>
        <tr><td>Sponsorship:</td><td colspan=4>$crew{'SPO'}</td></tr>
</table><br><br><br><br><br><br><br><br><br><br><br><br>
game

        $gcount++ % 4 == 0 ? print "<div class='pagebreak'><hr></div>\n" : { };
}



print<<tail;
</BODY>
</HTML>
tail